documentation.d.ts 3.9 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264
  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 handeled
  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 througouht 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 preceeding 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 dependncies */
  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 ressource is not delayed*/
  688. static readonly DELAYLOADSTATE_NONE: number;
  689. /** Defines that the ressource was successfully delay loaded */
  690. static readonly DELAYLOADSTATE_LOADED: number;
  691. /** Defines that the ressource is currently delay loading */
  692. static readonly DELAYLOADSTATE_LOADING: number;
  693. /** Defines that the ressource 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. * Detailled 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 + normal index in the textures array in the prepass
  1122. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1123. */
  1124. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1125. /**
  1126. * Constant used to retrieve albedo index in the textures array in the prepass
  1127. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1128. */
  1129. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1130. /**
  1131. * Prefixes used by the engine for custom effects
  1132. */
  1133. static readonly CUSTOMEFFECT_PREFIX_SHADOWGENERATOR: string;
  1134. }
  1135. }
  1136. declare module BABYLON {
  1137. /** @hidden */
  1138. export interface HardwareTextureWrapper {
  1139. underlyingResource: any;
  1140. set(hardwareTexture: any): void;
  1141. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  1142. reset(): void;
  1143. release(): void;
  1144. }
  1145. }
  1146. declare module BABYLON {
  1147. /**
  1148. * This represents the required contract to create a new type of texture loader.
  1149. */
  1150. export interface IInternalTextureLoader {
  1151. /**
  1152. * Defines wether the loader supports cascade loading the different faces.
  1153. */
  1154. supportCascades: boolean;
  1155. /**
  1156. * This returns if the loader support the current file information.
  1157. * @param extension defines the file extension of the file being loaded
  1158. * @param mimeType defines the optional mime type of the file being loaded
  1159. * @returns true if the loader can load the specified file
  1160. */
  1161. canLoad(extension: string, mimeType?: string): boolean;
  1162. /**
  1163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1164. * @param data contains the texture data
  1165. * @param texture defines the BabylonJS internal texture
  1166. * @param createPolynomials will be true if polynomials have been requested
  1167. * @param onLoad defines the callback to trigger once the texture is ready
  1168. * @param onError defines the callback to trigger in case of error
  1169. * @param options options to be passed to the loader
  1170. */
  1171. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1172. /**
  1173. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1174. * @param data contains the texture data
  1175. * @param texture defines the BabylonJS internal texture
  1176. * @param callback defines the method to call once ready to upload
  1177. * @param options options to be passed to the loader
  1178. */
  1179. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /**
  1184. * @hidden
  1185. */
  1186. export interface IColor4Like {
  1187. r: float;
  1188. g: float;
  1189. b: float;
  1190. a: float;
  1191. }
  1192. /**
  1193. * @hidden
  1194. */
  1195. export interface IColor3Like {
  1196. r: float;
  1197. g: float;
  1198. b: float;
  1199. }
  1200. /**
  1201. * @hidden
  1202. */
  1203. export interface IVector4Like {
  1204. x: float;
  1205. y: float;
  1206. z: float;
  1207. w: float;
  1208. }
  1209. /**
  1210. * @hidden
  1211. */
  1212. export interface IVector3Like {
  1213. x: float;
  1214. y: float;
  1215. z: float;
  1216. }
  1217. /**
  1218. * @hidden
  1219. */
  1220. export interface IVector2Like {
  1221. x: float;
  1222. y: float;
  1223. }
  1224. /**
  1225. * @hidden
  1226. */
  1227. export interface IMatrixLike {
  1228. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1229. updateFlag: int;
  1230. }
  1231. /**
  1232. * @hidden
  1233. */
  1234. export interface IViewportLike {
  1235. x: float;
  1236. y: float;
  1237. width: float;
  1238. height: float;
  1239. }
  1240. /**
  1241. * @hidden
  1242. */
  1243. export interface IPlaneLike {
  1244. normal: IVector3Like;
  1245. d: float;
  1246. normalize(): void;
  1247. }
  1248. }
  1249. declare module BABYLON {
  1250. /**
  1251. * Class used to store and describe the pipeline context associated with an effect
  1252. */
  1253. export interface IPipelineContext {
  1254. /**
  1255. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1256. */
  1257. isAsync: boolean;
  1258. /**
  1259. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1260. */
  1261. isReady: boolean;
  1262. /** @hidden */
  1263. _name?: string;
  1264. /** @hidden */
  1265. _getVertexShaderCode(): string | null;
  1266. /** @hidden */
  1267. _getFragmentShaderCode(): string | null;
  1268. /** @hidden */
  1269. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1270. /** @hidden */
  1271. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  1272. [key: string]: number;
  1273. }, uniformsNames: string[], uniforms: {
  1274. [key: string]: Nullable<WebGLUniformLocation>;
  1275. }, samplerList: string[], samplers: {
  1276. [key: string]: number;
  1277. }, attributesNames: string[], attributes: number[]): void;
  1278. /** Releases the resources associated with the pipeline. */
  1279. dispose(): void;
  1280. /**
  1281. * Sets an integer value on a uniform variable.
  1282. * @param uniformName Name of the variable.
  1283. * @param value Value to be set.
  1284. */
  1285. setInt(uniformName: string, value: number): void;
  1286. /**
  1287. * Sets an int2 value on a uniform variable.
  1288. * @param uniformName Name of the variable.
  1289. * @param x First int in int2.
  1290. * @param y Second int in int2.
  1291. */
  1292. setInt2(uniformName: string, x: number, y: number): void;
  1293. /**
  1294. * Sets an int3 value on a uniform variable.
  1295. * @param uniformName Name of the variable.
  1296. * @param x First int in int3.
  1297. * @param y Second int in int3.
  1298. * @param z Third int in int3.
  1299. */
  1300. setInt3(uniformName: string, x: number, y: number, z: number): void;
  1301. /**
  1302. * Sets an int4 value on a uniform variable.
  1303. * @param uniformName Name of the variable.
  1304. * @param x First int in int4.
  1305. * @param y Second int in int4.
  1306. * @param z Third int in int4.
  1307. * @param w Fourth int in int4.
  1308. */
  1309. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1310. /**
  1311. * Sets an int array on a uniform variable.
  1312. * @param uniformName Name of the variable.
  1313. * @param array array to be set.
  1314. */
  1315. setIntArray(uniformName: string, array: Int32Array): void;
  1316. /**
  1317. * 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)
  1318. * @param uniformName Name of the variable.
  1319. * @param array array to be set.
  1320. */
  1321. setIntArray2(uniformName: string, array: Int32Array): void;
  1322. /**
  1323. * 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)
  1324. * @param uniformName Name of the variable.
  1325. * @param array array to be set.
  1326. */
  1327. setIntArray3(uniformName: string, array: Int32Array): void;
  1328. /**
  1329. * 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)
  1330. * @param uniformName Name of the variable.
  1331. * @param array array to be set.
  1332. */
  1333. setIntArray4(uniformName: string, array: Int32Array): void;
  1334. /**
  1335. * Sets an array on a uniform variable.
  1336. * @param uniformName Name of the variable.
  1337. * @param array array to be set.
  1338. */
  1339. setArray(uniformName: string, array: number[] | Float32Array): void;
  1340. /**
  1341. * 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)
  1342. * @param uniformName Name of the variable.
  1343. * @param array array to be set.
  1344. */
  1345. setArray2(uniformName: string, array: number[] | Float32Array): void;
  1346. /**
  1347. * 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)
  1348. * @param uniformName Name of the variable.
  1349. * @param array array to be set.
  1350. */
  1351. setArray3(uniformName: string, array: number[] | Float32Array): void;
  1352. /**
  1353. * 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)
  1354. * @param uniformName Name of the variable.
  1355. * @param array array to be set.
  1356. */
  1357. setArray4(uniformName: string, array: number[] | Float32Array): void;
  1358. /**
  1359. * Sets matrices on a uniform variable.
  1360. * @param uniformName Name of the variable.
  1361. * @param matrices matrices to be set.
  1362. */
  1363. setMatrices(uniformName: string, matrices: Float32Array): void;
  1364. /**
  1365. * Sets matrix on a uniform variable.
  1366. * @param uniformName Name of the variable.
  1367. * @param matrix matrix to be set.
  1368. */
  1369. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  1370. /**
  1371. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  1372. * @param uniformName Name of the variable.
  1373. * @param matrix matrix to be set.
  1374. */
  1375. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  1376. /**
  1377. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  1378. * @param uniformName Name of the variable.
  1379. * @param matrix matrix to be set.
  1380. */
  1381. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  1382. /**
  1383. * Sets a float on a uniform variable.
  1384. * @param uniformName Name of the variable.
  1385. * @param value value to be set.
  1386. */
  1387. setFloat(uniformName: string, value: number): void;
  1388. /**
  1389. * Sets a Vector2 on a uniform variable.
  1390. * @param uniformName Name of the variable.
  1391. * @param vector2 vector2 to be set.
  1392. */
  1393. setVector2(uniformName: string, vector2: IVector2Like): void;
  1394. /**
  1395. * Sets a float2 on a uniform variable.
  1396. * @param uniformName Name of the variable.
  1397. * @param x First float in float2.
  1398. * @param y Second float in float2.
  1399. */
  1400. setFloat2(uniformName: string, x: number, y: number): void;
  1401. /**
  1402. * Sets a Vector3 on a uniform variable.
  1403. * @param uniformName Name of the variable.
  1404. * @param vector3 Value to be set.
  1405. */
  1406. setVector3(uniformName: string, vector3: IVector3Like): void;
  1407. /**
  1408. * Sets a float3 on a uniform variable.
  1409. * @param uniformName Name of the variable.
  1410. * @param x First float in float3.
  1411. * @param y Second float in float3.
  1412. * @param z Third float in float3.
  1413. */
  1414. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  1415. /**
  1416. * Sets a Vector4 on a uniform variable.
  1417. * @param uniformName Name of the variable.
  1418. * @param vector4 Value to be set.
  1419. */
  1420. setVector4(uniformName: string, vector4: IVector4Like): void;
  1421. /**
  1422. * Sets a float4 on a uniform variable.
  1423. * @param uniformName Name of the variable.
  1424. * @param x First float in float4.
  1425. * @param y Second float in float4.
  1426. * @param z Third float in float4.
  1427. * @param w Fourth float in float4.
  1428. */
  1429. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  1430. /**
  1431. * Sets a Color3 on a uniform variable.
  1432. * @param uniformName Name of the variable.
  1433. * @param color3 Value to be set.
  1434. */
  1435. setColor3(uniformName: string, color3: IColor3Like): void;
  1436. /**
  1437. * Sets a Color4 on a uniform variable.
  1438. * @param uniformName Name of the variable.
  1439. * @param color3 Value to be set.
  1440. * @param alpha Alpha value to be set.
  1441. */
  1442. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  1443. /**
  1444. * Sets a Color4 on a uniform variable
  1445. * @param uniformName defines the name of the variable
  1446. * @param color4 defines the value to be set
  1447. */
  1448. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  1449. }
  1450. }
  1451. declare module BABYLON {
  1452. /**
  1453. * Class used to store gfx data (like WebGLBuffer)
  1454. */
  1455. export class DataBuffer {
  1456. /**
  1457. * Gets or sets the number of objects referencing this buffer
  1458. */
  1459. references: number;
  1460. /** Gets or sets the size of the underlying buffer */
  1461. capacity: number;
  1462. /**
  1463. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1464. */
  1465. is32Bits: boolean;
  1466. /**
  1467. * Gets the underlying buffer
  1468. */
  1469. get underlyingResource(): any;
  1470. }
  1471. }
  1472. declare module BABYLON {
  1473. /** @hidden */
  1474. export interface IShaderProcessor {
  1475. attributeProcessor?: (attribute: string, preProcessors: {
  1476. [key: string]: string;
  1477. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1478. varyingProcessor?: (varying: string, isFragment: boolean, preProcessors: {
  1479. [key: string]: string;
  1480. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1481. uniformProcessor?: (uniform: string, isFragment: boolean, preProcessors: {
  1482. [key: string]: string;
  1483. }, processingContext: Nullable<ShaderProcessingContext>) => string;
  1484. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1485. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1486. lineProcessor?: (line: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1487. preProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>) => string;
  1488. postProcessor?: (code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine) => string;
  1489. initializeShaders?: (processingContext: Nullable<ShaderProcessingContext>) => void;
  1490. finalizeShaders?: (vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>) => {
  1491. vertexCode: string;
  1492. fragmentCode: string;
  1493. };
  1494. }
  1495. }
  1496. declare module BABYLON {
  1497. /** @hidden */
  1498. export interface ShaderProcessingContext {
  1499. }
  1500. /** @hidden */
  1501. export interface ProcessingOptions {
  1502. defines: string[];
  1503. indexParameters: any;
  1504. isFragment: boolean;
  1505. shouldUseHighPrecisionShader: boolean;
  1506. supportsUniformBuffers: boolean;
  1507. shadersRepository: string;
  1508. includesShadersStore: {
  1509. [key: string]: string;
  1510. };
  1511. processor: Nullable<IShaderProcessor>;
  1512. version: string;
  1513. platformName: string;
  1514. lookForClosingBracketForUniformBuffer?: boolean;
  1515. processingContext: Nullable<ShaderProcessingContext>;
  1516. }
  1517. }
  1518. declare module BABYLON {
  1519. /** @hidden */
  1520. export class ShaderCodeNode {
  1521. line: string;
  1522. children: ShaderCodeNode[];
  1523. additionalDefineKey?: string;
  1524. additionalDefineValue?: string;
  1525. isValid(preprocessors: {
  1526. [key: string]: string;
  1527. }): boolean;
  1528. process(preprocessors: {
  1529. [key: string]: string;
  1530. }, options: ProcessingOptions): string;
  1531. }
  1532. }
  1533. declare module BABYLON {
  1534. /** @hidden */
  1535. export class ShaderCodeCursor {
  1536. private _lines;
  1537. lineIndex: number;
  1538. get currentLine(): string;
  1539. get canRead(): boolean;
  1540. set lines(value: string[]);
  1541. }
  1542. }
  1543. declare module BABYLON {
  1544. /** @hidden */
  1545. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1546. process(preprocessors: {
  1547. [key: string]: string;
  1548. }, options: ProcessingOptions): string;
  1549. }
  1550. }
  1551. declare module BABYLON {
  1552. /** @hidden */
  1553. export class ShaderDefineExpression {
  1554. isTrue(preprocessors: {
  1555. [key: string]: string;
  1556. }): boolean;
  1557. private static _OperatorPriority;
  1558. private static _Stack;
  1559. static postfixToInfix(postfix: string[]): string;
  1560. static infixToPostfix(infix: string): string[];
  1561. }
  1562. }
  1563. declare module BABYLON {
  1564. /** @hidden */
  1565. export class ShaderCodeTestNode extends ShaderCodeNode {
  1566. testExpression: ShaderDefineExpression;
  1567. isValid(preprocessors: {
  1568. [key: string]: string;
  1569. }): boolean;
  1570. }
  1571. }
  1572. declare module BABYLON {
  1573. /** @hidden */
  1574. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1575. define: string;
  1576. not: boolean;
  1577. constructor(define: string, not?: boolean);
  1578. isTrue(preprocessors: {
  1579. [key: string]: string;
  1580. }): boolean;
  1581. }
  1582. }
  1583. declare module BABYLON {
  1584. /** @hidden */
  1585. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1586. leftOperand: ShaderDefineExpression;
  1587. rightOperand: ShaderDefineExpression;
  1588. isTrue(preprocessors: {
  1589. [key: string]: string;
  1590. }): boolean;
  1591. }
  1592. }
  1593. declare module BABYLON {
  1594. /** @hidden */
  1595. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1596. leftOperand: ShaderDefineExpression;
  1597. rightOperand: ShaderDefineExpression;
  1598. isTrue(preprocessors: {
  1599. [key: string]: string;
  1600. }): boolean;
  1601. }
  1602. }
  1603. declare module BABYLON {
  1604. /** @hidden */
  1605. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1606. define: string;
  1607. operand: string;
  1608. testValue: string;
  1609. constructor(define: string, operand: string, testValue: string);
  1610. isTrue(preprocessors: {
  1611. [key: string]: string;
  1612. }): boolean;
  1613. }
  1614. }
  1615. declare module BABYLON {
  1616. /**
  1617. * Class used to enable access to offline support
  1618. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1619. */
  1620. export interface IOfflineProvider {
  1621. /**
  1622. * Gets a boolean indicating if scene must be saved in the database
  1623. */
  1624. enableSceneOffline: boolean;
  1625. /**
  1626. * Gets a boolean indicating if textures must be saved in the database
  1627. */
  1628. enableTexturesOffline: boolean;
  1629. /**
  1630. * Open the offline support and make it available
  1631. * @param successCallback defines the callback to call on success
  1632. * @param errorCallback defines the callback to call on error
  1633. */
  1634. open(successCallback: () => void, errorCallback: () => void): void;
  1635. /**
  1636. * Loads an image from the offline support
  1637. * @param url defines the url to load from
  1638. * @param image defines the target DOM image
  1639. */
  1640. loadImage(url: string, image: HTMLImageElement): void;
  1641. /**
  1642. * Loads a file from offline support
  1643. * @param url defines the URL to load from
  1644. * @param sceneLoaded defines a callback to call on success
  1645. * @param progressCallBack defines a callback to call when progress changed
  1646. * @param errorCallback defines a callback to call on error
  1647. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1648. */
  1649. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1650. }
  1651. }
  1652. declare module BABYLON {
  1653. /**
  1654. * Class used to help managing file picking and drag'n'drop
  1655. * File Storage
  1656. */
  1657. export class FilesInputStore {
  1658. /**
  1659. * List of files ready to be loaded
  1660. */
  1661. static FilesToLoad: {
  1662. [key: string]: File;
  1663. };
  1664. }
  1665. }
  1666. declare module BABYLON {
  1667. /**
  1668. * Class used to define a retry strategy when error happens while loading assets
  1669. */
  1670. export class RetryStrategy {
  1671. /**
  1672. * Function used to defines an exponential back off strategy
  1673. * @param maxRetries defines the maximum number of retries (3 by default)
  1674. * @param baseInterval defines the interval between retries
  1675. * @returns the strategy function to use
  1676. */
  1677. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * @ignore
  1683. * Application error to support additional information when loading a file
  1684. */
  1685. export abstract class BaseError extends Error {
  1686. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1687. }
  1688. }
  1689. declare module BABYLON {
  1690. /** @ignore */
  1691. export class LoadFileError extends BaseError {
  1692. request?: WebRequest;
  1693. file?: File;
  1694. /**
  1695. * Creates a new LoadFileError
  1696. * @param message defines the message of the error
  1697. * @param request defines the optional web request
  1698. * @param file defines the optional file
  1699. */
  1700. constructor(message: string, object?: WebRequest | File);
  1701. }
  1702. /** @ignore */
  1703. export class RequestFileError extends BaseError {
  1704. request: WebRequest;
  1705. /**
  1706. * Creates a new LoadFileError
  1707. * @param message defines the message of the error
  1708. * @param request defines the optional web request
  1709. */
  1710. constructor(message: string, request: WebRequest);
  1711. }
  1712. /** @ignore */
  1713. export class ReadFileError extends BaseError {
  1714. file: File;
  1715. /**
  1716. * Creates a new ReadFileError
  1717. * @param message defines the message of the error
  1718. * @param file defines the optional file
  1719. */
  1720. constructor(message: string, file: File);
  1721. }
  1722. /**
  1723. * @hidden
  1724. */
  1725. export class FileTools {
  1726. /**
  1727. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1728. */
  1729. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1730. /**
  1731. * Gets or sets the base URL to use to load assets
  1732. */
  1733. static BaseUrl: string;
  1734. /**
  1735. * Default behaviour for cors in the application.
  1736. * It can be a string if the expected behavior is identical in the entire app.
  1737. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1738. */
  1739. static CorsBehavior: string | ((url: string | string[]) => string);
  1740. /**
  1741. * Gets or sets a function used to pre-process url before using them to load assets
  1742. */
  1743. static PreprocessUrl: (url: string) => string;
  1744. /**
  1745. * Removes unwanted characters from an url
  1746. * @param url defines the url to clean
  1747. * @returns the cleaned url
  1748. */
  1749. private static _CleanUrl;
  1750. /**
  1751. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1752. * @param url define the url we are trying
  1753. * @param element define the dom element where to configure the cors policy
  1754. */
  1755. static SetCorsBehavior(url: string | string[], element: {
  1756. crossOrigin: string | null;
  1757. }): void;
  1758. /**
  1759. * Loads an image as an HTMLImageElement.
  1760. * @param input url string, ArrayBuffer, or Blob to load
  1761. * @param onLoad callback called when the image successfully loads
  1762. * @param onError callback called when the image fails to load
  1763. * @param offlineProvider offline provider for caching
  1764. * @param mimeType optional mime type
  1765. * @returns the HTMLImageElement of the loaded image
  1766. */
  1767. 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>;
  1768. /**
  1769. * Reads a file from a File object
  1770. * @param file defines the file to load
  1771. * @param onSuccess defines the callback to call when data is loaded
  1772. * @param onProgress defines the callback to call during loading process
  1773. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1774. * @param onError defines the callback to call when an error occurs
  1775. * @returns a file request object
  1776. */
  1777. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1778. /**
  1779. * Loads a file from a url
  1780. * @param url url to load
  1781. * @param onSuccess callback called when the file successfully loads
  1782. * @param onProgress callback called while file is loading (if the server supports this mode)
  1783. * @param offlineProvider defines the offline provider for caching
  1784. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1785. * @param onError callback called when the file fails to load
  1786. * @returns a file request object
  1787. */
  1788. 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;
  1789. /**
  1790. * Loads a file
  1791. * @param url url to load
  1792. * @param onSuccess callback called when the file successfully loads
  1793. * @param onProgress callback called while file is loading (if the server supports this mode)
  1794. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1795. * @param onError callback called when the file fails to load
  1796. * @param onOpened callback called when the web request is opened
  1797. * @returns a file request object
  1798. */
  1799. 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;
  1800. /**
  1801. * Checks if the loaded document was accessed via `file:`-Protocol.
  1802. * @returns boolean
  1803. */
  1804. static IsFileURL(): boolean;
  1805. }
  1806. }
  1807. declare module BABYLON {
  1808. /** @hidden */
  1809. export class ShaderProcessor {
  1810. static Initialize(options: ProcessingOptions): void;
  1811. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1812. static Finalize(vertexCode: string, fragmentCode: string, options: ProcessingOptions): {
  1813. vertexCode: string;
  1814. fragmentCode: string;
  1815. };
  1816. private static _ProcessPrecision;
  1817. private static _ExtractOperation;
  1818. private static _BuildSubExpression;
  1819. private static _BuildExpression;
  1820. private static _MoveCursorWithinIf;
  1821. private static _MoveCursor;
  1822. private static _EvaluatePreProcessors;
  1823. private static _PreparePreProcessors;
  1824. private static _ProcessShaderConversion;
  1825. private static _ProcessIncludes;
  1826. /**
  1827. * Loads a file from a url
  1828. * @param url url to load
  1829. * @param onSuccess callback called when the file successfully loads
  1830. * @param onProgress callback called while file is loading (if the server supports this mode)
  1831. * @param offlineProvider defines the offline provider for caching
  1832. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1833. * @param onError callback called when the file fails to load
  1834. * @returns a file request object
  1835. * @hidden
  1836. */
  1837. 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;
  1838. }
  1839. }
  1840. declare module BABYLON {
  1841. /**
  1842. * Interface used to define common properties for effect fallbacks
  1843. */
  1844. export interface IEffectFallbacks {
  1845. /**
  1846. * Removes the defines that should be removed when falling back.
  1847. * @param currentDefines defines the current define statements for the shader.
  1848. * @param effect defines the current effect we try to compile
  1849. * @returns The resulting defines with defines of the current rank removed.
  1850. */
  1851. reduce(currentDefines: string, effect: Effect): string;
  1852. /**
  1853. * Removes the fallback from the bound mesh.
  1854. */
  1855. unBindMesh(): void;
  1856. /**
  1857. * Checks to see if more fallbacks are still availible.
  1858. */
  1859. hasMoreFallbacks: boolean;
  1860. }
  1861. }
  1862. declare module BABYLON {
  1863. /**
  1864. * Interface for the size containing width and height
  1865. */
  1866. export interface ISize {
  1867. /**
  1868. * Width
  1869. */
  1870. width: number;
  1871. /**
  1872. * Heighht
  1873. */
  1874. height: number;
  1875. }
  1876. /**
  1877. * Size containing widht and height
  1878. */
  1879. export class Size implements ISize {
  1880. /**
  1881. * Width
  1882. */
  1883. width: number;
  1884. /**
  1885. * Height
  1886. */
  1887. height: number;
  1888. /**
  1889. * Creates a Size object from the given width and height (floats).
  1890. * @param width width of the new size
  1891. * @param height height of the new size
  1892. */
  1893. constructor(width: number, height: number);
  1894. /**
  1895. * Returns a string with the Size width and height
  1896. * @returns a string with the Size width and height
  1897. */
  1898. toString(): string;
  1899. /**
  1900. * "Size"
  1901. * @returns the string "Size"
  1902. */
  1903. getClassName(): string;
  1904. /**
  1905. * Returns the Size hash code.
  1906. * @returns a hash code for a unique width and height
  1907. */
  1908. getHashCode(): number;
  1909. /**
  1910. * Updates the current size from the given one.
  1911. * @param src the given size
  1912. */
  1913. copyFrom(src: Size): void;
  1914. /**
  1915. * Updates in place the current Size from the given floats.
  1916. * @param width width of the new size
  1917. * @param height height of the new size
  1918. * @returns the updated Size.
  1919. */
  1920. copyFromFloats(width: number, height: number): Size;
  1921. /**
  1922. * Updates in place the current Size from the given floats.
  1923. * @param width width to set
  1924. * @param height height to set
  1925. * @returns the updated Size.
  1926. */
  1927. set(width: number, height: number): Size;
  1928. /**
  1929. * Multiplies the width and height by numbers
  1930. * @param w factor to multiple the width by
  1931. * @param h factor to multiple the height by
  1932. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  1933. */
  1934. multiplyByFloats(w: number, h: number): Size;
  1935. /**
  1936. * Clones the size
  1937. * @returns a new Size copied from the given one.
  1938. */
  1939. clone(): Size;
  1940. /**
  1941. * True if the current Size and the given one width and height are strictly equal.
  1942. * @param other the other size to compare against
  1943. * @returns True if the current Size and the given one width and height are strictly equal.
  1944. */
  1945. equals(other: Size): boolean;
  1946. /**
  1947. * The surface of the Size : width * height (float).
  1948. */
  1949. get surface(): number;
  1950. /**
  1951. * Create a new size of zero
  1952. * @returns a new Size set to (0.0, 0.0)
  1953. */
  1954. static Zero(): Size;
  1955. /**
  1956. * Sums the width and height of two sizes
  1957. * @param otherSize size to add to this size
  1958. * @returns a new Size set as the addition result of the current Size and the given one.
  1959. */
  1960. add(otherSize: Size): Size;
  1961. /**
  1962. * Subtracts the width and height of two
  1963. * @param otherSize size to subtract to this size
  1964. * @returns a new Size set as the subtraction result of the given one from the current Size.
  1965. */
  1966. subtract(otherSize: Size): Size;
  1967. /**
  1968. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  1969. * @param start starting size to lerp between
  1970. * @param end end size to lerp between
  1971. * @param amount amount to lerp between the start and end values
  1972. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  1973. */
  1974. static Lerp(start: Size, end: Size, amount: number): Size;
  1975. }
  1976. }
  1977. declare module BABYLON {
  1978. /**
  1979. * Base class of all the textures in babylon.
  1980. * It groups all the common properties required to work with Thin Engine.
  1981. */
  1982. export class ThinTexture {
  1983. protected _wrapU: number;
  1984. /**
  1985. * | Value | Type | Description |
  1986. * | ----- | ------------------ | ----------- |
  1987. * | 0 | CLAMP_ADDRESSMODE | |
  1988. * | 1 | WRAP_ADDRESSMODE | |
  1989. * | 2 | MIRROR_ADDRESSMODE | |
  1990. */
  1991. get wrapU(): number;
  1992. set wrapU(value: number);
  1993. protected _wrapV: number;
  1994. /**
  1995. * | Value | Type | Description |
  1996. * | ----- | ------------------ | ----------- |
  1997. * | 0 | CLAMP_ADDRESSMODE | |
  1998. * | 1 | WRAP_ADDRESSMODE | |
  1999. * | 2 | MIRROR_ADDRESSMODE | |
  2000. */
  2001. get wrapV(): number;
  2002. set wrapV(value: number);
  2003. /**
  2004. * | Value | Type | Description |
  2005. * | ----- | ------------------ | ----------- |
  2006. * | 0 | CLAMP_ADDRESSMODE | |
  2007. * | 1 | WRAP_ADDRESSMODE | |
  2008. * | 2 | MIRROR_ADDRESSMODE | |
  2009. */
  2010. wrapR: number;
  2011. /**
  2012. * With compliant hardware and browser (supporting anisotropic filtering)
  2013. * this defines the level of anisotropic filtering in the texture.
  2014. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  2015. */
  2016. anisotropicFilteringLevel: number;
  2017. /**
  2018. * Define the current state of the loading sequence when in delayed load mode.
  2019. */
  2020. delayLoadState: number;
  2021. /**
  2022. * How a texture is mapped.
  2023. * Unused in thin texture mode.
  2024. */
  2025. get coordinatesMode(): number;
  2026. /**
  2027. * Define if the texture is a cube texture or if false a 2d texture.
  2028. */
  2029. get isCube(): boolean;
  2030. set isCube(value: boolean);
  2031. /**
  2032. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  2033. */
  2034. get is3D(): boolean;
  2035. set is3D(value: boolean);
  2036. /**
  2037. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  2038. */
  2039. get is2DArray(): boolean;
  2040. set is2DArray(value: boolean);
  2041. /**
  2042. * Get the class name of the texture.
  2043. * @returns "ThinTexture"
  2044. */
  2045. getClassName(): string;
  2046. /** @hidden */
  2047. _texture: Nullable<InternalTexture>;
  2048. protected _engine: Nullable<ThinEngine>;
  2049. private _cachedSize;
  2050. private _cachedBaseSize;
  2051. /**
  2052. * Instantiates a new ThinTexture.
  2053. * Base class of all the textures in babylon.
  2054. * This can be used as an internal texture wrapper in ThinEngine to benefit from the cache
  2055. * @param internalTexture Define the internalTexture to wrap
  2056. */
  2057. constructor(internalTexture: Nullable<InternalTexture>);
  2058. /**
  2059. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  2060. * @returns true if fully ready
  2061. */
  2062. isReady(): boolean;
  2063. /**
  2064. * Triggers the load sequence in delayed load mode.
  2065. */
  2066. delayLoad(): void;
  2067. /**
  2068. * Get the underlying lower level texture from Babylon.
  2069. * @returns the insternal texture
  2070. */
  2071. getInternalTexture(): Nullable<InternalTexture>;
  2072. /**
  2073. * Get the size of the texture.
  2074. * @returns the texture size.
  2075. */
  2076. getSize(): ISize;
  2077. /**
  2078. * Get the base size of the texture.
  2079. * It can be different from the size if the texture has been resized for POT for instance
  2080. * @returns the base size
  2081. */
  2082. getBaseSize(): ISize;
  2083. /**
  2084. * Update the sampling mode of the texture.
  2085. * Default is Trilinear mode.
  2086. *
  2087. * | Value | Type | Description |
  2088. * | ----- | ------------------ | ----------- |
  2089. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  2090. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  2091. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  2092. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  2093. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  2094. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  2095. * | 7 | NEAREST_LINEAR | |
  2096. * | 8 | NEAREST_NEAREST | |
  2097. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  2098. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  2099. * | 11 | LINEAR_LINEAR | |
  2100. * | 12 | LINEAR_NEAREST | |
  2101. *
  2102. * > _mag_: magnification filter (close to the viewer)
  2103. * > _min_: minification filter (far from the viewer)
  2104. * > _mip_: filter used between mip map levels
  2105. *@param samplingMode Define the new sampling mode of the texture
  2106. */
  2107. updateSamplingMode(samplingMode: number): void;
  2108. /**
  2109. * Release and destroy the underlying lower level texture aka internalTexture.
  2110. */
  2111. releaseInternalTexture(): void;
  2112. /**
  2113. * Dispose the texture and release its associated resources.
  2114. */
  2115. dispose(): void;
  2116. }
  2117. }
  2118. declare module BABYLON {
  2119. /**
  2120. * Defines an array and its length.
  2121. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  2122. */
  2123. export interface ISmartArrayLike<T> {
  2124. /**
  2125. * The data of the array.
  2126. */
  2127. data: Array<T>;
  2128. /**
  2129. * The active length of the array.
  2130. */
  2131. length: number;
  2132. }
  2133. /**
  2134. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2135. */
  2136. export class SmartArray<T> implements ISmartArrayLike<T> {
  2137. /**
  2138. * The full set of data from the array.
  2139. */
  2140. data: Array<T>;
  2141. /**
  2142. * The active length of the array.
  2143. */
  2144. length: number;
  2145. protected _id: number;
  2146. /**
  2147. * Instantiates a Smart Array.
  2148. * @param capacity defines the default capacity of the array.
  2149. */
  2150. constructor(capacity: number);
  2151. /**
  2152. * Pushes a value at the end of the active data.
  2153. * @param value defines the object to push in the array.
  2154. */
  2155. push(value: T): void;
  2156. /**
  2157. * Iterates over the active data and apply the lambda to them.
  2158. * @param func defines the action to apply on each value.
  2159. */
  2160. forEach(func: (content: T) => void): void;
  2161. /**
  2162. * Sorts the full sets of data.
  2163. * @param compareFn defines the comparison function to apply.
  2164. */
  2165. sort(compareFn: (a: T, b: T) => number): void;
  2166. /**
  2167. * Resets the active data to an empty array.
  2168. */
  2169. reset(): void;
  2170. /**
  2171. * Releases all the data from the array as well as the array.
  2172. */
  2173. dispose(): void;
  2174. /**
  2175. * Concats the active data with a given array.
  2176. * @param array defines the data to concatenate with.
  2177. */
  2178. concat(array: any): void;
  2179. /**
  2180. * Returns the position of a value in the active data.
  2181. * @param value defines the value to find the index for
  2182. * @returns the index if found in the active data otherwise -1
  2183. */
  2184. indexOf(value: T): number;
  2185. /**
  2186. * Returns whether an element is part of the active data.
  2187. * @param value defines the value to look for
  2188. * @returns true if found in the active data otherwise false
  2189. */
  2190. contains(value: T): boolean;
  2191. private static _GlobalId;
  2192. }
  2193. /**
  2194. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  2195. * The data in this array can only be present once
  2196. */
  2197. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  2198. private _duplicateId;
  2199. /**
  2200. * Pushes a value at the end of the active data.
  2201. * THIS DOES NOT PREVENT DUPPLICATE DATA
  2202. * @param value defines the object to push in the array.
  2203. */
  2204. push(value: T): void;
  2205. /**
  2206. * Pushes a value at the end of the active data.
  2207. * If the data is already present, it won t be added again
  2208. * @param value defines the object to push in the array.
  2209. * @returns true if added false if it was already present
  2210. */
  2211. pushNoDuplicate(value: T): boolean;
  2212. /**
  2213. * Resets the active data to an empty array.
  2214. */
  2215. reset(): void;
  2216. /**
  2217. * Concats the active data with a given array.
  2218. * This ensures no dupplicate will be present in the result.
  2219. * @param array defines the data to concatenate with.
  2220. */
  2221. concatWithNoDuplicate(array: any): void;
  2222. }
  2223. }
  2224. declare module BABYLON {
  2225. /**
  2226. * Class used to evalaute queries containing `and` and `or` operators
  2227. */
  2228. export class AndOrNotEvaluator {
  2229. /**
  2230. * Evaluate a query
  2231. * @param query defines the query to evaluate
  2232. * @param evaluateCallback defines the callback used to filter result
  2233. * @returns true if the query matches
  2234. */
  2235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  2236. private static _HandleParenthesisContent;
  2237. private static _SimplifyNegation;
  2238. }
  2239. }
  2240. declare module BABYLON {
  2241. /**
  2242. * Class used to store custom tags
  2243. */
  2244. export class Tags {
  2245. /**
  2246. * Adds support for tags on the given object
  2247. * @param obj defines the object to use
  2248. */
  2249. static EnableFor(obj: any): void;
  2250. /**
  2251. * Removes tags support
  2252. * @param obj defines the object to use
  2253. */
  2254. static DisableFor(obj: any): void;
  2255. /**
  2256. * Gets a boolean indicating if the given object has tags
  2257. * @param obj defines the object to use
  2258. * @returns a boolean
  2259. */
  2260. static HasTags(obj: any): boolean;
  2261. /**
  2262. * Gets the tags available on a given object
  2263. * @param obj defines the object to use
  2264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  2265. * @returns the tags
  2266. */
  2267. static GetTags(obj: any, asString?: boolean): any;
  2268. /**
  2269. * Adds tags to an object
  2270. * @param obj defines the object to use
  2271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  2272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  2273. */
  2274. static AddTagsTo(obj: any, tagsString: string): void;
  2275. /**
  2276. * @hidden
  2277. */
  2278. static _AddTagTo(obj: any, tag: string): void;
  2279. /**
  2280. * Removes specific tags from a specific object
  2281. * @param obj defines the object to use
  2282. * @param tagsString defines the tags to remove
  2283. */
  2284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  2285. /**
  2286. * @hidden
  2287. */
  2288. static _RemoveTagFrom(obj: any, tag: string): void;
  2289. /**
  2290. * Defines if tags hosted on an object match a given query
  2291. * @param obj defines the object to use
  2292. * @param tagsQuery defines the tag query
  2293. * @returns a boolean
  2294. */
  2295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  2296. }
  2297. }
  2298. declare module BABYLON {
  2299. /**
  2300. * Scalar computation library
  2301. */
  2302. export class Scalar {
  2303. /**
  2304. * Two pi constants convenient for computation.
  2305. */
  2306. static TwoPi: number;
  2307. /**
  2308. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2309. * @param a number
  2310. * @param b number
  2311. * @param epsilon (default = 1.401298E-45)
  2312. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  2313. */
  2314. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  2315. /**
  2316. * Returns a string : the upper case translation of the number i to hexadecimal.
  2317. * @param i number
  2318. * @returns the upper case translation of the number i to hexadecimal.
  2319. */
  2320. static ToHex(i: number): string;
  2321. /**
  2322. * Returns -1 if value is negative and +1 is value is positive.
  2323. * @param value the value
  2324. * @returns the value itself if it's equal to zero.
  2325. */
  2326. static Sign(value: number): number;
  2327. /**
  2328. * Returns the value itself if it's between min and max.
  2329. * Returns min if the value is lower than min.
  2330. * Returns max if the value is greater than max.
  2331. * @param value the value to clmap
  2332. * @param min the min value to clamp to (default: 0)
  2333. * @param max the max value to clamp to (default: 1)
  2334. * @returns the clamped value
  2335. */
  2336. static Clamp(value: number, min?: number, max?: number): number;
  2337. /**
  2338. * the log2 of value.
  2339. * @param value the value to compute log2 of
  2340. * @returns the log2 of value.
  2341. */
  2342. static Log2(value: number): number;
  2343. /**
  2344. * the floor part of a log2 value.
  2345. * @param value the value to compute log2 of
  2346. * @returns the log2 of value.
  2347. */
  2348. static ILog2(value: number): number;
  2349. /**
  2350. * Loops the value, so that it is never larger than length and never smaller than 0.
  2351. *
  2352. * This is similar to the modulo operator but it works with floating point numbers.
  2353. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  2354. * With t = 5 and length = 2.5, the result would be 0.0.
  2355. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  2356. * @param value the value
  2357. * @param length the length
  2358. * @returns the looped value
  2359. */
  2360. static Repeat(value: number, length: number): number;
  2361. /**
  2362. * Normalize the value between 0.0 and 1.0 using min and max values
  2363. * @param value value to normalize
  2364. * @param min max to normalize between
  2365. * @param max min to normalize between
  2366. * @returns the normalized value
  2367. */
  2368. static Normalize(value: number, min: number, max: number): number;
  2369. /**
  2370. * Denormalize the value from 0.0 and 1.0 using min and max values
  2371. * @param normalized value to denormalize
  2372. * @param min max to denormalize between
  2373. * @param max min to denormalize between
  2374. * @returns the denormalized value
  2375. */
  2376. static Denormalize(normalized: number, min: number, max: number): number;
  2377. /**
  2378. * Calculates the shortest difference between two given angles given in degrees.
  2379. * @param current current angle in degrees
  2380. * @param target target angle in degrees
  2381. * @returns the delta
  2382. */
  2383. static DeltaAngle(current: number, target: number): number;
  2384. /**
  2385. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  2386. * @param tx value
  2387. * @param length length
  2388. * @returns The returned value will move back and forth between 0 and length
  2389. */
  2390. static PingPong(tx: number, length: number): number;
  2391. /**
  2392. * Interpolates between min and max with smoothing at the limits.
  2393. *
  2394. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  2395. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  2396. * @param from from
  2397. * @param to to
  2398. * @param tx value
  2399. * @returns the smooth stepped value
  2400. */
  2401. static SmoothStep(from: number, to: number, tx: number): number;
  2402. /**
  2403. * Moves a value current towards target.
  2404. *
  2405. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  2406. * Negative values of maxDelta pushes the value away from target.
  2407. * @param current current value
  2408. * @param target target value
  2409. * @param maxDelta max distance to move
  2410. * @returns resulting value
  2411. */
  2412. static MoveTowards(current: number, target: number, maxDelta: number): number;
  2413. /**
  2414. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2415. *
  2416. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  2417. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  2418. * @param current current value
  2419. * @param target target value
  2420. * @param maxDelta max distance to move
  2421. * @returns resulting angle
  2422. */
  2423. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  2424. /**
  2425. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  2426. * @param start start value
  2427. * @param end target value
  2428. * @param amount amount to lerp between
  2429. * @returns the lerped value
  2430. */
  2431. static Lerp(start: number, end: number, amount: number): number;
  2432. /**
  2433. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  2434. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  2435. * @param start start value
  2436. * @param end target value
  2437. * @param amount amount to lerp between
  2438. * @returns the lerped value
  2439. */
  2440. static LerpAngle(start: number, end: number, amount: number): number;
  2441. /**
  2442. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  2443. * @param a start value
  2444. * @param b target value
  2445. * @param value value between a and b
  2446. * @returns the inverseLerp value
  2447. */
  2448. static InverseLerp(a: number, b: number, value: number): number;
  2449. /**
  2450. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  2451. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  2452. * @param value1 spline value
  2453. * @param tangent1 spline value
  2454. * @param value2 spline value
  2455. * @param tangent2 spline value
  2456. * @param amount input value
  2457. * @returns hermite result
  2458. */
  2459. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  2460. /**
  2461. * Returns a random float number between and min and max values
  2462. * @param min min value of random
  2463. * @param max max value of random
  2464. * @returns random value
  2465. */
  2466. static RandomRange(min: number, max: number): number;
  2467. /**
  2468. * This function returns percentage of a number in a given range.
  2469. *
  2470. * RangeToPercent(40,20,60) will return 0.5 (50%)
  2471. * RangeToPercent(34,0,100) will return 0.34 (34%)
  2472. * @param number to convert to percentage
  2473. * @param min min range
  2474. * @param max max range
  2475. * @returns the percentage
  2476. */
  2477. static RangeToPercent(number: number, min: number, max: number): number;
  2478. /**
  2479. * This function returns number that corresponds to the percentage in a given range.
  2480. *
  2481. * PercentToRange(0.34,0,100) will return 34.
  2482. * @param percent to convert to number
  2483. * @param min min range
  2484. * @param max max range
  2485. * @returns the number
  2486. */
  2487. static PercentToRange(percent: number, min: number, max: number): number;
  2488. /**
  2489. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  2490. * @param angle The angle to normalize in radian.
  2491. * @return The converted angle.
  2492. */
  2493. static NormalizeRadians(angle: number): number;
  2494. }
  2495. }
  2496. declare module BABYLON {
  2497. /**
  2498. * Constant used to convert a value to gamma space
  2499. * @ignorenaming
  2500. */
  2501. export const ToGammaSpace: number;
  2502. /**
  2503. * Constant used to convert a value to linear space
  2504. * @ignorenaming
  2505. */
  2506. export const ToLinearSpace = 2.2;
  2507. /**
  2508. * Constant used to define the minimal number value in Babylon.js
  2509. * @ignorenaming
  2510. */
  2511. let Epsilon: number;
  2512. }
  2513. declare module BABYLON {
  2514. /**
  2515. * Class used to represent a viewport on screen
  2516. */
  2517. export class Viewport {
  2518. /** viewport left coordinate */
  2519. x: number;
  2520. /** viewport top coordinate */
  2521. y: number;
  2522. /**viewport width */
  2523. width: number;
  2524. /** viewport height */
  2525. height: number;
  2526. /**
  2527. * Creates a Viewport object located at (x, y) and sized (width, height)
  2528. * @param x defines viewport left coordinate
  2529. * @param y defines viewport top coordinate
  2530. * @param width defines the viewport width
  2531. * @param height defines the viewport height
  2532. */
  2533. constructor(
  2534. /** viewport left coordinate */
  2535. x: number,
  2536. /** viewport top coordinate */
  2537. y: number,
  2538. /**viewport width */
  2539. width: number,
  2540. /** viewport height */
  2541. height: number);
  2542. /**
  2543. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  2544. * @param renderWidth defines the rendering width
  2545. * @param renderHeight defines the rendering height
  2546. * @returns a new Viewport
  2547. */
  2548. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  2549. /**
  2550. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  2551. * @param renderWidth defines the rendering width
  2552. * @param renderHeight defines the rendering height
  2553. * @param ref defines the target viewport
  2554. * @returns the current viewport
  2555. */
  2556. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  2557. /**
  2558. * Returns a new Viewport copied from the current one
  2559. * @returns a new Viewport
  2560. */
  2561. clone(): Viewport;
  2562. }
  2563. }
  2564. declare module BABYLON {
  2565. /**
  2566. * Class containing a set of static utilities functions for arrays.
  2567. */
  2568. export class ArrayTools {
  2569. /**
  2570. * Returns an array of the given size filled with element built from the given constructor and the paramters
  2571. * @param size the number of element to construct and put in the array
  2572. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  2573. * @returns a new array filled with new objects
  2574. */
  2575. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  2576. }
  2577. }
  2578. declare module BABYLON {
  2579. /**
  2580. * Represents a plane by the equation ax + by + cz + d = 0
  2581. */
  2582. export class Plane {
  2583. private static _TmpMatrix;
  2584. /**
  2585. * Normal of the plane (a,b,c)
  2586. */
  2587. normal: Vector3;
  2588. /**
  2589. * d component of the plane
  2590. */
  2591. d: number;
  2592. /**
  2593. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2594. * @param a a component of the plane
  2595. * @param b b component of the plane
  2596. * @param c c component of the plane
  2597. * @param d d component of the plane
  2598. */
  2599. constructor(a: number, b: number, c: number, d: number);
  2600. /**
  2601. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2602. */
  2603. asArray(): number[];
  2604. /**
  2605. * @returns a new plane copied from the current Plane.
  2606. */
  2607. clone(): Plane;
  2608. /**
  2609. * @returns the string "Plane".
  2610. */
  2611. getClassName(): string;
  2612. /**
  2613. * @returns the Plane hash code.
  2614. */
  2615. getHashCode(): number;
  2616. /**
  2617. * Normalize the current Plane in place.
  2618. * @returns the updated Plane.
  2619. */
  2620. normalize(): Plane;
  2621. /**
  2622. * Applies a transformation the plane and returns the result
  2623. * @param transformation the transformation matrix to be applied to the plane
  2624. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2625. */
  2626. transform(transformation: DeepImmutable<Matrix>): Plane;
  2627. /**
  2628. * Compute the dot product between the point and the plane normal
  2629. * @param point point to calculate the dot product with
  2630. * @returns the dot product (float) of the point coordinates and the plane normal.
  2631. */
  2632. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2633. /**
  2634. * Updates the current Plane from the plane defined by the three given points.
  2635. * @param point1 one of the points used to contruct the plane
  2636. * @param point2 one of the points used to contruct the plane
  2637. * @param point3 one of the points used to contruct the plane
  2638. * @returns the updated Plane.
  2639. */
  2640. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2641. /**
  2642. * 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).
  2643. * Note that for this function to work as expected you should make sure that:
  2644. * - direction and the plane normal are normalized
  2645. * - epsilon is a number just bigger than -1, something like -0.99 for eg
  2646. * @param direction the direction to check if the plane is facing
  2647. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2648. * @returns True if the plane is facing the given direction
  2649. */
  2650. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2651. /**
  2652. * Calculates the distance to a point
  2653. * @param point point to calculate distance to
  2654. * @returns the signed distance (float) from the given point to the Plane.
  2655. */
  2656. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2657. /**
  2658. * Creates a plane from an array
  2659. * @param array the array to create a plane from
  2660. * @returns a new Plane from the given array.
  2661. */
  2662. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2663. /**
  2664. * Creates a plane from three points
  2665. * @param point1 point used to create the plane
  2666. * @param point2 point used to create the plane
  2667. * @param point3 point used to create the plane
  2668. * @returns a new Plane defined by the three given points.
  2669. */
  2670. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2671. /**
  2672. * Creates a plane from an origin point and a normal
  2673. * @param origin origin of the plane to be constructed
  2674. * @param normal normal of the plane to be constructed
  2675. * @returns a new Plane the normal vector to this plane at the given origin point.
  2676. * Note : the vector "normal" is updated because normalized.
  2677. */
  2678. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2679. /**
  2680. * Calculates the distance from a plane and a point
  2681. * @param origin origin of the plane to be constructed
  2682. * @param normal normal of the plane to be constructed
  2683. * @param point point to calculate distance to
  2684. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2685. */
  2686. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2687. }
  2688. }
  2689. declare module BABYLON {
  2690. /** @hidden */
  2691. export class PerformanceConfigurator {
  2692. /** @hidden */
  2693. static MatrixUse64Bits: boolean;
  2694. /** @hidden */
  2695. static MatrixTrackPrecisionChange: boolean;
  2696. /** @hidden */
  2697. static MatrixCurrentType: any;
  2698. /** @hidden */
  2699. static MatrixTrackedMatrices: Array<any> | null;
  2700. /** @hidden */
  2701. static SetMatrixPrecision(use64bits: boolean): void;
  2702. }
  2703. }
  2704. declare module BABYLON {
  2705. /**
  2706. * Class representing a vector containing 2 coordinates
  2707. */
  2708. export class Vector2 {
  2709. /** defines the first coordinate */
  2710. x: number;
  2711. /** defines the second coordinate */
  2712. y: number;
  2713. /**
  2714. * Creates a new Vector2 from the given x and y coordinates
  2715. * @param x defines the first coordinate
  2716. * @param y defines the second coordinate
  2717. */
  2718. constructor(
  2719. /** defines the first coordinate */
  2720. x?: number,
  2721. /** defines the second coordinate */
  2722. y?: number);
  2723. /**
  2724. * Gets a string with the Vector2 coordinates
  2725. * @returns a string with the Vector2 coordinates
  2726. */
  2727. toString(): string;
  2728. /**
  2729. * Gets class name
  2730. * @returns the string "Vector2"
  2731. */
  2732. getClassName(): string;
  2733. /**
  2734. * Gets current vector hash code
  2735. * @returns the Vector2 hash code as a number
  2736. */
  2737. getHashCode(): number;
  2738. /**
  2739. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2740. * @param array defines the source array
  2741. * @param index defines the offset in source array
  2742. * @returns the current Vector2
  2743. */
  2744. toArray(array: FloatArray, index?: number): Vector2;
  2745. /**
  2746. * Update the current vector from an array
  2747. * @param array defines the destination array
  2748. * @param index defines the offset in the destination array
  2749. * @returns the current Vector3
  2750. */
  2751. fromArray(array: FloatArray, index?: number): Vector2;
  2752. /**
  2753. * Copy the current vector to an array
  2754. * @returns a new array with 2 elements: the Vector2 coordinates.
  2755. */
  2756. asArray(): number[];
  2757. /**
  2758. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2759. * @param source defines the source Vector2
  2760. * @returns the current updated Vector2
  2761. */
  2762. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2763. /**
  2764. * Sets the Vector2 coordinates with the given floats
  2765. * @param x defines the first coordinate
  2766. * @param y defines the second coordinate
  2767. * @returns the current updated Vector2
  2768. */
  2769. copyFromFloats(x: number, y: number): Vector2;
  2770. /**
  2771. * Sets the Vector2 coordinates with the given floats
  2772. * @param x defines the first coordinate
  2773. * @param y defines the second coordinate
  2774. * @returns the current updated Vector2
  2775. */
  2776. set(x: number, y: number): Vector2;
  2777. /**
  2778. * Add another vector with the current one
  2779. * @param otherVector defines the other vector
  2780. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2781. */
  2782. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2783. /**
  2784. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2785. * @param otherVector defines the other vector
  2786. * @param result defines the target vector
  2787. * @returns the unmodified current Vector2
  2788. */
  2789. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2790. /**
  2791. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2792. * @param otherVector defines the other vector
  2793. * @returns the current updated Vector2
  2794. */
  2795. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2796. /**
  2797. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2798. * @param otherVector defines the other vector
  2799. * @returns a new Vector2
  2800. */
  2801. addVector3(otherVector: Vector3): Vector2;
  2802. /**
  2803. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2804. * @param otherVector defines the other vector
  2805. * @returns a new Vector2
  2806. */
  2807. subtract(otherVector: Vector2): Vector2;
  2808. /**
  2809. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2810. * @param otherVector defines the other vector
  2811. * @param result defines the target vector
  2812. * @returns the unmodified current Vector2
  2813. */
  2814. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2815. /**
  2816. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2817. * @param otherVector defines the other vector
  2818. * @returns the current updated Vector2
  2819. */
  2820. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2821. /**
  2822. * Multiplies in place the current Vector2 coordinates by the given ones
  2823. * @param otherVector defines the other vector
  2824. * @returns the current updated Vector2
  2825. */
  2826. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2827. /**
  2828. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2829. * @param otherVector defines the other vector
  2830. * @returns a new Vector2
  2831. */
  2832. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2833. /**
  2834. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2835. * @param otherVector defines the other vector
  2836. * @param result defines the target vector
  2837. * @returns the unmodified current Vector2
  2838. */
  2839. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2840. /**
  2841. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2842. * @param x defines the first coordinate
  2843. * @param y defines the second coordinate
  2844. * @returns a new Vector2
  2845. */
  2846. multiplyByFloats(x: number, y: number): Vector2;
  2847. /**
  2848. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2849. * @param otherVector defines the other vector
  2850. * @returns a new Vector2
  2851. */
  2852. divide(otherVector: Vector2): Vector2;
  2853. /**
  2854. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2855. * @param otherVector defines the other vector
  2856. * @param result defines the target vector
  2857. * @returns the unmodified current Vector2
  2858. */
  2859. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2860. /**
  2861. * Divides the current Vector2 coordinates by the given ones
  2862. * @param otherVector defines the other vector
  2863. * @returns the current updated Vector2
  2864. */
  2865. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2866. /**
  2867. * Gets a new Vector2 with current Vector2 negated coordinates
  2868. * @returns a new Vector2
  2869. */
  2870. negate(): Vector2;
  2871. /**
  2872. * Negate this vector in place
  2873. * @returns this
  2874. */
  2875. negateInPlace(): Vector2;
  2876. /**
  2877. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2878. * @param result defines the Vector3 object where to store the result
  2879. * @returns the current Vector2
  2880. */
  2881. negateToRef(result: Vector2): Vector2;
  2882. /**
  2883. * Multiply the Vector2 coordinates by scale
  2884. * @param scale defines the scaling factor
  2885. * @returns the current updated Vector2
  2886. */
  2887. scaleInPlace(scale: number): Vector2;
  2888. /**
  2889. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2890. * @param scale defines the scaling factor
  2891. * @returns a new Vector2
  2892. */
  2893. scale(scale: number): Vector2;
  2894. /**
  2895. * Scale the current Vector2 values by a factor to a given Vector2
  2896. * @param scale defines the scale factor
  2897. * @param result defines the Vector2 object where to store the result
  2898. * @returns the unmodified current Vector2
  2899. */
  2900. scaleToRef(scale: number, result: Vector2): Vector2;
  2901. /**
  2902. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2903. * @param scale defines the scale factor
  2904. * @param result defines the Vector2 object where to store the result
  2905. * @returns the unmodified current Vector2
  2906. */
  2907. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2908. /**
  2909. * Gets a boolean if two vectors are equals
  2910. * @param otherVector defines the other vector
  2911. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2912. */
  2913. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2914. /**
  2915. * Gets a boolean if two vectors are equals (using an epsilon value)
  2916. * @param otherVector defines the other vector
  2917. * @param epsilon defines the minimal distance to consider equality
  2918. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2919. */
  2920. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2921. /**
  2922. * Gets a new Vector2 from current Vector2 floored values
  2923. * @returns a new Vector2
  2924. */
  2925. floor(): Vector2;
  2926. /**
  2927. * Gets a new Vector2 from current Vector2 floored values
  2928. * @returns a new Vector2
  2929. */
  2930. fract(): Vector2;
  2931. /**
  2932. * Gets the length of the vector
  2933. * @returns the vector length (float)
  2934. */
  2935. length(): number;
  2936. /**
  2937. * Gets the vector squared length
  2938. * @returns the vector squared length (float)
  2939. */
  2940. lengthSquared(): number;
  2941. /**
  2942. * Normalize the vector
  2943. * @returns the current updated Vector2
  2944. */
  2945. normalize(): Vector2;
  2946. /**
  2947. * Gets a new Vector2 copied from the Vector2
  2948. * @returns a new Vector2
  2949. */
  2950. clone(): Vector2;
  2951. /**
  2952. * Gets a new Vector2(0, 0)
  2953. * @returns a new Vector2
  2954. */
  2955. static Zero(): Vector2;
  2956. /**
  2957. * Gets a new Vector2(1, 1)
  2958. * @returns a new Vector2
  2959. */
  2960. static One(): Vector2;
  2961. /**
  2962. * Gets a new Vector2 set from the given index element of the given array
  2963. * @param array defines the data source
  2964. * @param offset defines the offset in the data source
  2965. * @returns a new Vector2
  2966. */
  2967. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2968. /**
  2969. * Sets "result" from the given index element of the given array
  2970. * @param array defines the data source
  2971. * @param offset defines the offset in the data source
  2972. * @param result defines the target vector
  2973. */
  2974. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2975. /**
  2976. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2977. * @param value1 defines 1st point of control
  2978. * @param value2 defines 2nd point of control
  2979. * @param value3 defines 3rd point of control
  2980. * @param value4 defines 4th point of control
  2981. * @param amount defines the interpolation factor
  2982. * @returns a new Vector2
  2983. */
  2984. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2985. /**
  2986. * 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".
  2987. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2988. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2989. * @param value defines the value to clamp
  2990. * @param min defines the lower limit
  2991. * @param max defines the upper limit
  2992. * @returns a new Vector2
  2993. */
  2994. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2995. /**
  2996. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2997. * @param value1 defines the 1st control point
  2998. * @param tangent1 defines the outgoing tangent
  2999. * @param value2 defines the 2nd control point
  3000. * @param tangent2 defines the incoming tangent
  3001. * @param amount defines the interpolation factor
  3002. * @returns a new Vector2
  3003. */
  3004. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  3005. /**
  3006. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  3007. * @param start defines the start vector
  3008. * @param end defines the end vector
  3009. * @param amount defines the interpolation factor
  3010. * @returns a new Vector2
  3011. */
  3012. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  3013. /**
  3014. * Gets the dot product of the vector "left" and the vector "right"
  3015. * @param left defines first vector
  3016. * @param right defines second vector
  3017. * @returns the dot product (float)
  3018. */
  3019. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  3020. /**
  3021. * Returns a new Vector2 equal to the normalized given vector
  3022. * @param vector defines the vector to normalize
  3023. * @returns a new Vector2
  3024. */
  3025. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  3026. /**
  3027. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  3028. * @param left defines 1st vector
  3029. * @param right defines 2nd vector
  3030. * @returns a new Vector2
  3031. */
  3032. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3033. /**
  3034. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  3035. * @param left defines 1st vector
  3036. * @param right defines 2nd vector
  3037. * @returns a new Vector2
  3038. */
  3039. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  3040. /**
  3041. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  3042. * @param vector defines the vector to transform
  3043. * @param transformation defines the matrix to apply
  3044. * @returns a new Vector2
  3045. */
  3046. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  3047. /**
  3048. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  3049. * @param vector defines the vector to transform
  3050. * @param transformation defines the matrix to apply
  3051. * @param result defines the target vector
  3052. */
  3053. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  3054. /**
  3055. * Determines if a given vector is included in a triangle
  3056. * @param p defines the vector to test
  3057. * @param p0 defines 1st triangle point
  3058. * @param p1 defines 2nd triangle point
  3059. * @param p2 defines 3rd triangle point
  3060. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  3061. */
  3062. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  3063. /**
  3064. * Gets the distance between the vectors "value1" and "value2"
  3065. * @param value1 defines first vector
  3066. * @param value2 defines second vector
  3067. * @returns the distance between vectors
  3068. */
  3069. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3070. /**
  3071. * Returns the squared distance between the vectors "value1" and "value2"
  3072. * @param value1 defines first vector
  3073. * @param value2 defines second vector
  3074. * @returns the squared distance between vectors
  3075. */
  3076. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  3077. /**
  3078. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  3079. * @param value1 defines first vector
  3080. * @param value2 defines second vector
  3081. * @returns a new Vector2
  3082. */
  3083. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  3084. /**
  3085. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3086. * @param value1 defines first vector
  3087. * @param value2 defines second vector
  3088. * @param ref defines third vector
  3089. * @returns ref
  3090. */
  3091. static CenterToRef(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, ref: DeepImmutable<Vector2>): Vector2;
  3092. /**
  3093. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  3094. * @param p defines the middle point
  3095. * @param segA defines one point of the segment
  3096. * @param segB defines the other point of the segment
  3097. * @returns the shortest distance
  3098. */
  3099. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  3100. }
  3101. /**
  3102. * Class used to store (x,y,z) vector representation
  3103. * A Vector3 is the main object used in 3D geometry
  3104. * It can represent etiher the coordinates of a point the space, either a direction
  3105. * Reminder: js uses a left handed forward facing system
  3106. */
  3107. export class Vector3 {
  3108. private static _UpReadOnly;
  3109. private static _ZeroReadOnly;
  3110. /** @hidden */
  3111. _x: number;
  3112. /** @hidden */
  3113. _y: number;
  3114. /** @hidden */
  3115. _z: number;
  3116. /** @hidden */
  3117. _isDirty: boolean;
  3118. /** Gets or sets the x coordinate */
  3119. get x(): number;
  3120. set x(value: number);
  3121. /** Gets or sets the y coordinate */
  3122. get y(): number;
  3123. set y(value: number);
  3124. /** Gets or sets the z coordinate */
  3125. get z(): number;
  3126. set z(value: number);
  3127. /**
  3128. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  3129. * @param x defines the first coordinates (on X axis)
  3130. * @param y defines the second coordinates (on Y axis)
  3131. * @param z defines the third coordinates (on Z axis)
  3132. */
  3133. constructor(x?: number, y?: number, z?: number);
  3134. /**
  3135. * Creates a string representation of the Vector3
  3136. * @returns a string with the Vector3 coordinates.
  3137. */
  3138. toString(): string;
  3139. /**
  3140. * Gets the class name
  3141. * @returns the string "Vector3"
  3142. */
  3143. getClassName(): string;
  3144. /**
  3145. * Creates the Vector3 hash code
  3146. * @returns a number which tends to be unique between Vector3 instances
  3147. */
  3148. getHashCode(): number;
  3149. /**
  3150. * Creates an array containing three elements : the coordinates of the Vector3
  3151. * @returns a new array of numbers
  3152. */
  3153. asArray(): number[];
  3154. /**
  3155. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  3156. * @param array defines the destination array
  3157. * @param index defines the offset in the destination array
  3158. * @returns the current Vector3
  3159. */
  3160. toArray(array: FloatArray, index?: number): Vector3;
  3161. /**
  3162. * Update the current vector from an array
  3163. * @param array defines the destination array
  3164. * @param index defines the offset in the destination array
  3165. * @returns the current Vector3
  3166. */
  3167. fromArray(array: FloatArray, index?: number): Vector3;
  3168. /**
  3169. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  3170. * @returns a new Quaternion object, computed from the Vector3 coordinates
  3171. */
  3172. toQuaternion(): Quaternion;
  3173. /**
  3174. * Adds the given vector to the current Vector3
  3175. * @param otherVector defines the second operand
  3176. * @returns the current updated Vector3
  3177. */
  3178. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3179. /**
  3180. * Adds the given coordinates to the current Vector3
  3181. * @param x defines the x coordinate of the operand
  3182. * @param y defines the y coordinate of the operand
  3183. * @param z defines the z coordinate of the operand
  3184. * @returns the current updated Vector3
  3185. */
  3186. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3187. /**
  3188. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  3189. * @param otherVector defines the second operand
  3190. * @returns the resulting Vector3
  3191. */
  3192. add(otherVector: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  3195. * @param otherVector defines the second operand
  3196. * @param result defines the Vector3 object where to store the result
  3197. * @returns the current Vector3
  3198. */
  3199. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3200. /**
  3201. * Subtract the given vector from the current Vector3
  3202. * @param otherVector defines the second operand
  3203. * @returns the current updated Vector3
  3204. */
  3205. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3206. /**
  3207. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  3208. * @param otherVector defines the second operand
  3209. * @returns the resulting Vector3
  3210. */
  3211. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  3212. /**
  3213. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  3214. * @param otherVector defines the second operand
  3215. * @param result defines the Vector3 object where to store the result
  3216. * @returns the current Vector3
  3217. */
  3218. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3219. /**
  3220. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  3221. * @param x defines the x coordinate of the operand
  3222. * @param y defines the y coordinate of the operand
  3223. * @param z defines the z coordinate of the operand
  3224. * @returns the resulting Vector3
  3225. */
  3226. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3227. /**
  3228. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  3229. * @param x defines the x coordinate of the operand
  3230. * @param y defines the y coordinate of the operand
  3231. * @param z defines the z coordinate of the operand
  3232. * @param result defines the Vector3 object where to store the result
  3233. * @returns the current Vector3
  3234. */
  3235. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3236. /**
  3237. * Gets a new Vector3 set with the current Vector3 negated coordinates
  3238. * @returns a new Vector3
  3239. */
  3240. negate(): Vector3;
  3241. /**
  3242. * Negate this vector in place
  3243. * @returns this
  3244. */
  3245. negateInPlace(): Vector3;
  3246. /**
  3247. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  3248. * @param result defines the Vector3 object where to store the result
  3249. * @returns the current Vector3
  3250. */
  3251. negateToRef(result: Vector3): Vector3;
  3252. /**
  3253. * Multiplies the Vector3 coordinates by the float "scale"
  3254. * @param scale defines the multiplier factor
  3255. * @returns the current updated Vector3
  3256. */
  3257. scaleInPlace(scale: number): Vector3;
  3258. /**
  3259. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  3260. * @param scale defines the multiplier factor
  3261. * @returns a new Vector3
  3262. */
  3263. scale(scale: number): Vector3;
  3264. /**
  3265. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  3266. * @param scale defines the multiplier factor
  3267. * @param result defines the Vector3 object where to store the result
  3268. * @returns the current Vector3
  3269. */
  3270. scaleToRef(scale: number, result: Vector3): Vector3;
  3271. /**
  3272. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  3273. * @param scale defines the scale factor
  3274. * @param result defines the Vector3 object where to store the result
  3275. * @returns the unmodified current Vector3
  3276. */
  3277. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  3278. /**
  3279. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3280. * @param origin defines the origin of the projection ray
  3281. * @param plane defines the plane to project to
  3282. * @returns the projected vector3
  3283. */
  3284. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  3285. /**
  3286. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  3287. * @param origin defines the origin of the projection ray
  3288. * @param plane defines the plane to project to
  3289. * @param result defines the Vector3 where to store the result
  3290. */
  3291. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  3292. /**
  3293. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  3294. * @param otherVector defines the second operand
  3295. * @returns true if both vectors are equals
  3296. */
  3297. equals(otherVector: DeepImmutable<Vector3>): boolean;
  3298. /**
  3299. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  3300. * @param otherVector defines the second operand
  3301. * @param epsilon defines the minimal distance to define values as equals
  3302. * @returns true if both vectors are distant less than epsilon
  3303. */
  3304. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  3305. /**
  3306. * Returns true if the current Vector3 coordinates equals the given floats
  3307. * @param x defines the x coordinate of the operand
  3308. * @param y defines the y coordinate of the operand
  3309. * @param z defines the z coordinate of the operand
  3310. * @returns true if both vectors are equals
  3311. */
  3312. equalsToFloats(x: number, y: number, z: number): boolean;
  3313. /**
  3314. * Multiplies the current Vector3 coordinates by the given ones
  3315. * @param otherVector defines the second operand
  3316. * @returns the current updated Vector3
  3317. */
  3318. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  3319. /**
  3320. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  3321. * @param otherVector defines the second operand
  3322. * @returns the new Vector3
  3323. */
  3324. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  3325. /**
  3326. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  3327. * @param otherVector defines the second operand
  3328. * @param result defines the Vector3 object where to store the result
  3329. * @returns the current Vector3
  3330. */
  3331. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3332. /**
  3333. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  3334. * @param x defines the x coordinate of the operand
  3335. * @param y defines the y coordinate of the operand
  3336. * @param z defines the z coordinate of the operand
  3337. * @returns the new Vector3
  3338. */
  3339. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3340. /**
  3341. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  3342. * @param otherVector defines the second operand
  3343. * @returns the new Vector3
  3344. */
  3345. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  3346. /**
  3347. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  3348. * @param otherVector defines the second operand
  3349. * @param result defines the Vector3 object where to store the result
  3350. * @returns the current Vector3
  3351. */
  3352. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  3353. /**
  3354. * Divides the current Vector3 coordinates by the given ones.
  3355. * @param otherVector defines the second operand
  3356. * @returns the current updated Vector3
  3357. */
  3358. divideInPlace(otherVector: Vector3): Vector3;
  3359. /**
  3360. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  3361. * @param other defines the second operand
  3362. * @returns the current updated Vector3
  3363. */
  3364. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3365. /**
  3366. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  3367. * @param other defines the second operand
  3368. * @returns the current updated Vector3
  3369. */
  3370. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  3371. /**
  3372. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  3373. * @param x defines the x coordinate of the operand
  3374. * @param y defines the y coordinate of the operand
  3375. * @param z defines the z coordinate of the operand
  3376. * @returns the current updated Vector3
  3377. */
  3378. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3379. /**
  3380. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  3381. * @param x defines the x coordinate of the operand
  3382. * @param y defines the y coordinate of the operand
  3383. * @param z defines the z coordinate of the operand
  3384. * @returns the current updated Vector3
  3385. */
  3386. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  3387. /**
  3388. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  3389. * Check if is non uniform within a certain amount of decimal places to account for this
  3390. * @param epsilon the amount the values can differ
  3391. * @returns if the the vector is non uniform to a certain number of decimal places
  3392. */
  3393. isNonUniformWithinEpsilon(epsilon: number): boolean;
  3394. /**
  3395. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  3396. */
  3397. get isNonUniform(): boolean;
  3398. /**
  3399. * Gets a new Vector3 from current Vector3 floored values
  3400. * @returns a new Vector3
  3401. */
  3402. floor(): Vector3;
  3403. /**
  3404. * Gets a new Vector3 from current Vector3 floored values
  3405. * @returns a new Vector3
  3406. */
  3407. fract(): Vector3;
  3408. /**
  3409. * Gets the length of the Vector3
  3410. * @returns the length of the Vector3
  3411. */
  3412. length(): number;
  3413. /**
  3414. * Gets the squared length of the Vector3
  3415. * @returns squared length of the Vector3
  3416. */
  3417. lengthSquared(): number;
  3418. /**
  3419. * Normalize the current Vector3.
  3420. * Please note that this is an in place operation.
  3421. * @returns the current updated Vector3
  3422. */
  3423. normalize(): Vector3;
  3424. /**
  3425. * Reorders the x y z properties of the vector in place
  3426. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  3427. * @returns the current updated vector
  3428. */
  3429. reorderInPlace(order: string): this;
  3430. /**
  3431. * Rotates the vector around 0,0,0 by a quaternion
  3432. * @param quaternion the rotation quaternion
  3433. * @param result vector to store the result
  3434. * @returns the resulting vector
  3435. */
  3436. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  3437. /**
  3438. * Rotates a vector around a given point
  3439. * @param quaternion the rotation quaternion
  3440. * @param point the point to rotate around
  3441. * @param result vector to store the result
  3442. * @returns the resulting vector
  3443. */
  3444. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  3445. /**
  3446. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  3447. * The cross product is then orthogonal to both current and "other"
  3448. * @param other defines the right operand
  3449. * @returns the cross product
  3450. */
  3451. cross(other: Vector3): Vector3;
  3452. /**
  3453. * Normalize the current Vector3 with the given input length.
  3454. * Please note that this is an in place operation.
  3455. * @param len the length of the vector
  3456. * @returns the current updated Vector3
  3457. */
  3458. normalizeFromLength(len: number): Vector3;
  3459. /**
  3460. * Normalize the current Vector3 to a new vector
  3461. * @returns the new Vector3
  3462. */
  3463. normalizeToNew(): Vector3;
  3464. /**
  3465. * Normalize the current Vector3 to the reference
  3466. * @param reference define the Vector3 to update
  3467. * @returns the updated Vector3
  3468. */
  3469. normalizeToRef(reference: Vector3): Vector3;
  3470. /**
  3471. * Creates a new Vector3 copied from the current Vector3
  3472. * @returns the new Vector3
  3473. */
  3474. clone(): Vector3;
  3475. /**
  3476. * Copies the given vector coordinates to the current Vector3 ones
  3477. * @param source defines the source Vector3
  3478. * @returns the current updated Vector3
  3479. */
  3480. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  3481. /**
  3482. * Copies the given floats to the current Vector3 coordinates
  3483. * @param x defines the x coordinate of the operand
  3484. * @param y defines the y coordinate of the operand
  3485. * @param z defines the z coordinate of the operand
  3486. * @returns the current updated Vector3
  3487. */
  3488. copyFromFloats(x: number, y: number, z: number): Vector3;
  3489. /**
  3490. * Copies the given floats to the current Vector3 coordinates
  3491. * @param x defines the x coordinate of the operand
  3492. * @param y defines the y coordinate of the operand
  3493. * @param z defines the z coordinate of the operand
  3494. * @returns the current updated Vector3
  3495. */
  3496. set(x: number, y: number, z: number): Vector3;
  3497. /**
  3498. * Copies the given float to the current Vector3 coordinates
  3499. * @param v defines the x, y and z coordinates of the operand
  3500. * @returns the current updated Vector3
  3501. */
  3502. setAll(v: number): Vector3;
  3503. /**
  3504. * Get the clip factor between two vectors
  3505. * @param vector0 defines the first operand
  3506. * @param vector1 defines the second operand
  3507. * @param axis defines the axis to use
  3508. * @param size defines the size along the axis
  3509. * @returns the clip factor
  3510. */
  3511. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  3512. /**
  3513. * Get angle between two vectors
  3514. * @param vector0 angle between vector0 and vector1
  3515. * @param vector1 angle between vector0 and vector1
  3516. * @param normal direction of the normal
  3517. * @return the angle between vector0 and vector1
  3518. */
  3519. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  3520. /**
  3521. * Returns a new Vector3 set from the index "offset" of the given array
  3522. * @param array defines the source array
  3523. * @param offset defines the offset in the source array
  3524. * @returns the new Vector3
  3525. */
  3526. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  3527. /**
  3528. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  3529. * @param array defines the source array
  3530. * @param offset defines the offset in the source array
  3531. * @returns the new Vector3
  3532. * @deprecated Please use FromArray instead.
  3533. */
  3534. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  3535. /**
  3536. * Sets the given vector "result" with the element values from the index "offset" of the given array
  3537. * @param array defines the source array
  3538. * @param offset defines the offset in the source array
  3539. * @param result defines the Vector3 where to store the result
  3540. */
  3541. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  3542. /**
  3543. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  3544. * @param array defines the source array
  3545. * @param offset defines the offset in the source array
  3546. * @param result defines the Vector3 where to store the result
  3547. * @deprecated Please use FromArrayToRef instead.
  3548. */
  3549. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  3550. /**
  3551. * Sets the given vector "result" with the given floats.
  3552. * @param x defines the x coordinate of the source
  3553. * @param y defines the y coordinate of the source
  3554. * @param z defines the z coordinate of the source
  3555. * @param result defines the Vector3 where to store the result
  3556. */
  3557. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3558. /**
  3559. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  3560. * @returns a new empty Vector3
  3561. */
  3562. static Zero(): Vector3;
  3563. /**
  3564. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  3565. * @returns a new unit Vector3
  3566. */
  3567. static One(): Vector3;
  3568. /**
  3569. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  3570. * @returns a new up Vector3
  3571. */
  3572. static Up(): Vector3;
  3573. /**
  3574. * Gets a up Vector3 that must not be updated
  3575. */
  3576. static get UpReadOnly(): DeepImmutable<Vector3>;
  3577. /**
  3578. * Gets a zero Vector3 that must not be updated
  3579. */
  3580. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  3581. /**
  3582. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  3583. * @returns a new down Vector3
  3584. */
  3585. static Down(): Vector3;
  3586. /**
  3587. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  3588. * @param rightHandedSystem is the scene right-handed (negative z)
  3589. * @returns a new forward Vector3
  3590. */
  3591. static Forward(rightHandedSystem?: boolean): Vector3;
  3592. /**
  3593. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3594. * @param rightHandedSystem is the scene right-handed (negative-z)
  3595. * @returns a new forward Vector3
  3596. */
  3597. static Backward(rightHandedSystem?: boolean): Vector3;
  3598. /**
  3599. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3600. * @returns a new right Vector3
  3601. */
  3602. static Right(): Vector3;
  3603. /**
  3604. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3605. * @returns a new left Vector3
  3606. */
  3607. static Left(): Vector3;
  3608. /**
  3609. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3610. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3611. * @param vector defines the Vector3 to transform
  3612. * @param transformation defines the transformation matrix
  3613. * @returns the transformed Vector3
  3614. */
  3615. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3616. /**
  3617. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3618. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3619. * @param vector defines the Vector3 to transform
  3620. * @param transformation defines the transformation matrix
  3621. * @param result defines the Vector3 where to store the result
  3622. */
  3623. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3624. /**
  3625. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3626. * This method computes tranformed coordinates only, not transformed direction vectors
  3627. * @param x define the x coordinate of the source vector
  3628. * @param y define the y coordinate of the source vector
  3629. * @param z define the z coordinate of the source vector
  3630. * @param transformation defines the transformation matrix
  3631. * @param result defines the Vector3 where to store the result
  3632. */
  3633. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3634. /**
  3635. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3636. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3637. * @param vector defines the Vector3 to transform
  3638. * @param transformation defines the transformation matrix
  3639. * @returns the new Vector3
  3640. */
  3641. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3642. /**
  3643. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3644. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3645. * @param vector defines the Vector3 to transform
  3646. * @param transformation defines the transformation matrix
  3647. * @param result defines the Vector3 where to store the result
  3648. */
  3649. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3650. /**
  3651. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3652. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3653. * @param x define the x coordinate of the source vector
  3654. * @param y define the y coordinate of the source vector
  3655. * @param z define the z coordinate of the source vector
  3656. * @param transformation defines the transformation matrix
  3657. * @param result defines the Vector3 where to store the result
  3658. */
  3659. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3660. /**
  3661. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3662. * @param value1 defines the first control point
  3663. * @param value2 defines the second control point
  3664. * @param value3 defines the third control point
  3665. * @param value4 defines the fourth control point
  3666. * @param amount defines the amount on the spline to use
  3667. * @returns the new Vector3
  3668. */
  3669. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3670. /**
  3671. * 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"
  3672. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3673. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3674. * @param value defines the current value
  3675. * @param min defines the lower range value
  3676. * @param max defines the upper range value
  3677. * @returns the new Vector3
  3678. */
  3679. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3680. /**
  3681. * 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"
  3682. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3683. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3684. * @param value defines the current value
  3685. * @param min defines the lower range value
  3686. * @param max defines the upper range value
  3687. * @param result defines the Vector3 where to store the result
  3688. */
  3689. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3690. /**
  3691. * Checks if a given vector is inside a specific range
  3692. * @param v defines the vector to test
  3693. * @param min defines the minimum range
  3694. * @param max defines the maximum range
  3695. */
  3696. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3697. /**
  3698. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3699. * @param value1 defines the first control point
  3700. * @param tangent1 defines the first tangent vector
  3701. * @param value2 defines the second control point
  3702. * @param tangent2 defines the second tangent vector
  3703. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3704. * @returns the new Vector3
  3705. */
  3706. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3707. /**
  3708. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3709. * @param start defines the start value
  3710. * @param end defines the end value
  3711. * @param amount max defines amount between both (between 0 and 1)
  3712. * @returns the new Vector3
  3713. */
  3714. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3715. /**
  3716. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3717. * @param start defines the start value
  3718. * @param end defines the end value
  3719. * @param amount max defines amount between both (between 0 and 1)
  3720. * @param result defines the Vector3 where to store the result
  3721. */
  3722. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3723. /**
  3724. * Returns the dot product (float) between the vectors "left" and "right"
  3725. * @param left defines the left operand
  3726. * @param right defines the right operand
  3727. * @returns the dot product
  3728. */
  3729. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3730. /**
  3731. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3732. * The cross product is then orthogonal to both "left" and "right"
  3733. * @param left defines the left operand
  3734. * @param right defines the right operand
  3735. * @returns the cross product
  3736. */
  3737. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3738. /**
  3739. * Sets the given vector "result" with the cross product of "left" and "right"
  3740. * The cross product is then orthogonal to both "left" and "right"
  3741. * @param left defines the left operand
  3742. * @param right defines the right operand
  3743. * @param result defines the Vector3 where to store the result
  3744. */
  3745. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3746. /**
  3747. * Returns a new Vector3 as the normalization of the given vector
  3748. * @param vector defines the Vector3 to normalize
  3749. * @returns the new Vector3
  3750. */
  3751. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3752. /**
  3753. * Sets the given vector "result" with the normalization of the given first vector
  3754. * @param vector defines the Vector3 to normalize
  3755. * @param result defines the Vector3 where to store the result
  3756. */
  3757. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3758. /**
  3759. * Project a Vector3 onto screen space
  3760. * @param vector defines the Vector3 to project
  3761. * @param world defines the world matrix to use
  3762. * @param transform defines the transform (view x projection) matrix to use
  3763. * @param viewport defines the screen viewport to use
  3764. * @returns the new Vector3
  3765. */
  3766. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3767. /**
  3768. * Project a Vector3 onto screen space to reference
  3769. * @param vector defines the Vector3 to project
  3770. * @param world defines the world matrix to use
  3771. * @param transform defines the transform (view x projection) matrix to use
  3772. * @param viewport defines the screen viewport to use
  3773. * @param result the vector in which the screen space will be stored
  3774. * @returns the new Vector3
  3775. */
  3776. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3777. /** @hidden */
  3778. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3779. /**
  3780. * Unproject from screen space to object space
  3781. * @param source defines the screen space Vector3 to use
  3782. * @param viewportWidth defines the current width of the viewport
  3783. * @param viewportHeight defines the current height of the viewport
  3784. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3785. * @param transform defines the transform (view x projection) matrix to use
  3786. * @returns the new Vector3
  3787. */
  3788. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3789. /**
  3790. * Unproject from screen space to object space
  3791. * @param source defines the screen space Vector3 to use
  3792. * @param viewportWidth defines the current width of the viewport
  3793. * @param viewportHeight defines the current height of the viewport
  3794. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3795. * @param view defines the view matrix to use
  3796. * @param projection defines the projection matrix to use
  3797. * @returns the new Vector3
  3798. */
  3799. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3800. /**
  3801. * Unproject from screen space to object space
  3802. * @param source defines the screen space Vector3 to use
  3803. * @param viewportWidth defines the current width of the viewport
  3804. * @param viewportHeight defines the current height of the viewport
  3805. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3806. * @param view defines the view matrix to use
  3807. * @param projection defines the projection matrix to use
  3808. * @param result defines the Vector3 where to store the result
  3809. */
  3810. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3811. /**
  3812. * Unproject from screen space to object space
  3813. * @param sourceX defines the screen space x coordinate to use
  3814. * @param sourceY defines the screen space y coordinate to use
  3815. * @param sourceZ defines the screen space z coordinate to use
  3816. * @param viewportWidth defines the current width of the viewport
  3817. * @param viewportHeight defines the current height of the viewport
  3818. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3819. * @param view defines the view matrix to use
  3820. * @param projection defines the projection matrix to use
  3821. * @param result defines the Vector3 where to store the result
  3822. */
  3823. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3824. /**
  3825. * Gets the minimal coordinate values between two Vector3
  3826. * @param left defines the first operand
  3827. * @param right defines the second operand
  3828. * @returns the new Vector3
  3829. */
  3830. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3831. /**
  3832. * Gets the maximal coordinate values between two Vector3
  3833. * @param left defines the first operand
  3834. * @param right defines the second operand
  3835. * @returns the new Vector3
  3836. */
  3837. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3838. /**
  3839. * Returns the distance between the vectors "value1" and "value2"
  3840. * @param value1 defines the first operand
  3841. * @param value2 defines the second operand
  3842. * @returns the distance
  3843. */
  3844. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3845. /**
  3846. * Returns the squared distance between the vectors "value1" and "value2"
  3847. * @param value1 defines the first operand
  3848. * @param value2 defines the second operand
  3849. * @returns the squared distance
  3850. */
  3851. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3852. /**
  3853. * Returns a new Vector3 located at the center between "value1" and "value2"
  3854. * @param value1 defines the first operand
  3855. * @param value2 defines the second operand
  3856. * @returns the new Vector3
  3857. */
  3858. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3859. /**
  3860. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  3861. * @param value1 defines first vector
  3862. * @param value2 defines second vector
  3863. * @param ref defines third vector
  3864. * @returns ref
  3865. */
  3866. static CenterToRef(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, ref: DeepImmutable<Vector3>): Vector3;
  3867. /**
  3868. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3869. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3870. * to something in order to rotate it from its local system to the given target system
  3871. * Note: axis1, axis2 and axis3 are normalized during this operation
  3872. * @param axis1 defines the first axis
  3873. * @param axis2 defines the second axis
  3874. * @param axis3 defines the third axis
  3875. * @returns a new Vector3
  3876. */
  3877. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3878. /**
  3879. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3880. * @param axis1 defines the first axis
  3881. * @param axis2 defines the second axis
  3882. * @param axis3 defines the third axis
  3883. * @param ref defines the Vector3 where to store the result
  3884. */
  3885. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3886. }
  3887. /**
  3888. * Vector4 class created for EulerAngle class conversion to Quaternion
  3889. */
  3890. export class Vector4 {
  3891. /** x value of the vector */
  3892. x: number;
  3893. /** y value of the vector */
  3894. y: number;
  3895. /** z value of the vector */
  3896. z: number;
  3897. /** w value of the vector */
  3898. w: number;
  3899. /**
  3900. * Creates a Vector4 object from the given floats.
  3901. * @param x x value of the vector
  3902. * @param y y value of the vector
  3903. * @param z z value of the vector
  3904. * @param w w value of the vector
  3905. */
  3906. constructor(
  3907. /** x value of the vector */
  3908. x: number,
  3909. /** y value of the vector */
  3910. y: number,
  3911. /** z value of the vector */
  3912. z: number,
  3913. /** w value of the vector */
  3914. w: number);
  3915. /**
  3916. * Returns the string with the Vector4 coordinates.
  3917. * @returns a string containing all the vector values
  3918. */
  3919. toString(): string;
  3920. /**
  3921. * Returns the string "Vector4".
  3922. * @returns "Vector4"
  3923. */
  3924. getClassName(): string;
  3925. /**
  3926. * Returns the Vector4 hash code.
  3927. * @returns a unique hash code
  3928. */
  3929. getHashCode(): number;
  3930. /**
  3931. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3932. * @returns the resulting array
  3933. */
  3934. asArray(): number[];
  3935. /**
  3936. * Populates the given array from the given index with the Vector4 coordinates.
  3937. * @param array array to populate
  3938. * @param index index of the array to start at (default: 0)
  3939. * @returns the Vector4.
  3940. */
  3941. toArray(array: FloatArray, index?: number): Vector4;
  3942. /**
  3943. * Update the current vector from an array
  3944. * @param array defines the destination array
  3945. * @param index defines the offset in the destination array
  3946. * @returns the current Vector3
  3947. */
  3948. fromArray(array: FloatArray, index?: number): Vector4;
  3949. /**
  3950. * Adds the given vector to the current Vector4.
  3951. * @param otherVector the vector to add
  3952. * @returns the updated Vector4.
  3953. */
  3954. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3955. /**
  3956. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3957. * @param otherVector the vector to add
  3958. * @returns the resulting vector
  3959. */
  3960. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3961. /**
  3962. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3963. * @param otherVector the vector to add
  3964. * @param result the vector to store the result
  3965. * @returns the current Vector4.
  3966. */
  3967. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3968. /**
  3969. * Subtract in place the given vector from the current Vector4.
  3970. * @param otherVector the vector to subtract
  3971. * @returns the updated Vector4.
  3972. */
  3973. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3974. /**
  3975. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3976. * @param otherVector the vector to add
  3977. * @returns the new vector with the result
  3978. */
  3979. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3980. /**
  3981. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3982. * @param otherVector the vector to subtract
  3983. * @param result the vector to store the result
  3984. * @returns the current Vector4.
  3985. */
  3986. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3987. /**
  3988. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3989. */
  3990. /**
  3991. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3992. * @param x value to subtract
  3993. * @param y value to subtract
  3994. * @param z value to subtract
  3995. * @param w value to subtract
  3996. * @returns new vector containing the result
  3997. */
  3998. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3999. /**
  4000. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  4001. * @param x value to subtract
  4002. * @param y value to subtract
  4003. * @param z value to subtract
  4004. * @param w value to subtract
  4005. * @param result the vector to store the result in
  4006. * @returns the current Vector4.
  4007. */
  4008. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  4009. /**
  4010. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  4011. * @returns a new vector with the negated values
  4012. */
  4013. negate(): Vector4;
  4014. /**
  4015. * Negate this vector in place
  4016. * @returns this
  4017. */
  4018. negateInPlace(): Vector4;
  4019. /**
  4020. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  4021. * @param result defines the Vector3 object where to store the result
  4022. * @returns the current Vector4
  4023. */
  4024. negateToRef(result: Vector4): Vector4;
  4025. /**
  4026. * Multiplies the current Vector4 coordinates by scale (float).
  4027. * @param scale the number to scale with
  4028. * @returns the updated Vector4.
  4029. */
  4030. scaleInPlace(scale: number): Vector4;
  4031. /**
  4032. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  4033. * @param scale the number to scale with
  4034. * @returns a new vector with the result
  4035. */
  4036. scale(scale: number): Vector4;
  4037. /**
  4038. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  4039. * @param scale the number to scale with
  4040. * @param result a vector to store the result in
  4041. * @returns the current Vector4.
  4042. */
  4043. scaleToRef(scale: number, result: Vector4): Vector4;
  4044. /**
  4045. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  4046. * @param scale defines the scale factor
  4047. * @param result defines the Vector4 object where to store the result
  4048. * @returns the unmodified current Vector4
  4049. */
  4050. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  4051. /**
  4052. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  4053. * @param otherVector the vector to compare against
  4054. * @returns true if they are equal
  4055. */
  4056. equals(otherVector: DeepImmutable<Vector4>): boolean;
  4057. /**
  4058. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  4059. * @param otherVector vector to compare against
  4060. * @param epsilon (Default: very small number)
  4061. * @returns true if they are equal
  4062. */
  4063. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  4064. /**
  4065. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  4066. * @param x x value to compare against
  4067. * @param y y value to compare against
  4068. * @param z z value to compare against
  4069. * @param w w value to compare against
  4070. * @returns true if equal
  4071. */
  4072. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  4073. /**
  4074. * Multiplies in place the current Vector4 by the given one.
  4075. * @param otherVector vector to multiple with
  4076. * @returns the updated Vector4.
  4077. */
  4078. multiplyInPlace(otherVector: Vector4): Vector4;
  4079. /**
  4080. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  4081. * @param otherVector vector to multiple with
  4082. * @returns resulting new vector
  4083. */
  4084. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  4085. /**
  4086. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  4087. * @param otherVector vector to multiple with
  4088. * @param result vector to store the result
  4089. * @returns the current Vector4.
  4090. */
  4091. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4092. /**
  4093. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  4094. * @param x x value multiply with
  4095. * @param y y value multiply with
  4096. * @param z z value multiply with
  4097. * @param w w value multiply with
  4098. * @returns resulting new vector
  4099. */
  4100. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  4101. /**
  4102. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  4103. * @param otherVector vector to devide with
  4104. * @returns resulting new vector
  4105. */
  4106. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  4107. /**
  4108. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  4109. * @param otherVector vector to devide with
  4110. * @param result vector to store the result
  4111. * @returns the current Vector4.
  4112. */
  4113. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  4114. /**
  4115. * Divides the current Vector3 coordinates by the given ones.
  4116. * @param otherVector vector to devide with
  4117. * @returns the updated Vector3.
  4118. */
  4119. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  4120. /**
  4121. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  4122. * @param other defines the second operand
  4123. * @returns the current updated Vector4
  4124. */
  4125. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4126. /**
  4127. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  4128. * @param other defines the second operand
  4129. * @returns the current updated Vector4
  4130. */
  4131. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  4132. /**
  4133. * Gets a new Vector4 from current Vector4 floored values
  4134. * @returns a new Vector4
  4135. */
  4136. floor(): Vector4;
  4137. /**
  4138. * Gets a new Vector4 from current Vector3 floored values
  4139. * @returns a new Vector4
  4140. */
  4141. fract(): Vector4;
  4142. /**
  4143. * Returns the Vector4 length (float).
  4144. * @returns the length
  4145. */
  4146. length(): number;
  4147. /**
  4148. * Returns the Vector4 squared length (float).
  4149. * @returns the length squared
  4150. */
  4151. lengthSquared(): number;
  4152. /**
  4153. * Normalizes in place the Vector4.
  4154. * @returns the updated Vector4.
  4155. */
  4156. normalize(): Vector4;
  4157. /**
  4158. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  4159. * @returns this converted to a new vector3
  4160. */
  4161. toVector3(): Vector3;
  4162. /**
  4163. * Returns a new Vector4 copied from the current one.
  4164. * @returns the new cloned vector
  4165. */
  4166. clone(): Vector4;
  4167. /**
  4168. * Updates the current Vector4 with the given one coordinates.
  4169. * @param source the source vector to copy from
  4170. * @returns the updated Vector4.
  4171. */
  4172. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  4173. /**
  4174. * Updates the current Vector4 coordinates with the given floats.
  4175. * @param x float to copy from
  4176. * @param y float to copy from
  4177. * @param z float to copy from
  4178. * @param w float to copy from
  4179. * @returns the updated Vector4.
  4180. */
  4181. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  4182. /**
  4183. * Updates the current Vector4 coordinates with the given floats.
  4184. * @param x float to set from
  4185. * @param y float to set from
  4186. * @param z float to set from
  4187. * @param w float to set from
  4188. * @returns the updated Vector4.
  4189. */
  4190. set(x: number, y: number, z: number, w: number): Vector4;
  4191. /**
  4192. * Copies the given float to the current Vector3 coordinates
  4193. * @param v defines the x, y, z and w coordinates of the operand
  4194. * @returns the current updated Vector3
  4195. */
  4196. setAll(v: number): Vector4;
  4197. /**
  4198. * Returns a new Vector4 set from the starting index of the given array.
  4199. * @param array the array to pull values from
  4200. * @param offset the offset into the array to start at
  4201. * @returns the new vector
  4202. */
  4203. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  4204. /**
  4205. * Updates the given vector "result" from the starting index of the given array.
  4206. * @param array the array to pull values from
  4207. * @param offset the offset into the array to start at
  4208. * @param result the vector to store the result in
  4209. */
  4210. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  4211. /**
  4212. * Updates the given vector "result" from the starting index of the given Float32Array.
  4213. * @param array the array to pull values from
  4214. * @param offset the offset into the array to start at
  4215. * @param result the vector to store the result in
  4216. */
  4217. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  4218. /**
  4219. * Updates the given vector "result" coordinates from the given floats.
  4220. * @param x float to set from
  4221. * @param y float to set from
  4222. * @param z float to set from
  4223. * @param w float to set from
  4224. * @param result the vector to the floats in
  4225. */
  4226. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  4227. /**
  4228. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  4229. * @returns the new vector
  4230. */
  4231. static Zero(): Vector4;
  4232. /**
  4233. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  4234. * @returns the new vector
  4235. */
  4236. static One(): Vector4;
  4237. /**
  4238. * Returns a new normalized Vector4 from the given one.
  4239. * @param vector the vector to normalize
  4240. * @returns the vector
  4241. */
  4242. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  4243. /**
  4244. * Updates the given vector "result" from the normalization of the given one.
  4245. * @param vector the vector to normalize
  4246. * @param result the vector to store the result in
  4247. */
  4248. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  4249. /**
  4250. * Returns a vector with the minimum values from the left and right vectors
  4251. * @param left left vector to minimize
  4252. * @param right right vector to minimize
  4253. * @returns a new vector with the minimum of the left and right vector values
  4254. */
  4255. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4256. /**
  4257. * Returns a vector with the maximum values from the left and right vectors
  4258. * @param left left vector to maximize
  4259. * @param right right vector to maximize
  4260. * @returns a new vector with the maximum of the left and right vector values
  4261. */
  4262. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  4263. /**
  4264. * Returns the distance (float) between the vectors "value1" and "value2".
  4265. * @param value1 value to calulate the distance between
  4266. * @param value2 value to calulate the distance between
  4267. * @return the distance between the two vectors
  4268. */
  4269. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4270. /**
  4271. * Returns the squared distance (float) between the vectors "value1" and "value2".
  4272. * @param value1 value to calulate the distance between
  4273. * @param value2 value to calulate the distance between
  4274. * @return the distance between the two vectors squared
  4275. */
  4276. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  4277. /**
  4278. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  4279. * @param value1 value to calulate the center between
  4280. * @param value2 value to calulate the center between
  4281. * @return the center between the two vectors
  4282. */
  4283. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  4284. /**
  4285. * Gets the center of the vectors "value1" and "value2" and stores the result in the vector "ref"
  4286. * @param value1 defines first vector
  4287. * @param value2 defines second vector
  4288. * @param ref defines third vector
  4289. * @returns ref
  4290. */
  4291. static CenterToRef(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>, ref: DeepImmutable<Vector4>): Vector4;
  4292. /**
  4293. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  4294. * This methods computes transformed normalized direction vectors only.
  4295. * @param vector the vector to transform
  4296. * @param transformation the transformation matrix to apply
  4297. * @returns the new vector
  4298. */
  4299. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  4300. /**
  4301. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  4302. * This methods computes transformed normalized direction vectors only.
  4303. * @param vector the vector to transform
  4304. * @param transformation the transformation matrix to apply
  4305. * @param result the vector to store the result in
  4306. */
  4307. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4308. /**
  4309. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  4310. * This methods computes transformed normalized direction vectors only.
  4311. * @param x value to transform
  4312. * @param y value to transform
  4313. * @param z value to transform
  4314. * @param w value to transform
  4315. * @param transformation the transformation matrix to apply
  4316. * @param result the vector to store the results in
  4317. */
  4318. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  4319. /**
  4320. * Creates a new Vector4 from a Vector3
  4321. * @param source defines the source data
  4322. * @param w defines the 4th component (default is 0)
  4323. * @returns a new Vector4
  4324. */
  4325. static FromVector3(source: Vector3, w?: number): Vector4;
  4326. }
  4327. /**
  4328. * Class used to store quaternion data
  4329. * @see https://en.wikipedia.org/wiki/Quaternion
  4330. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  4331. */
  4332. export class Quaternion {
  4333. /** @hidden */
  4334. _x: number;
  4335. /** @hidden */
  4336. _y: number;
  4337. /** @hidden */
  4338. _z: number;
  4339. /** @hidden */
  4340. _w: number;
  4341. /** @hidden */
  4342. _isDirty: boolean;
  4343. /** Gets or sets the x coordinate */
  4344. get x(): number;
  4345. set x(value: number);
  4346. /** Gets or sets the y coordinate */
  4347. get y(): number;
  4348. set y(value: number);
  4349. /** Gets or sets the z coordinate */
  4350. get z(): number;
  4351. set z(value: number);
  4352. /** Gets or sets the w coordinate */
  4353. get w(): number;
  4354. set w(value: number);
  4355. /**
  4356. * Creates a new Quaternion from the given floats
  4357. * @param x defines the first component (0 by default)
  4358. * @param y defines the second component (0 by default)
  4359. * @param z defines the third component (0 by default)
  4360. * @param w defines the fourth component (1.0 by default)
  4361. */
  4362. constructor(x?: number, y?: number, z?: number, w?: number);
  4363. /**
  4364. * Gets a string representation for the current quaternion
  4365. * @returns a string with the Quaternion coordinates
  4366. */
  4367. toString(): string;
  4368. /**
  4369. * Gets the class name of the quaternion
  4370. * @returns the string "Quaternion"
  4371. */
  4372. getClassName(): string;
  4373. /**
  4374. * Gets a hash code for this quaternion
  4375. * @returns the quaternion hash code
  4376. */
  4377. getHashCode(): number;
  4378. /**
  4379. * Copy the quaternion to an array
  4380. * @returns a new array populated with 4 elements from the quaternion coordinates
  4381. */
  4382. asArray(): number[];
  4383. /**
  4384. * Check if two quaternions are equals
  4385. * @param otherQuaternion defines the second operand
  4386. * @return true if the current quaternion and the given one coordinates are strictly equals
  4387. */
  4388. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  4389. /**
  4390. * Gets a boolean if two quaternions are equals (using an epsilon value)
  4391. * @param otherQuaternion defines the other quaternion
  4392. * @param epsilon defines the minimal distance to consider equality
  4393. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  4394. */
  4395. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  4396. /**
  4397. * Clone the current quaternion
  4398. * @returns a new quaternion copied from the current one
  4399. */
  4400. clone(): Quaternion;
  4401. /**
  4402. * Copy a quaternion to the current one
  4403. * @param other defines the other quaternion
  4404. * @returns the updated current quaternion
  4405. */
  4406. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  4407. /**
  4408. * Updates the current quaternion with the given float coordinates
  4409. * @param x defines the x coordinate
  4410. * @param y defines the y coordinate
  4411. * @param z defines the z coordinate
  4412. * @param w defines the w coordinate
  4413. * @returns the updated current quaternion
  4414. */
  4415. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  4416. /**
  4417. * Updates the current quaternion from the given float coordinates
  4418. * @param x defines the x coordinate
  4419. * @param y defines the y coordinate
  4420. * @param z defines the z coordinate
  4421. * @param w defines the w coordinate
  4422. * @returns the updated current quaternion
  4423. */
  4424. set(x: number, y: number, z: number, w: number): Quaternion;
  4425. /**
  4426. * Adds two quaternions
  4427. * @param other defines the second operand
  4428. * @returns a new quaternion as the addition result of the given one and the current quaternion
  4429. */
  4430. add(other: DeepImmutable<Quaternion>): Quaternion;
  4431. /**
  4432. * Add a quaternion to the current one
  4433. * @param other defines the quaternion to add
  4434. * @returns the current quaternion
  4435. */
  4436. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  4437. /**
  4438. * Subtract two quaternions
  4439. * @param other defines the second operand
  4440. * @returns a new quaternion as the subtraction result of the given one from the current one
  4441. */
  4442. subtract(other: Quaternion): Quaternion;
  4443. /**
  4444. * Multiplies the current quaternion by a scale factor
  4445. * @param value defines the scale factor
  4446. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  4447. */
  4448. scale(value: number): Quaternion;
  4449. /**
  4450. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  4451. * @param scale defines the scale factor
  4452. * @param result defines the Quaternion object where to store the result
  4453. * @returns the unmodified current quaternion
  4454. */
  4455. scaleToRef(scale: number, result: Quaternion): Quaternion;
  4456. /**
  4457. * Multiplies in place the current quaternion by a scale factor
  4458. * @param value defines the scale factor
  4459. * @returns the current modified quaternion
  4460. */
  4461. scaleInPlace(value: number): Quaternion;
  4462. /**
  4463. * Scale the current quaternion values by a factor and add the result to a given quaternion
  4464. * @param scale defines the scale factor
  4465. * @param result defines the Quaternion object where to store the result
  4466. * @returns the unmodified current quaternion
  4467. */
  4468. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  4469. /**
  4470. * Multiplies two quaternions
  4471. * @param q1 defines the second operand
  4472. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  4473. */
  4474. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  4475. /**
  4476. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  4477. * @param q1 defines the second operand
  4478. * @param result defines the target quaternion
  4479. * @returns the current quaternion
  4480. */
  4481. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  4482. /**
  4483. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  4484. * @param q1 defines the second operand
  4485. * @returns the currentupdated quaternion
  4486. */
  4487. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  4488. /**
  4489. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  4490. * @param ref defines the target quaternion
  4491. * @returns the current quaternion
  4492. */
  4493. conjugateToRef(ref: Quaternion): Quaternion;
  4494. /**
  4495. * Conjugates in place (1-q) the current quaternion
  4496. * @returns the current updated quaternion
  4497. */
  4498. conjugateInPlace(): Quaternion;
  4499. /**
  4500. * Conjugates in place (1-q) the current quaternion
  4501. * @returns a new quaternion
  4502. */
  4503. conjugate(): Quaternion;
  4504. /**
  4505. * Gets length of current quaternion
  4506. * @returns the quaternion length (float)
  4507. */
  4508. length(): number;
  4509. /**
  4510. * Normalize in place the current quaternion
  4511. * @returns the current updated quaternion
  4512. */
  4513. normalize(): Quaternion;
  4514. /**
  4515. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  4516. * @param order is a reserved parameter and is ignored for now
  4517. * @returns a new Vector3 containing the Euler angles
  4518. */
  4519. toEulerAngles(order?: string): Vector3;
  4520. /**
  4521. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  4522. * @param result defines the vector which will be filled with the Euler angles
  4523. * @returns the current unchanged quaternion
  4524. */
  4525. toEulerAnglesToRef(result: Vector3): Quaternion;
  4526. /**
  4527. * Updates the given rotation matrix with the current quaternion values
  4528. * @param result defines the target matrix
  4529. * @returns the current unchanged quaternion
  4530. */
  4531. toRotationMatrix(result: Matrix): Quaternion;
  4532. /**
  4533. * Updates the current quaternion from the given rotation matrix values
  4534. * @param matrix defines the source matrix
  4535. * @returns the current updated quaternion
  4536. */
  4537. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4538. /**
  4539. * Creates a new quaternion from a rotation matrix
  4540. * @param matrix defines the source matrix
  4541. * @returns a new quaternion created from the given rotation matrix values
  4542. */
  4543. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  4544. /**
  4545. * Updates the given quaternion with the given rotation matrix values
  4546. * @param matrix defines the source matrix
  4547. * @param result defines the target quaternion
  4548. */
  4549. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  4550. /**
  4551. * Returns the dot product (float) between the quaternions "left" and "right"
  4552. * @param left defines the left operand
  4553. * @param right defines the right operand
  4554. * @returns the dot product
  4555. */
  4556. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  4557. /**
  4558. * Checks if the two quaternions are close to each other
  4559. * @param quat0 defines the first quaternion to check
  4560. * @param quat1 defines the second quaternion to check
  4561. * @returns true if the two quaternions are close to each other
  4562. */
  4563. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  4564. /**
  4565. * Creates an empty quaternion
  4566. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  4567. */
  4568. static Zero(): Quaternion;
  4569. /**
  4570. * Inverse a given quaternion
  4571. * @param q defines the source quaternion
  4572. * @returns a new quaternion as the inverted current quaternion
  4573. */
  4574. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  4575. /**
  4576. * Inverse a given quaternion
  4577. * @param q defines the source quaternion
  4578. * @param result the quaternion the result will be stored in
  4579. * @returns the result quaternion
  4580. */
  4581. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  4582. /**
  4583. * Creates an identity quaternion
  4584. * @returns the identity quaternion
  4585. */
  4586. static Identity(): Quaternion;
  4587. /**
  4588. * Gets a boolean indicating if the given quaternion is identity
  4589. * @param quaternion defines the quaternion to check
  4590. * @returns true if the quaternion is identity
  4591. */
  4592. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  4593. /**
  4594. * Creates a quaternion from a rotation around an axis
  4595. * @param axis defines the axis to use
  4596. * @param angle defines the angle to use
  4597. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  4598. */
  4599. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  4600. /**
  4601. * Creates a rotation around an axis and stores it into the given quaternion
  4602. * @param axis defines the axis to use
  4603. * @param angle defines the angle to use
  4604. * @param result defines the target quaternion
  4605. * @returns the target quaternion
  4606. */
  4607. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4608. /**
  4609. * Creates a new quaternion from data stored into an array
  4610. * @param array defines the data source
  4611. * @param offset defines the offset in the source array where the data starts
  4612. * @returns a new quaternion
  4613. */
  4614. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4615. /**
  4616. * Updates the given quaternion "result" from the starting index of the given array.
  4617. * @param array the array to pull values from
  4618. * @param offset the offset into the array to start at
  4619. * @param result the quaternion to store the result in
  4620. */
  4621. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4622. /**
  4623. * Create a quaternion from Euler rotation angles
  4624. * @param x Pitch
  4625. * @param y Yaw
  4626. * @param z Roll
  4627. * @returns the new Quaternion
  4628. */
  4629. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4630. /**
  4631. * Updates a quaternion from Euler rotation angles
  4632. * @param x Pitch
  4633. * @param y Yaw
  4634. * @param z Roll
  4635. * @param result the quaternion to store the result
  4636. * @returns the updated quaternion
  4637. */
  4638. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4639. /**
  4640. * Create a quaternion from Euler rotation vector
  4641. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4642. * @returns the new Quaternion
  4643. */
  4644. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4645. /**
  4646. * Updates a quaternion from Euler rotation vector
  4647. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4648. * @param result the quaternion to store the result
  4649. * @returns the updated quaternion
  4650. */
  4651. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4652. /**
  4653. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4654. * @param yaw defines the rotation around Y axis
  4655. * @param pitch defines the rotation around X axis
  4656. * @param roll defines the rotation around Z axis
  4657. * @returns the new quaternion
  4658. */
  4659. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4660. /**
  4661. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4662. * @param yaw defines the rotation around Y axis
  4663. * @param pitch defines the rotation around X axis
  4664. * @param roll defines the rotation around Z axis
  4665. * @param result defines the target quaternion
  4666. */
  4667. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4668. /**
  4669. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4670. * @param alpha defines the rotation around first axis
  4671. * @param beta defines the rotation around second axis
  4672. * @param gamma defines the rotation around third axis
  4673. * @returns the new quaternion
  4674. */
  4675. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4676. /**
  4677. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4678. * @param alpha defines the rotation around first axis
  4679. * @param beta defines the rotation around second axis
  4680. * @param gamma defines the rotation around third axis
  4681. * @param result defines the target quaternion
  4682. */
  4683. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4684. /**
  4685. * 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)
  4686. * @param axis1 defines the first axis
  4687. * @param axis2 defines the second axis
  4688. * @param axis3 defines the third axis
  4689. * @returns the new quaternion
  4690. */
  4691. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4692. /**
  4693. * 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
  4694. * @param axis1 defines the first axis
  4695. * @param axis2 defines the second axis
  4696. * @param axis3 defines the third axis
  4697. * @param ref defines the target quaternion
  4698. */
  4699. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4700. /**
  4701. * Interpolates between two quaternions
  4702. * @param left defines first quaternion
  4703. * @param right defines second quaternion
  4704. * @param amount defines the gradient to use
  4705. * @returns the new interpolated quaternion
  4706. */
  4707. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4708. /**
  4709. * Interpolates between two quaternions and stores it into a target quaternion
  4710. * @param left defines first quaternion
  4711. * @param right defines second quaternion
  4712. * @param amount defines the gradient to use
  4713. * @param result defines the target quaternion
  4714. */
  4715. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4716. /**
  4717. * Interpolate between two quaternions using Hermite interpolation
  4718. * @param value1 defines first quaternion
  4719. * @param tangent1 defines the incoming tangent
  4720. * @param value2 defines second quaternion
  4721. * @param tangent2 defines the outgoing tangent
  4722. * @param amount defines the target quaternion
  4723. * @returns the new interpolated quaternion
  4724. */
  4725. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4726. }
  4727. /**
  4728. * Class used to store matrix data (4x4)
  4729. */
  4730. export class Matrix {
  4731. /**
  4732. * Gets the precision of matrix computations
  4733. */
  4734. static get Use64Bits(): boolean;
  4735. private static _updateFlagSeed;
  4736. private static _identityReadOnly;
  4737. private _isIdentity;
  4738. private _isIdentityDirty;
  4739. private _isIdentity3x2;
  4740. private _isIdentity3x2Dirty;
  4741. /**
  4742. * Gets the update flag of the matrix which is an unique number for the matrix.
  4743. * It will be incremented every time the matrix data change.
  4744. * You can use it to speed the comparison between two versions of the same matrix.
  4745. */
  4746. updateFlag: number;
  4747. private readonly _m;
  4748. /**
  4749. * Gets the internal data of the matrix
  4750. */
  4751. get m(): DeepImmutable<Float32Array | Array<number>>;
  4752. /** @hidden */
  4753. _markAsUpdated(): void;
  4754. /** @hidden */
  4755. private _updateIdentityStatus;
  4756. /**
  4757. * Creates an empty matrix (filled with zeros)
  4758. */
  4759. constructor();
  4760. /**
  4761. * Check if the current matrix is identity
  4762. * @returns true is the matrix is the identity matrix
  4763. */
  4764. isIdentity(): boolean;
  4765. /**
  4766. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4767. * @returns true is the matrix is the identity matrix
  4768. */
  4769. isIdentityAs3x2(): boolean;
  4770. /**
  4771. * Gets the determinant of the matrix
  4772. * @returns the matrix determinant
  4773. */
  4774. determinant(): number;
  4775. /**
  4776. * Returns the matrix as a Float32Array or Array<number>
  4777. * @returns the matrix underlying array
  4778. */
  4779. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4780. /**
  4781. * Returns the matrix as a Float32Array or Array<number>
  4782. * @returns the matrix underlying array.
  4783. */
  4784. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4785. /**
  4786. * Inverts the current matrix in place
  4787. * @returns the current inverted matrix
  4788. */
  4789. invert(): Matrix;
  4790. /**
  4791. * Sets all the matrix elements to zero
  4792. * @returns the current matrix
  4793. */
  4794. reset(): Matrix;
  4795. /**
  4796. * Adds the current matrix with a second one
  4797. * @param other defines the matrix to add
  4798. * @returns a new matrix as the addition of the current matrix and the given one
  4799. */
  4800. add(other: DeepImmutable<Matrix>): Matrix;
  4801. /**
  4802. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4803. * @param other defines the matrix to add
  4804. * @param result defines the target matrix
  4805. * @returns the current matrix
  4806. */
  4807. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4808. /**
  4809. * Adds in place the given matrix to the current matrix
  4810. * @param other defines the second operand
  4811. * @returns the current updated matrix
  4812. */
  4813. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4814. /**
  4815. * Sets the given matrix to the current inverted Matrix
  4816. * @param other defines the target matrix
  4817. * @returns the unmodified current matrix
  4818. */
  4819. invertToRef(other: Matrix): Matrix;
  4820. /**
  4821. * add a value at the specified position in the current Matrix
  4822. * @param index the index of the value within the matrix. between 0 and 15.
  4823. * @param value the value to be added
  4824. * @returns the current updated matrix
  4825. */
  4826. addAtIndex(index: number, value: number): Matrix;
  4827. /**
  4828. * mutiply the specified position in the current Matrix by a value
  4829. * @param index the index of the value within the matrix. between 0 and 15.
  4830. * @param value the value to be added
  4831. * @returns the current updated matrix
  4832. */
  4833. multiplyAtIndex(index: number, value: number): Matrix;
  4834. /**
  4835. * Inserts the translation vector (using 3 floats) in the current matrix
  4836. * @param x defines the 1st component of the translation
  4837. * @param y defines the 2nd component of the translation
  4838. * @param z defines the 3rd component of the translation
  4839. * @returns the current updated matrix
  4840. */
  4841. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4842. /**
  4843. * Adds the translation vector (using 3 floats) in the current matrix
  4844. * @param x defines the 1st component of the translation
  4845. * @param y defines the 2nd component of the translation
  4846. * @param z defines the 3rd component of the translation
  4847. * @returns the current updated matrix
  4848. */
  4849. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4850. /**
  4851. * Inserts the translation vector in the current matrix
  4852. * @param vector3 defines the translation to insert
  4853. * @returns the current updated matrix
  4854. */
  4855. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4856. /**
  4857. * Gets the translation value of the current matrix
  4858. * @returns a new Vector3 as the extracted translation from the matrix
  4859. */
  4860. getTranslation(): Vector3;
  4861. /**
  4862. * Fill a Vector3 with the extracted translation from the matrix
  4863. * @param result defines the Vector3 where to store the translation
  4864. * @returns the current matrix
  4865. */
  4866. getTranslationToRef(result: Vector3): Matrix;
  4867. /**
  4868. * Remove rotation and scaling part from the matrix
  4869. * @returns the updated matrix
  4870. */
  4871. removeRotationAndScaling(): Matrix;
  4872. /**
  4873. * Multiply two matrices
  4874. * @param other defines the second operand
  4875. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4876. */
  4877. multiply(other: DeepImmutable<Matrix>): Matrix;
  4878. /**
  4879. * Copy the current matrix from the given one
  4880. * @param other defines the source matrix
  4881. * @returns the current updated matrix
  4882. */
  4883. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4884. /**
  4885. * Populates the given array from the starting index with the current matrix values
  4886. * @param array defines the target array
  4887. * @param offset defines the offset in the target array where to start storing values
  4888. * @returns the current matrix
  4889. */
  4890. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4891. /**
  4892. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4893. * @param other defines the second operand
  4894. * @param result defines the matrix where to store the multiplication
  4895. * @returns the current matrix
  4896. */
  4897. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4898. /**
  4899. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4900. * @param other defines the second operand
  4901. * @param result defines the array where to store the multiplication
  4902. * @param offset defines the offset in the target array where to start storing values
  4903. * @returns the current matrix
  4904. */
  4905. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4906. /**
  4907. * Check equality between this matrix and a second one
  4908. * @param value defines the second matrix to compare
  4909. * @returns true is the current matrix and the given one values are strictly equal
  4910. */
  4911. equals(value: DeepImmutable<Matrix>): boolean;
  4912. /**
  4913. * Clone the current matrix
  4914. * @returns a new matrix from the current matrix
  4915. */
  4916. clone(): Matrix;
  4917. /**
  4918. * Returns the name of the current matrix class
  4919. * @returns the string "Matrix"
  4920. */
  4921. getClassName(): string;
  4922. /**
  4923. * Gets the hash code of the current matrix
  4924. * @returns the hash code
  4925. */
  4926. getHashCode(): number;
  4927. /**
  4928. * Decomposes the current Matrix into a translation, rotation and scaling components
  4929. * @param scale defines the scale vector3 given as a reference to update
  4930. * @param rotation defines the rotation quaternion given as a reference to update
  4931. * @param translation defines the translation vector3 given as a reference to update
  4932. * @returns true if operation was successful
  4933. */
  4934. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4935. /**
  4936. * Gets specific row of the matrix
  4937. * @param index defines the number of the row to get
  4938. * @returns the index-th row of the current matrix as a new Vector4
  4939. */
  4940. getRow(index: number): Nullable<Vector4>;
  4941. /**
  4942. * Sets the index-th row of the current matrix to the vector4 values
  4943. * @param index defines the number of the row to set
  4944. * @param row defines the target vector4
  4945. * @returns the updated current matrix
  4946. */
  4947. setRow(index: number, row: Vector4): Matrix;
  4948. /**
  4949. * Compute the transpose of the matrix
  4950. * @returns the new transposed matrix
  4951. */
  4952. transpose(): Matrix;
  4953. /**
  4954. * Compute the transpose of the matrix and store it in a given matrix
  4955. * @param result defines the target matrix
  4956. * @returns the current matrix
  4957. */
  4958. transposeToRef(result: Matrix): Matrix;
  4959. /**
  4960. * Sets the index-th row of the current matrix with the given 4 x float values
  4961. * @param index defines the row index
  4962. * @param x defines the x component to set
  4963. * @param y defines the y component to set
  4964. * @param z defines the z component to set
  4965. * @param w defines the w component to set
  4966. * @returns the updated current matrix
  4967. */
  4968. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4969. /**
  4970. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4971. * @param scale defines the scale factor
  4972. * @returns a new matrix
  4973. */
  4974. scale(scale: number): Matrix;
  4975. /**
  4976. * Scale the current matrix values by a factor to a given result matrix
  4977. * @param scale defines the scale factor
  4978. * @param result defines the matrix to store the result
  4979. * @returns the current matrix
  4980. */
  4981. scaleToRef(scale: number, result: Matrix): Matrix;
  4982. /**
  4983. * Scale the current matrix values by a factor and add the result to a given matrix
  4984. * @param scale defines the scale factor
  4985. * @param result defines the Matrix to store the result
  4986. * @returns the current matrix
  4987. */
  4988. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4989. /**
  4990. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4991. * @param ref matrix to store the result
  4992. */
  4993. toNormalMatrix(ref: Matrix): void;
  4994. /**
  4995. * Gets only rotation part of the current matrix
  4996. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4997. */
  4998. getRotationMatrix(): Matrix;
  4999. /**
  5000. * Extracts the rotation matrix from the current one and sets it as the given "result"
  5001. * @param result defines the target matrix to store data to
  5002. * @returns the current matrix
  5003. */
  5004. getRotationMatrixToRef(result: Matrix): Matrix;
  5005. /**
  5006. * Toggles model matrix from being right handed to left handed in place and vice versa
  5007. */
  5008. toggleModelMatrixHandInPlace(): void;
  5009. /**
  5010. * Toggles projection matrix from being right handed to left handed in place and vice versa
  5011. */
  5012. toggleProjectionMatrixHandInPlace(): void;
  5013. /**
  5014. * Creates a matrix from an array
  5015. * @param array defines the source array
  5016. * @param offset defines an offset in the source array
  5017. * @returns a new Matrix set from the starting index of the given array
  5018. */
  5019. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  5020. /**
  5021. * Copy the content of an array into a given matrix
  5022. * @param array defines the source array
  5023. * @param offset defines an offset in the source array
  5024. * @param result defines the target matrix
  5025. */
  5026. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  5027. /**
  5028. * Stores an array into a matrix after having multiplied each component by a given factor
  5029. * @param array defines the source array
  5030. * @param offset defines the offset in the source array
  5031. * @param scale defines the scaling factor
  5032. * @param result defines the target matrix
  5033. */
  5034. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  5035. /**
  5036. * Gets an identity matrix that must not be updated
  5037. */
  5038. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  5039. /**
  5040. * Stores a list of values (16) inside a given matrix
  5041. * @param initialM11 defines 1st value of 1st row
  5042. * @param initialM12 defines 2nd value of 1st row
  5043. * @param initialM13 defines 3rd value of 1st row
  5044. * @param initialM14 defines 4th value of 1st row
  5045. * @param initialM21 defines 1st value of 2nd row
  5046. * @param initialM22 defines 2nd value of 2nd row
  5047. * @param initialM23 defines 3rd value of 2nd row
  5048. * @param initialM24 defines 4th value of 2nd row
  5049. * @param initialM31 defines 1st value of 3rd row
  5050. * @param initialM32 defines 2nd value of 3rd row
  5051. * @param initialM33 defines 3rd value of 3rd row
  5052. * @param initialM34 defines 4th value of 3rd row
  5053. * @param initialM41 defines 1st value of 4th row
  5054. * @param initialM42 defines 2nd value of 4th row
  5055. * @param initialM43 defines 3rd value of 4th row
  5056. * @param initialM44 defines 4th value of 4th row
  5057. * @param result defines the target matrix
  5058. */
  5059. 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;
  5060. /**
  5061. * Creates new matrix from a list of values (16)
  5062. * @param initialM11 defines 1st value of 1st row
  5063. * @param initialM12 defines 2nd value of 1st row
  5064. * @param initialM13 defines 3rd value of 1st row
  5065. * @param initialM14 defines 4th value of 1st row
  5066. * @param initialM21 defines 1st value of 2nd row
  5067. * @param initialM22 defines 2nd value of 2nd row
  5068. * @param initialM23 defines 3rd value of 2nd row
  5069. * @param initialM24 defines 4th value of 2nd row
  5070. * @param initialM31 defines 1st value of 3rd row
  5071. * @param initialM32 defines 2nd value of 3rd row
  5072. * @param initialM33 defines 3rd value of 3rd row
  5073. * @param initialM34 defines 4th value of 3rd row
  5074. * @param initialM41 defines 1st value of 4th row
  5075. * @param initialM42 defines 2nd value of 4th row
  5076. * @param initialM43 defines 3rd value of 4th row
  5077. * @param initialM44 defines 4th value of 4th row
  5078. * @returns the new matrix
  5079. */
  5080. 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;
  5081. /**
  5082. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5083. * @param scale defines the scale vector3
  5084. * @param rotation defines the rotation quaternion
  5085. * @param translation defines the translation vector3
  5086. * @returns a new matrix
  5087. */
  5088. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  5089. /**
  5090. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  5091. * @param scale defines the scale vector3
  5092. * @param rotation defines the rotation quaternion
  5093. * @param translation defines the translation vector3
  5094. * @param result defines the target matrix
  5095. */
  5096. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  5097. /**
  5098. * Creates a new identity matrix
  5099. * @returns a new identity matrix
  5100. */
  5101. static Identity(): Matrix;
  5102. /**
  5103. * Creates a new identity matrix and stores the result in a given matrix
  5104. * @param result defines the target matrix
  5105. */
  5106. static IdentityToRef(result: Matrix): void;
  5107. /**
  5108. * Creates a new zero matrix
  5109. * @returns a new zero matrix
  5110. */
  5111. static Zero(): Matrix;
  5112. /**
  5113. * Creates a new rotation matrix for "angle" radians around the X axis
  5114. * @param angle defines the angle (in radians) to use
  5115. * @return the new matrix
  5116. */
  5117. static RotationX(angle: number): Matrix;
  5118. /**
  5119. * Creates a new matrix as the invert of a given matrix
  5120. * @param source defines the source matrix
  5121. * @returns the new matrix
  5122. */
  5123. static Invert(source: DeepImmutable<Matrix>): Matrix;
  5124. /**
  5125. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  5126. * @param angle defines the angle (in radians) to use
  5127. * @param result defines the target matrix
  5128. */
  5129. static RotationXToRef(angle: number, result: Matrix): void;
  5130. /**
  5131. * Creates a new rotation matrix for "angle" radians around the Y axis
  5132. * @param angle defines the angle (in radians) to use
  5133. * @return the new matrix
  5134. */
  5135. static RotationY(angle: number): Matrix;
  5136. /**
  5137. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  5138. * @param angle defines the angle (in radians) to use
  5139. * @param result defines the target matrix
  5140. */
  5141. static RotationYToRef(angle: number, result: Matrix): void;
  5142. /**
  5143. * Creates a new rotation matrix for "angle" radians around the Z axis
  5144. * @param angle defines the angle (in radians) to use
  5145. * @return the new matrix
  5146. */
  5147. static RotationZ(angle: number): Matrix;
  5148. /**
  5149. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  5150. * @param angle defines the angle (in radians) to use
  5151. * @param result defines the target matrix
  5152. */
  5153. static RotationZToRef(angle: number, result: Matrix): void;
  5154. /**
  5155. * Creates a new rotation matrix for "angle" radians around the given axis
  5156. * @param axis defines the axis to use
  5157. * @param angle defines the angle (in radians) to use
  5158. * @return the new matrix
  5159. */
  5160. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  5161. /**
  5162. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  5163. * @param axis defines the axis to use
  5164. * @param angle defines the angle (in radians) to use
  5165. * @param result defines the target matrix
  5166. */
  5167. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  5168. /**
  5169. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  5170. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  5171. * @param from defines the vector to align
  5172. * @param to defines the vector to align to
  5173. * @param result defines the target matrix
  5174. */
  5175. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  5176. /**
  5177. * Creates a rotation matrix
  5178. * @param yaw defines the yaw angle in radians (Y axis)
  5179. * @param pitch defines the pitch angle in radians (X axis)
  5180. * @param roll defines the roll angle in radians (Z axis)
  5181. * @returns the new rotation matrix
  5182. */
  5183. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  5184. /**
  5185. * Creates a rotation matrix and stores it in a given matrix
  5186. * @param yaw defines the yaw angle in radians (Y axis)
  5187. * @param pitch defines the pitch angle in radians (X axis)
  5188. * @param roll defines the roll angle in radians (Z axis)
  5189. * @param result defines the target matrix
  5190. */
  5191. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  5192. /**
  5193. * Creates a scaling matrix
  5194. * @param x defines the scale factor on X axis
  5195. * @param y defines the scale factor on Y axis
  5196. * @param z defines the scale factor on Z axis
  5197. * @returns the new matrix
  5198. */
  5199. static Scaling(x: number, y: number, z: number): Matrix;
  5200. /**
  5201. * Creates a scaling matrix and stores it in a given matrix
  5202. * @param x defines the scale factor on X axis
  5203. * @param y defines the scale factor on Y axis
  5204. * @param z defines the scale factor on Z axis
  5205. * @param result defines the target matrix
  5206. */
  5207. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  5208. /**
  5209. * Creates a translation matrix
  5210. * @param x defines the translation on X axis
  5211. * @param y defines the translation on Y axis
  5212. * @param z defines the translationon Z axis
  5213. * @returns the new matrix
  5214. */
  5215. static Translation(x: number, y: number, z: number): Matrix;
  5216. /**
  5217. * Creates a translation matrix and stores it in a given matrix
  5218. * @param x defines the translation on X axis
  5219. * @param y defines the translation on Y axis
  5220. * @param z defines the translationon Z axis
  5221. * @param result defines the target matrix
  5222. */
  5223. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  5224. /**
  5225. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5226. * @param startValue defines the start value
  5227. * @param endValue defines the end value
  5228. * @param gradient defines the gradient factor
  5229. * @returns the new matrix
  5230. */
  5231. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5232. /**
  5233. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  5234. * @param startValue defines the start value
  5235. * @param endValue defines the end value
  5236. * @param gradient defines the gradient factor
  5237. * @param result defines the Matrix object where to store data
  5238. */
  5239. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5240. /**
  5241. * Builds a new matrix whose values are computed by:
  5242. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5243. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5244. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5245. * @param startValue defines the first matrix
  5246. * @param endValue defines the second matrix
  5247. * @param gradient defines the gradient between the two matrices
  5248. * @returns the new matrix
  5249. */
  5250. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  5251. /**
  5252. * Update a matrix to values which are computed by:
  5253. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  5254. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  5255. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  5256. * @param startValue defines the first matrix
  5257. * @param endValue defines the second matrix
  5258. * @param gradient defines the gradient between the two matrices
  5259. * @param result defines the target matrix
  5260. */
  5261. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  5262. /**
  5263. * 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"
  5264. * This function works in left handed mode
  5265. * @param eye defines the final position of the entity
  5266. * @param target defines where the entity should look at
  5267. * @param up defines the up vector for the entity
  5268. * @returns the new matrix
  5269. */
  5270. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5271. /**
  5272. * 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".
  5273. * This function works in left handed mode
  5274. * @param eye defines the final position of the entity
  5275. * @param target defines where the entity should look at
  5276. * @param up defines the up vector for the entity
  5277. * @param result defines the target matrix
  5278. */
  5279. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5280. /**
  5281. * 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"
  5282. * This function works in right handed mode
  5283. * @param eye defines the final position of the entity
  5284. * @param target defines where the entity should look at
  5285. * @param up defines the up vector for the entity
  5286. * @returns the new matrix
  5287. */
  5288. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  5289. /**
  5290. * 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".
  5291. * This function works in right handed mode
  5292. * @param eye defines the final position of the entity
  5293. * @param target defines where the entity should look at
  5294. * @param up defines the up vector for the entity
  5295. * @param result defines the target matrix
  5296. */
  5297. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  5298. /**
  5299. * Create a left-handed orthographic projection matrix
  5300. * @param width defines the viewport width
  5301. * @param height defines the viewport height
  5302. * @param znear defines the near clip plane
  5303. * @param zfar defines the far clip plane
  5304. * @returns a new matrix as a left-handed orthographic projection matrix
  5305. */
  5306. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5307. /**
  5308. * Store a left-handed orthographic projection to a given matrix
  5309. * @param width defines the viewport width
  5310. * @param height defines the viewport height
  5311. * @param znear defines the near clip plane
  5312. * @param zfar defines the far clip plane
  5313. * @param result defines the target matrix
  5314. */
  5315. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  5316. /**
  5317. * Create a left-handed orthographic projection matrix
  5318. * @param left defines the viewport left coordinate
  5319. * @param right defines the viewport right coordinate
  5320. * @param bottom defines the viewport bottom coordinate
  5321. * @param top defines the viewport top coordinate
  5322. * @param znear defines the near clip plane
  5323. * @param zfar defines the far clip plane
  5324. * @returns a new matrix as a left-handed orthographic projection matrix
  5325. */
  5326. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5327. /**
  5328. * Stores a left-handed orthographic projection into a given matrix
  5329. * @param left defines the viewport left coordinate
  5330. * @param right defines the viewport right coordinate
  5331. * @param bottom defines the viewport bottom coordinate
  5332. * @param top defines the viewport top coordinate
  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 OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5338. /**
  5339. * Creates a right-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 right-handed orthographic projection matrix
  5347. */
  5348. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  5349. /**
  5350. * Stores a right-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 OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  5360. /**
  5361. * Creates a left-handed perspective projection matrix
  5362. * @param width defines the viewport width
  5363. * @param height defines the viewport height
  5364. * @param znear defines the near clip plane
  5365. * @param zfar defines the far clip plane
  5366. * @returns a new matrix as a left-handed perspective projection matrix
  5367. */
  5368. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  5369. /**
  5370. * Creates a left-handed perspective projection matrix
  5371. * @param fov defines the horizontal field of view
  5372. * @param aspect defines the aspect ratio
  5373. * @param znear defines the near clip plane
  5374. * @param zfar defines the far clip plane
  5375. * @returns a new matrix as a left-handed perspective projection matrix
  5376. */
  5377. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5378. /**
  5379. * Stores a left-handed perspective projection into a given matrix
  5380. * @param fov defines the horizontal field of view
  5381. * @param aspect defines the aspect ratio
  5382. * @param znear defines the near clip plane
  5383. * @param zfar defines the far clip plane
  5384. * @param result defines the target matrix
  5385. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5386. */
  5387. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5388. /**
  5389. * Stores a left-handed perspective projection into a given matrix with depth reversed
  5390. * @param fov defines the horizontal field of view
  5391. * @param aspect defines the aspect ratio
  5392. * @param znear defines the near clip plane
  5393. * @param zfar not used as infinity is used as far clip
  5394. * @param result defines the target matrix
  5395. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5396. */
  5397. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5398. /**
  5399. * Creates a right-handed perspective projection matrix
  5400. * @param fov defines the horizontal field of view
  5401. * @param aspect defines the aspect ratio
  5402. * @param znear defines the near clip plane
  5403. * @param zfar defines the far clip plane
  5404. * @returns a new matrix as a right-handed perspective projection matrix
  5405. */
  5406. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  5407. /**
  5408. * Stores a right-handed perspective projection into a given matrix
  5409. * @param fov defines the horizontal field of view
  5410. * @param aspect defines the aspect ratio
  5411. * @param znear defines the near clip plane
  5412. * @param zfar defines the far clip plane
  5413. * @param result defines the target matrix
  5414. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5415. */
  5416. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5417. /**
  5418. * Stores a right-handed perspective projection into a given matrix
  5419. * @param fov defines the horizontal field of view
  5420. * @param aspect defines the aspect ratio
  5421. * @param znear defines the near clip plane
  5422. * @param zfar not used as infinity is used as far clip
  5423. * @param result defines the target matrix
  5424. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  5425. */
  5426. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  5427. /**
  5428. * Stores a perspective projection for WebVR info a given matrix
  5429. * @param fov defines the field of view
  5430. * @param znear defines the near clip plane
  5431. * @param zfar defines the far clip plane
  5432. * @param result defines the target matrix
  5433. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  5434. */
  5435. static PerspectiveFovWebVRToRef(fov: {
  5436. upDegrees: number;
  5437. downDegrees: number;
  5438. leftDegrees: number;
  5439. rightDegrees: number;
  5440. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  5441. /**
  5442. * Computes a complete transformation matrix
  5443. * @param viewport defines the viewport to use
  5444. * @param world defines the world matrix
  5445. * @param view defines the view matrix
  5446. * @param projection defines the projection matrix
  5447. * @param zmin defines the near clip plane
  5448. * @param zmax defines the far clip plane
  5449. * @returns the transformation matrix
  5450. */
  5451. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  5452. /**
  5453. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  5454. * @param matrix defines the matrix to use
  5455. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  5456. */
  5457. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5458. /**
  5459. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  5460. * @param matrix defines the matrix to use
  5461. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  5462. */
  5463. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  5464. /**
  5465. * Compute the transpose of a given matrix
  5466. * @param matrix defines the matrix to transpose
  5467. * @returns the new matrix
  5468. */
  5469. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  5470. /**
  5471. * Compute the transpose of a matrix and store it in a target matrix
  5472. * @param matrix defines the matrix to transpose
  5473. * @param result defines the target matrix
  5474. */
  5475. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  5476. /**
  5477. * Computes a reflection matrix from a plane
  5478. * @param plane defines the reflection plane
  5479. * @returns a new matrix
  5480. */
  5481. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  5482. /**
  5483. * Computes a reflection matrix from a plane
  5484. * @param plane defines the reflection plane
  5485. * @param result defines the target matrix
  5486. */
  5487. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  5488. /**
  5489. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  5490. * @param xaxis defines the value of the 1st axis
  5491. * @param yaxis defines the value of the 2nd axis
  5492. * @param zaxis defines the value of the 3rd axis
  5493. * @param result defines the target matrix
  5494. */
  5495. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  5496. /**
  5497. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  5498. * @param quat defines the quaternion to use
  5499. * @param result defines the target matrix
  5500. */
  5501. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  5502. }
  5503. /**
  5504. * @hidden
  5505. */
  5506. export class TmpVectors {
  5507. static Vector2: Vector2[];
  5508. static Vector3: Vector3[];
  5509. static Vector4: Vector4[];
  5510. static Quaternion: Quaternion[];
  5511. static Matrix: Matrix[];
  5512. }
  5513. }
  5514. declare module BABYLON {
  5515. /**
  5516. * Defines potential orientation for back face culling
  5517. */
  5518. export enum Orientation {
  5519. /**
  5520. * Clockwise
  5521. */
  5522. CW = 0,
  5523. /** Counter clockwise */
  5524. CCW = 1
  5525. }
  5526. /** Class used to represent a Bezier curve */
  5527. export class BezierCurve {
  5528. /**
  5529. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5530. * @param t defines the time
  5531. * @param x1 defines the left coordinate on X axis
  5532. * @param y1 defines the left coordinate on Y axis
  5533. * @param x2 defines the right coordinate on X axis
  5534. * @param y2 defines the right coordinate on Y axis
  5535. * @returns the interpolated value
  5536. */
  5537. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5538. }
  5539. /**
  5540. * Defines angle representation
  5541. */
  5542. export class Angle {
  5543. private _radians;
  5544. /**
  5545. * Creates an Angle object of "radians" radians (float).
  5546. * @param radians the angle in radians
  5547. */
  5548. constructor(radians: number);
  5549. /**
  5550. * Get value in degrees
  5551. * @returns the Angle value in degrees (float)
  5552. */
  5553. degrees(): number;
  5554. /**
  5555. * Get value in radians
  5556. * @returns the Angle value in radians (float)
  5557. */
  5558. radians(): number;
  5559. /**
  5560. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  5561. * @param a defines first point as the origin
  5562. * @param b defines point
  5563. * @returns a new Angle
  5564. */
  5565. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5566. /**
  5567. * Gets a new Angle object from the given float in radians
  5568. * @param radians defines the angle value in radians
  5569. * @returns a new Angle
  5570. */
  5571. static FromRadians(radians: number): Angle;
  5572. /**
  5573. * Gets a new Angle object from the given float in degrees
  5574. * @param degrees defines the angle value in degrees
  5575. * @returns a new Angle
  5576. */
  5577. static FromDegrees(degrees: number): Angle;
  5578. }
  5579. /**
  5580. * This represents an arc in a 2d space.
  5581. */
  5582. export class Arc2 {
  5583. /** Defines the start point of the arc */
  5584. startPoint: Vector2;
  5585. /** Defines the mid point of the arc */
  5586. midPoint: Vector2;
  5587. /** Defines the end point of the arc */
  5588. endPoint: Vector2;
  5589. /**
  5590. * Defines the center point of the arc.
  5591. */
  5592. centerPoint: Vector2;
  5593. /**
  5594. * Defines the radius of the arc.
  5595. */
  5596. radius: number;
  5597. /**
  5598. * Defines the angle of the arc (from mid point to end point).
  5599. */
  5600. angle: Angle;
  5601. /**
  5602. * Defines the start angle of the arc (from start point to middle point).
  5603. */
  5604. startAngle: Angle;
  5605. /**
  5606. * Defines the orientation of the arc (clock wise/counter clock wise).
  5607. */
  5608. orientation: Orientation;
  5609. /**
  5610. * Creates an Arc object from the three given points : start, middle and end.
  5611. * @param startPoint Defines the start point of the arc
  5612. * @param midPoint Defines the midlle point of the arc
  5613. * @param endPoint Defines the end point of the arc
  5614. */
  5615. constructor(
  5616. /** Defines the start point of the arc */
  5617. startPoint: Vector2,
  5618. /** Defines the mid point of the arc */
  5619. midPoint: Vector2,
  5620. /** Defines the end point of the arc */
  5621. endPoint: Vector2);
  5622. }
  5623. /**
  5624. * Represents a 2D path made up of multiple 2D points
  5625. */
  5626. export class Path2 {
  5627. private _points;
  5628. private _length;
  5629. /**
  5630. * If the path start and end point are the same
  5631. */
  5632. closed: boolean;
  5633. /**
  5634. * Creates a Path2 object from the starting 2D coordinates x and y.
  5635. * @param x the starting points x value
  5636. * @param y the starting points y value
  5637. */
  5638. constructor(x: number, y: number);
  5639. /**
  5640. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5641. * @param x the added points x value
  5642. * @param y the added points y value
  5643. * @returns the updated Path2.
  5644. */
  5645. addLineTo(x: number, y: number): Path2;
  5646. /**
  5647. * 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.
  5648. * @param midX middle point x value
  5649. * @param midY middle point y value
  5650. * @param endX end point x value
  5651. * @param endY end point y value
  5652. * @param numberOfSegments (default: 36)
  5653. * @returns the updated Path2.
  5654. */
  5655. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5656. /**
  5657. * Closes the Path2.
  5658. * @returns the Path2.
  5659. */
  5660. close(): Path2;
  5661. /**
  5662. * Gets the sum of the distance between each sequential point in the path
  5663. * @returns the Path2 total length (float).
  5664. */
  5665. length(): number;
  5666. /**
  5667. * Gets the points which construct the path
  5668. * @returns the Path2 internal array of points.
  5669. */
  5670. getPoints(): Vector2[];
  5671. /**
  5672. * Retreives the point at the distance aways from the starting point
  5673. * @param normalizedLengthPosition the length along the path to retreive the point from
  5674. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5675. */
  5676. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5677. /**
  5678. * Creates a new path starting from an x and y position
  5679. * @param x starting x value
  5680. * @param y starting y value
  5681. * @returns a new Path2 starting at the coordinates (x, y).
  5682. */
  5683. static StartingAt(x: number, y: number): Path2;
  5684. }
  5685. /**
  5686. * Represents a 3D path made up of multiple 3D points
  5687. */
  5688. export class Path3D {
  5689. /**
  5690. * an array of Vector3, the curve axis of the Path3D
  5691. */
  5692. path: Vector3[];
  5693. private _curve;
  5694. private _distances;
  5695. private _tangents;
  5696. private _normals;
  5697. private _binormals;
  5698. private _raw;
  5699. private _alignTangentsWithPath;
  5700. private readonly _pointAtData;
  5701. /**
  5702. * new Path3D(path, normal, raw)
  5703. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5704. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5705. * @param path an array of Vector3, the curve axis of the Path3D
  5706. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5707. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5708. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5709. */
  5710. constructor(
  5711. /**
  5712. * an array of Vector3, the curve axis of the Path3D
  5713. */
  5714. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5715. /**
  5716. * Returns the Path3D array of successive Vector3 designing its curve.
  5717. * @returns the Path3D array of successive Vector3 designing its curve.
  5718. */
  5719. getCurve(): Vector3[];
  5720. /**
  5721. * Returns the Path3D array of successive Vector3 designing its curve.
  5722. * @returns the Path3D array of successive Vector3 designing its curve.
  5723. */
  5724. getPoints(): Vector3[];
  5725. /**
  5726. * @returns the computed length (float) of the path.
  5727. */
  5728. length(): number;
  5729. /**
  5730. * Returns an array populated with tangent vectors on each Path3D curve point.
  5731. * @returns an array populated with tangent vectors on each Path3D curve point.
  5732. */
  5733. getTangents(): Vector3[];
  5734. /**
  5735. * Returns an array populated with normal vectors on each Path3D curve point.
  5736. * @returns an array populated with normal vectors on each Path3D curve point.
  5737. */
  5738. getNormals(): Vector3[];
  5739. /**
  5740. * Returns an array populated with binormal vectors on each Path3D curve point.
  5741. * @returns an array populated with binormal vectors on each Path3D curve point.
  5742. */
  5743. getBinormals(): Vector3[];
  5744. /**
  5745. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5746. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5747. */
  5748. getDistances(): number[];
  5749. /**
  5750. * Returns an interpolated point along this path
  5751. * @param position the position of the point along this path, from 0.0 to 1.0
  5752. * @returns a new Vector3 as the point
  5753. */
  5754. getPointAt(position: number): Vector3;
  5755. /**
  5756. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5757. * @param position the position of the point along this path, from 0.0 to 1.0
  5758. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5759. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5760. */
  5761. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5762. /**
  5763. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5764. * @param position the position of the point along this path, from 0.0 to 1.0
  5765. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5766. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5767. */
  5768. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5769. /**
  5770. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5771. * @param position the position of the point along this path, from 0.0 to 1.0
  5772. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5773. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5774. */
  5775. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5776. /**
  5777. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5778. * @param position the position of the point along this path, from 0.0 to 1.0
  5779. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5780. */
  5781. getDistanceAt(position: number): number;
  5782. /**
  5783. * Returns the array index of the previous point of an interpolated point along this path
  5784. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5785. * @returns the array index
  5786. */
  5787. getPreviousPointIndexAt(position: number): number;
  5788. /**
  5789. * 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)
  5790. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5791. * @returns the sub position
  5792. */
  5793. getSubPositionAt(position: number): number;
  5794. /**
  5795. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5796. * @param target the vector of which to get the closest position to
  5797. * @returns the position of the closest virtual point on this path to the target vector
  5798. */
  5799. getClosestPositionTo(target: Vector3): number;
  5800. /**
  5801. * Returns a sub path (slice) of this path
  5802. * @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
  5803. * @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
  5804. * @returns a sub path (slice) of this path
  5805. */
  5806. slice(start?: number, end?: number): Path3D;
  5807. /**
  5808. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5809. * @param path path which all values are copied into the curves points
  5810. * @param firstNormal which should be projected onto the curve
  5811. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5812. * @returns the same object updated.
  5813. */
  5814. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5815. private _compute;
  5816. private _getFirstNonNullVector;
  5817. private _getLastNonNullVector;
  5818. private _normalVector;
  5819. /**
  5820. * Updates the point at data for an interpolated point along this curve
  5821. * @param position the position of the point along this curve, from 0.0 to 1.0
  5822. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5823. * @returns the (updated) point at data
  5824. */
  5825. private _updatePointAtData;
  5826. /**
  5827. * Updates the point at data from the specified parameters
  5828. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5829. * @param point the interpolated point
  5830. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5831. */
  5832. private _setPointAtData;
  5833. /**
  5834. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5835. */
  5836. private _updateInterpolationMatrix;
  5837. }
  5838. /**
  5839. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5840. * A Curve3 is designed from a series of successive Vector3.
  5841. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5842. */
  5843. export class Curve3 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5848. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5849. * @param v1 (Vector3) the control point
  5850. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5851. * @param nbPoints (integer) the wanted number of points in the curve
  5852. * @returns the created Curve3
  5853. */
  5854. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5855. /**
  5856. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5857. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5858. * @param v1 (Vector3) the first control point
  5859. * @param v2 (Vector3) the second control point
  5860. * @param v3 (Vector3) the end point of the Cubic Bezier
  5861. * @param nbPoints (integer) the wanted number of points in the curve
  5862. * @returns the created Curve3
  5863. */
  5864. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5865. /**
  5866. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5867. * @param p1 (Vector3) the origin point of the Hermite Spline
  5868. * @param t1 (Vector3) the tangent vector at the origin point
  5869. * @param p2 (Vector3) the end point of the Hermite Spline
  5870. * @param t2 (Vector3) the tangent vector at the end point
  5871. * @param nbPoints (integer) the wanted number of points in the curve
  5872. * @returns the created Curve3
  5873. */
  5874. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5875. /**
  5876. * Returns a Curve3 object along a CatmullRom Spline curve :
  5877. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5878. * @param nbPoints (integer) the wanted number of points between each curve control points
  5879. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5880. * @returns the created Curve3
  5881. */
  5882. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5883. /**
  5884. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5885. * A Curve3 is designed from a series of successive Vector3.
  5886. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5887. * @param points points which make up the curve
  5888. */
  5889. constructor(points: Vector3[]);
  5890. /**
  5891. * @returns the Curve3 stored array of successive Vector3
  5892. */
  5893. getPoints(): Vector3[];
  5894. /**
  5895. * @returns the computed length (float) of the curve.
  5896. */
  5897. length(): number;
  5898. /**
  5899. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5900. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5901. * curveA and curveB keep unchanged.
  5902. * @param curve the curve to continue from this curve
  5903. * @returns the newly constructed curve
  5904. */
  5905. continue(curve: DeepImmutable<Curve3>): Curve3;
  5906. private _computeLength;
  5907. }
  5908. }
  5909. declare module BABYLON {
  5910. /**
  5911. * This represents the main contract an easing function should follow.
  5912. * Easing functions are used throughout the animation system.
  5913. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5914. */
  5915. export interface IEasingFunction {
  5916. /**
  5917. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5918. * of the easing function.
  5919. * The link below provides some of the most common examples of easing functions.
  5920. * @see https://easings.net/
  5921. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5922. * @returns the corresponding value on the curve defined by the easing function
  5923. */
  5924. ease(gradient: number): number;
  5925. }
  5926. /**
  5927. * Base class used for every default easing function.
  5928. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5929. */
  5930. export class EasingFunction implements IEasingFunction {
  5931. /**
  5932. * Interpolation follows the mathematical formula associated with the easing function.
  5933. */
  5934. static readonly EASINGMODE_EASEIN: number;
  5935. /**
  5936. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5937. */
  5938. static readonly EASINGMODE_EASEOUT: number;
  5939. /**
  5940. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5941. */
  5942. static readonly EASINGMODE_EASEINOUT: number;
  5943. private _easingMode;
  5944. /**
  5945. * Sets the easing mode of the current function.
  5946. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5947. */
  5948. setEasingMode(easingMode: number): void;
  5949. /**
  5950. * Gets the current easing mode.
  5951. * @returns the easing mode
  5952. */
  5953. getEasingMode(): number;
  5954. /**
  5955. * @hidden
  5956. */
  5957. easeInCore(gradient: number): number;
  5958. /**
  5959. * Given an input gradient between 0 and 1, this returns the corresponding value
  5960. * of the easing function.
  5961. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5962. * @returns the corresponding value on the curve defined by the easing function
  5963. */
  5964. ease(gradient: number): number;
  5965. }
  5966. /**
  5967. * Easing function with a circle shape (see link below).
  5968. * @see https://easings.net/#easeInCirc
  5969. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5970. */
  5971. export class CircleEase extends EasingFunction implements IEasingFunction {
  5972. /** @hidden */
  5973. easeInCore(gradient: number): number;
  5974. }
  5975. /**
  5976. * Easing function with a ease back shape (see link below).
  5977. * @see https://easings.net/#easeInBack
  5978. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5979. */
  5980. export class BackEase extends EasingFunction implements IEasingFunction {
  5981. /** Defines the amplitude of the function */
  5982. amplitude: number;
  5983. /**
  5984. * Instantiates a back ease easing
  5985. * @see https://easings.net/#easeInBack
  5986. * @param amplitude Defines the amplitude of the function
  5987. */
  5988. constructor(
  5989. /** Defines the amplitude of the function */
  5990. amplitude?: number);
  5991. /** @hidden */
  5992. easeInCore(gradient: number): number;
  5993. }
  5994. /**
  5995. * Easing function with a bouncing shape (see link below).
  5996. * @see https://easings.net/#easeInBounce
  5997. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5998. */
  5999. export class BounceEase extends EasingFunction implements IEasingFunction {
  6000. /** Defines the number of bounces */
  6001. bounces: number;
  6002. /** Defines the amplitude of the bounce */
  6003. bounciness: number;
  6004. /**
  6005. * Instantiates a bounce easing
  6006. * @see https://easings.net/#easeInBounce
  6007. * @param bounces Defines the number of bounces
  6008. * @param bounciness Defines the amplitude of the bounce
  6009. */
  6010. constructor(
  6011. /** Defines the number of bounces */
  6012. bounces?: number,
  6013. /** Defines the amplitude of the bounce */
  6014. bounciness?: number);
  6015. /** @hidden */
  6016. easeInCore(gradient: number): number;
  6017. }
  6018. /**
  6019. * Easing function with a power of 3 shape (see link below).
  6020. * @see https://easings.net/#easeInCubic
  6021. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6022. */
  6023. export class CubicEase extends EasingFunction implements IEasingFunction {
  6024. /** @hidden */
  6025. easeInCore(gradient: number): number;
  6026. }
  6027. /**
  6028. * Easing function with an elastic shape (see link below).
  6029. * @see https://easings.net/#easeInElastic
  6030. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6031. */
  6032. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6033. /** Defines the number of oscillations*/
  6034. oscillations: number;
  6035. /** Defines the amplitude of the oscillations*/
  6036. springiness: number;
  6037. /**
  6038. * Instantiates an elastic easing function
  6039. * @see https://easings.net/#easeInElastic
  6040. * @param oscillations Defines the number of oscillations
  6041. * @param springiness Defines the amplitude of the oscillations
  6042. */
  6043. constructor(
  6044. /** Defines the number of oscillations*/
  6045. oscillations?: number,
  6046. /** Defines the amplitude of the oscillations*/
  6047. springiness?: number);
  6048. /** @hidden */
  6049. easeInCore(gradient: number): number;
  6050. }
  6051. /**
  6052. * Easing function with an exponential shape (see link below).
  6053. * @see https://easings.net/#easeInExpo
  6054. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6055. */
  6056. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6057. /** Defines the exponent of the function */
  6058. exponent: number;
  6059. /**
  6060. * Instantiates an exponential easing function
  6061. * @see https://easings.net/#easeInExpo
  6062. * @param exponent Defines the exponent of the function
  6063. */
  6064. constructor(
  6065. /** Defines the exponent of the function */
  6066. exponent?: number);
  6067. /** @hidden */
  6068. easeInCore(gradient: number): number;
  6069. }
  6070. /**
  6071. * Easing function with a power shape (see link below).
  6072. * @see https://easings.net/#easeInQuad
  6073. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6074. */
  6075. export class PowerEase extends EasingFunction implements IEasingFunction {
  6076. /** Defines the power of the function */
  6077. power: number;
  6078. /**
  6079. * Instantiates an power base easing function
  6080. * @see https://easings.net/#easeInQuad
  6081. * @param power Defines the power of the function
  6082. */
  6083. constructor(
  6084. /** Defines the power of the function */
  6085. power?: number);
  6086. /** @hidden */
  6087. easeInCore(gradient: number): number;
  6088. }
  6089. /**
  6090. * Easing function with a power of 2 shape (see link below).
  6091. * @see https://easings.net/#easeInQuad
  6092. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6093. */
  6094. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6095. /** @hidden */
  6096. easeInCore(gradient: number): number;
  6097. }
  6098. /**
  6099. * Easing function with a power of 4 shape (see link below).
  6100. * @see https://easings.net/#easeInQuart
  6101. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6102. */
  6103. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6104. /** @hidden */
  6105. easeInCore(gradient: number): number;
  6106. }
  6107. /**
  6108. * Easing function with a power of 5 shape (see link below).
  6109. * @see https://easings.net/#easeInQuint
  6110. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6111. */
  6112. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6113. /** @hidden */
  6114. easeInCore(gradient: number): number;
  6115. }
  6116. /**
  6117. * Easing function with a sin shape (see link below).
  6118. * @see https://easings.net/#easeInSine
  6119. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6120. */
  6121. export class SineEase extends EasingFunction implements IEasingFunction {
  6122. /** @hidden */
  6123. easeInCore(gradient: number): number;
  6124. }
  6125. /**
  6126. * Easing function with a bezier shape (see link below).
  6127. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6128. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  6129. */
  6130. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6131. /** Defines the x component of the start tangent in the bezier curve */
  6132. x1: number;
  6133. /** Defines the y component of the start tangent in the bezier curve */
  6134. y1: number;
  6135. /** Defines the x component of the end tangent in the bezier curve */
  6136. x2: number;
  6137. /** Defines the y component of the end tangent in the bezier curve */
  6138. y2: number;
  6139. /**
  6140. * Instantiates a bezier function
  6141. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6142. * @param x1 Defines the x component of the start tangent in the bezier curve
  6143. * @param y1 Defines the y component of the start tangent in the bezier curve
  6144. * @param x2 Defines the x component of the end tangent in the bezier curve
  6145. * @param y2 Defines the y component of the end tangent in the bezier curve
  6146. */
  6147. constructor(
  6148. /** Defines the x component of the start tangent in the bezier curve */
  6149. x1?: number,
  6150. /** Defines the y component of the start tangent in the bezier curve */
  6151. y1?: number,
  6152. /** Defines the x component of the end tangent in the bezier curve */
  6153. x2?: number,
  6154. /** Defines the y component of the end tangent in the bezier curve */
  6155. y2?: number);
  6156. /** @hidden */
  6157. easeInCore(gradient: number): number;
  6158. }
  6159. }
  6160. declare module BABYLON {
  6161. /**
  6162. * Class used to hold a RGB color
  6163. */
  6164. export class Color3 {
  6165. /**
  6166. * Defines the red component (between 0 and 1, default is 0)
  6167. */
  6168. r: number;
  6169. /**
  6170. * Defines the green component (between 0 and 1, default is 0)
  6171. */
  6172. g: number;
  6173. /**
  6174. * Defines the blue component (between 0 and 1, default is 0)
  6175. */
  6176. b: number;
  6177. /**
  6178. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  6179. * @param r defines the red component (between 0 and 1, default is 0)
  6180. * @param g defines the green component (between 0 and 1, default is 0)
  6181. * @param b defines the blue component (between 0 and 1, default is 0)
  6182. */
  6183. constructor(
  6184. /**
  6185. * Defines the red component (between 0 and 1, default is 0)
  6186. */
  6187. r?: number,
  6188. /**
  6189. * Defines the green component (between 0 and 1, default is 0)
  6190. */
  6191. g?: number,
  6192. /**
  6193. * Defines the blue component (between 0 and 1, default is 0)
  6194. */
  6195. b?: number);
  6196. /**
  6197. * Creates a string with the Color3 current values
  6198. * @returns the string representation of the Color3 object
  6199. */
  6200. toString(): string;
  6201. /**
  6202. * Returns the string "Color3"
  6203. * @returns "Color3"
  6204. */
  6205. getClassName(): string;
  6206. /**
  6207. * Compute the Color3 hash code
  6208. * @returns an unique number that can be used to hash Color3 objects
  6209. */
  6210. getHashCode(): number;
  6211. /**
  6212. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  6213. * @param array defines the array where to store the r,g,b components
  6214. * @param index defines an optional index in the target array to define where to start storing values
  6215. * @returns the current Color3 object
  6216. */
  6217. toArray(array: FloatArray, index?: number): Color3;
  6218. /**
  6219. * Update the current color with values stored in an array from the starting index of the given array
  6220. * @param array defines the source array
  6221. * @param offset defines an offset in the source array
  6222. * @returns the current Color3 object
  6223. */
  6224. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6225. /**
  6226. * Returns a new Color4 object from the current Color3 and the given alpha
  6227. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  6228. * @returns a new Color4 object
  6229. */
  6230. toColor4(alpha?: number): Color4;
  6231. /**
  6232. * Returns a new array populated with 3 numeric elements : red, green and blue values
  6233. * @returns the new array
  6234. */
  6235. asArray(): number[];
  6236. /**
  6237. * Returns the luminance value
  6238. * @returns a float value
  6239. */
  6240. toLuminance(): number;
  6241. /**
  6242. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  6243. * @param otherColor defines the second operand
  6244. * @returns the new Color3 object
  6245. */
  6246. multiply(otherColor: DeepImmutable<Color3>): Color3;
  6247. /**
  6248. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  6249. * @param otherColor defines the second operand
  6250. * @param result defines the Color3 object where to store the result
  6251. * @returns the current Color3
  6252. */
  6253. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6254. /**
  6255. * Determines equality between Color3 objects
  6256. * @param otherColor defines the second operand
  6257. * @returns true if the rgb values are equal to the given ones
  6258. */
  6259. equals(otherColor: DeepImmutable<Color3>): boolean;
  6260. /**
  6261. * Determines equality between the current Color3 object and a set of r,b,g values
  6262. * @param r defines the red component to check
  6263. * @param g defines the green component to check
  6264. * @param b defines the blue component to check
  6265. * @returns true if the rgb values are equal to the given ones
  6266. */
  6267. equalsFloats(r: number, g: number, b: number): boolean;
  6268. /**
  6269. * Multiplies in place each rgb value by scale
  6270. * @param scale defines the scaling factor
  6271. * @returns the updated Color3
  6272. */
  6273. scale(scale: number): Color3;
  6274. /**
  6275. * Multiplies the rgb values by scale and stores the result into "result"
  6276. * @param scale defines the scaling factor
  6277. * @param result defines the Color3 object where to store the result
  6278. * @returns the unmodified current Color3
  6279. */
  6280. scaleToRef(scale: number, result: Color3): Color3;
  6281. /**
  6282. * Scale the current Color3 values by a factor and add the result to a given Color3
  6283. * @param scale defines the scale factor
  6284. * @param result defines color to store the result into
  6285. * @returns the unmodified current Color3
  6286. */
  6287. scaleAndAddToRef(scale: number, result: Color3): Color3;
  6288. /**
  6289. * Clamps the rgb values by the min and max values and stores the result into "result"
  6290. * @param min defines minimum clamping value (default is 0)
  6291. * @param max defines maximum clamping value (default is 1)
  6292. * @param result defines color to store the result into
  6293. * @returns the original Color3
  6294. */
  6295. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  6296. /**
  6297. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  6298. * @param otherColor defines the second operand
  6299. * @returns the new Color3
  6300. */
  6301. add(otherColor: DeepImmutable<Color3>): Color3;
  6302. /**
  6303. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  6304. * @param otherColor defines the second operand
  6305. * @param result defines Color3 object to store the result into
  6306. * @returns the unmodified current Color3
  6307. */
  6308. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6309. /**
  6310. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  6311. * @param otherColor defines the second operand
  6312. * @returns the new Color3
  6313. */
  6314. subtract(otherColor: DeepImmutable<Color3>): Color3;
  6315. /**
  6316. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  6317. * @param otherColor defines the second operand
  6318. * @param result defines Color3 object to store the result into
  6319. * @returns the unmodified current Color3
  6320. */
  6321. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  6322. /**
  6323. * Copy the current object
  6324. * @returns a new Color3 copied the current one
  6325. */
  6326. clone(): Color3;
  6327. /**
  6328. * Copies the rgb values from the source in the current Color3
  6329. * @param source defines the source Color3 object
  6330. * @returns the updated Color3 object
  6331. */
  6332. copyFrom(source: DeepImmutable<Color3>): Color3;
  6333. /**
  6334. * Updates the Color3 rgb values from the given floats
  6335. * @param r defines the red component to read from
  6336. * @param g defines the green component to read from
  6337. * @param b defines the blue component to read from
  6338. * @returns the current Color3 object
  6339. */
  6340. copyFromFloats(r: number, g: number, b: number): Color3;
  6341. /**
  6342. * Updates the Color3 rgb values from the given floats
  6343. * @param r defines the red component to read from
  6344. * @param g defines the green component to read from
  6345. * @param b defines the blue component to read from
  6346. * @returns the current Color3 object
  6347. */
  6348. set(r: number, g: number, b: number): Color3;
  6349. /**
  6350. * Compute the Color3 hexadecimal code as a string
  6351. * @returns a string containing the hexadecimal representation of the Color3 object
  6352. */
  6353. toHexString(): string;
  6354. /**
  6355. * Computes a new Color3 converted from the current one to linear space
  6356. * @returns a new Color3 object
  6357. */
  6358. toLinearSpace(): Color3;
  6359. /**
  6360. * Converts current color in rgb space to HSV values
  6361. * @returns a new color3 representing the HSV values
  6362. */
  6363. toHSV(): Color3;
  6364. /**
  6365. * Converts current color in rgb space to HSV values
  6366. * @param result defines the Color3 where to store the HSV values
  6367. */
  6368. toHSVToRef(result: Color3): void;
  6369. /**
  6370. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  6371. * @param convertedColor defines the Color3 object where to store the linear space version
  6372. * @returns the unmodified Color3
  6373. */
  6374. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6375. /**
  6376. * Computes a new Color3 converted from the current one to gamma space
  6377. * @returns a new Color3 object
  6378. */
  6379. toGammaSpace(): Color3;
  6380. /**
  6381. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  6382. * @param convertedColor defines the Color3 object where to store the gamma space version
  6383. * @returns the unmodified Color3
  6384. */
  6385. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6386. private static _BlackReadOnly;
  6387. /**
  6388. * Convert Hue, saturation and value to a Color3 (RGB)
  6389. * @param hue defines the hue
  6390. * @param saturation defines the saturation
  6391. * @param value defines the value
  6392. * @param result defines the Color3 where to store the RGB values
  6393. */
  6394. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  6395. /**
  6396. * Creates a new Color3 from the string containing valid hexadecimal values
  6397. * @param hex defines a string containing valid hexadecimal values
  6398. * @returns a new Color3 object
  6399. */
  6400. static FromHexString(hex: string): Color3;
  6401. /**
  6402. * Creates a new Color3 from the starting index of the given array
  6403. * @param array defines the source array
  6404. * @param offset defines an offset in the source array
  6405. * @returns a new Color3 object
  6406. */
  6407. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  6408. /**
  6409. * Creates a new Color3 from the starting index element of the given array
  6410. * @param array defines the source array to read from
  6411. * @param offset defines the offset in the source array
  6412. * @param result defines the target Color3 object
  6413. */
  6414. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  6415. /**
  6416. * Creates a new Color3 from integer values (< 256)
  6417. * @param r defines the red component to read from (value between 0 and 255)
  6418. * @param g defines the green component to read from (value between 0 and 255)
  6419. * @param b defines the blue component to read from (value between 0 and 255)
  6420. * @returns a new Color3 object
  6421. */
  6422. static FromInts(r: number, g: number, b: number): Color3;
  6423. /**
  6424. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6425. * @param start defines the start Color3 value
  6426. * @param end defines the end Color3 value
  6427. * @param amount defines the gradient value between start and end
  6428. * @returns a new Color3 object
  6429. */
  6430. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  6431. /**
  6432. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  6433. * @param left defines the start value
  6434. * @param right defines the end value
  6435. * @param amount defines the gradient factor
  6436. * @param result defines the Color3 object where to store the result
  6437. */
  6438. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  6439. /**
  6440. * Returns a Color3 value containing a red color
  6441. * @returns a new Color3 object
  6442. */
  6443. static Red(): Color3;
  6444. /**
  6445. * Returns a Color3 value containing a green color
  6446. * @returns a new Color3 object
  6447. */
  6448. static Green(): Color3;
  6449. /**
  6450. * Returns a Color3 value containing a blue color
  6451. * @returns a new Color3 object
  6452. */
  6453. static Blue(): Color3;
  6454. /**
  6455. * Returns a Color3 value containing a black color
  6456. * @returns a new Color3 object
  6457. */
  6458. static Black(): Color3;
  6459. /**
  6460. * Gets a Color3 value containing a black color that must not be updated
  6461. */
  6462. static get BlackReadOnly(): DeepImmutable<Color3>;
  6463. /**
  6464. * Returns a Color3 value containing a white color
  6465. * @returns a new Color3 object
  6466. */
  6467. static White(): Color3;
  6468. /**
  6469. * Returns a Color3 value containing a purple color
  6470. * @returns a new Color3 object
  6471. */
  6472. static Purple(): Color3;
  6473. /**
  6474. * Returns a Color3 value containing a magenta color
  6475. * @returns a new Color3 object
  6476. */
  6477. static Magenta(): Color3;
  6478. /**
  6479. * Returns a Color3 value containing a yellow color
  6480. * @returns a new Color3 object
  6481. */
  6482. static Yellow(): Color3;
  6483. /**
  6484. * Returns a Color3 value containing a gray color
  6485. * @returns a new Color3 object
  6486. */
  6487. static Gray(): Color3;
  6488. /**
  6489. * Returns a Color3 value containing a teal color
  6490. * @returns a new Color3 object
  6491. */
  6492. static Teal(): Color3;
  6493. /**
  6494. * Returns a Color3 value containing a random color
  6495. * @returns a new Color3 object
  6496. */
  6497. static Random(): Color3;
  6498. }
  6499. /**
  6500. * Class used to hold a RBGA color
  6501. */
  6502. export class Color4 {
  6503. /**
  6504. * Defines the red component (between 0 and 1, default is 0)
  6505. */
  6506. r: number;
  6507. /**
  6508. * Defines the green component (between 0 and 1, default is 0)
  6509. */
  6510. g: number;
  6511. /**
  6512. * Defines the blue component (between 0 and 1, default is 0)
  6513. */
  6514. b: number;
  6515. /**
  6516. * Defines the alpha component (between 0 and 1, default is 1)
  6517. */
  6518. a: number;
  6519. /**
  6520. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  6521. * @param r defines the red component (between 0 and 1, default is 0)
  6522. * @param g defines the green component (between 0 and 1, default is 0)
  6523. * @param b defines the blue component (between 0 and 1, default is 0)
  6524. * @param a defines the alpha component (between 0 and 1, default is 1)
  6525. */
  6526. constructor(
  6527. /**
  6528. * Defines the red component (between 0 and 1, default is 0)
  6529. */
  6530. r?: number,
  6531. /**
  6532. * Defines the green component (between 0 and 1, default is 0)
  6533. */
  6534. g?: number,
  6535. /**
  6536. * Defines the blue component (between 0 and 1, default is 0)
  6537. */
  6538. b?: number,
  6539. /**
  6540. * Defines the alpha component (between 0 and 1, default is 1)
  6541. */
  6542. a?: number);
  6543. /**
  6544. * Adds in place the given Color4 values to the current Color4 object
  6545. * @param right defines the second operand
  6546. * @returns the current updated Color4 object
  6547. */
  6548. addInPlace(right: DeepImmutable<Color4>): Color4;
  6549. /**
  6550. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  6551. * @returns the new array
  6552. */
  6553. asArray(): number[];
  6554. /**
  6555. * Stores from the starting index in the given array the Color4 successive values
  6556. * @param array defines the array where to store the r,g,b components
  6557. * @param index defines an optional index in the target array to define where to start storing values
  6558. * @returns the current Color4 object
  6559. */
  6560. toArray(array: number[], index?: number): Color4;
  6561. /**
  6562. * Update the current color with values stored in an array from the starting index of the given array
  6563. * @param array defines the source array
  6564. * @param offset defines an offset in the source array
  6565. * @returns the current Color4 object
  6566. */
  6567. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6568. /**
  6569. * Determines equality between Color4 objects
  6570. * @param otherColor defines the second operand
  6571. * @returns true if the rgba values are equal to the given ones
  6572. */
  6573. equals(otherColor: DeepImmutable<Color4>): boolean;
  6574. /**
  6575. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  6576. * @param right defines the second operand
  6577. * @returns a new Color4 object
  6578. */
  6579. add(right: DeepImmutable<Color4>): Color4;
  6580. /**
  6581. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  6582. * @param right defines the second operand
  6583. * @returns a new Color4 object
  6584. */
  6585. subtract(right: DeepImmutable<Color4>): Color4;
  6586. /**
  6587. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  6588. * @param right defines the second operand
  6589. * @param result defines the Color4 object where to store the result
  6590. * @returns the current Color4 object
  6591. */
  6592. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  6593. /**
  6594. * Creates a new Color4 with the current Color4 values multiplied by scale
  6595. * @param scale defines the scaling factor to apply
  6596. * @returns a new Color4 object
  6597. */
  6598. scale(scale: number): Color4;
  6599. /**
  6600. * Multiplies the current Color4 values by scale and stores the result in "result"
  6601. * @param scale defines the scaling factor to apply
  6602. * @param result defines the Color4 object where to store the result
  6603. * @returns the current unmodified Color4
  6604. */
  6605. scaleToRef(scale: number, result: Color4): Color4;
  6606. /**
  6607. * Scale the current Color4 values by a factor and add the result to a given Color4
  6608. * @param scale defines the scale factor
  6609. * @param result defines the Color4 object where to store the result
  6610. * @returns the unmodified current Color4
  6611. */
  6612. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6613. /**
  6614. * Clamps the rgb values by the min and max values and stores the result into "result"
  6615. * @param min defines minimum clamping value (default is 0)
  6616. * @param max defines maximum clamping value (default is 1)
  6617. * @param result defines color to store the result into.
  6618. * @returns the cuurent Color4
  6619. */
  6620. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6621. /**
  6622. * Multipy an Color4 value by another and return a new Color4 object
  6623. * @param color defines the Color4 value to multiply by
  6624. * @returns a new Color4 object
  6625. */
  6626. multiply(color: Color4): Color4;
  6627. /**
  6628. * Multipy a Color4 value by another and push the result in a reference value
  6629. * @param color defines the Color4 value to multiply by
  6630. * @param result defines the Color4 to fill the result in
  6631. * @returns the result Color4
  6632. */
  6633. multiplyToRef(color: Color4, result: Color4): Color4;
  6634. /**
  6635. * Creates a string with the Color4 current values
  6636. * @returns the string representation of the Color4 object
  6637. */
  6638. toString(): string;
  6639. /**
  6640. * Returns the string "Color4"
  6641. * @returns "Color4"
  6642. */
  6643. getClassName(): string;
  6644. /**
  6645. * Compute the Color4 hash code
  6646. * @returns an unique number that can be used to hash Color4 objects
  6647. */
  6648. getHashCode(): number;
  6649. /**
  6650. * Creates a new Color4 copied from the current one
  6651. * @returns a new Color4 object
  6652. */
  6653. clone(): Color4;
  6654. /**
  6655. * Copies the given Color4 values into the current one
  6656. * @param source defines the source Color4 object
  6657. * @returns the current updated Color4 object
  6658. */
  6659. copyFrom(source: Color4): Color4;
  6660. /**
  6661. * Copies the given float values into the current one
  6662. * @param r defines the red component to read from
  6663. * @param g defines the green component to read from
  6664. * @param b defines the blue component to read from
  6665. * @param a defines the alpha component to read from
  6666. * @returns the current updated Color4 object
  6667. */
  6668. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6669. /**
  6670. * Copies the given float values into the current one
  6671. * @param r defines the red component to read from
  6672. * @param g defines the green component to read from
  6673. * @param b defines the blue component to read from
  6674. * @param a defines the alpha component to read from
  6675. * @returns the current updated Color4 object
  6676. */
  6677. set(r: number, g: number, b: number, a: number): Color4;
  6678. /**
  6679. * Compute the Color4 hexadecimal code as a string
  6680. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6681. * @returns a string containing the hexadecimal representation of the Color4 object
  6682. */
  6683. toHexString(returnAsColor3?: boolean): string;
  6684. /**
  6685. * Computes a new Color4 converted from the current one to linear space
  6686. * @returns a new Color4 object
  6687. */
  6688. toLinearSpace(): Color4;
  6689. /**
  6690. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6691. * @param convertedColor defines the Color4 object where to store the linear space version
  6692. * @returns the unmodified Color4
  6693. */
  6694. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6695. /**
  6696. * Computes a new Color4 converted from the current one to gamma space
  6697. * @returns a new Color4 object
  6698. */
  6699. toGammaSpace(): Color4;
  6700. /**
  6701. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6702. * @param convertedColor defines the Color4 object where to store the gamma space version
  6703. * @returns the unmodified Color4
  6704. */
  6705. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6706. /**
  6707. * Creates a new Color4 from the string containing valid hexadecimal values
  6708. * @param hex defines a string containing valid hexadecimal values
  6709. * @returns a new Color4 object
  6710. */
  6711. static FromHexString(hex: string): Color4;
  6712. /**
  6713. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6714. * @param left defines the start value
  6715. * @param right defines the end value
  6716. * @param amount defines the gradient factor
  6717. * @returns a new Color4 object
  6718. */
  6719. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6720. /**
  6721. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6722. * @param left defines the start value
  6723. * @param right defines the end value
  6724. * @param amount defines the gradient factor
  6725. * @param result defines the Color4 object where to store data
  6726. */
  6727. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6728. /**
  6729. * Creates a new Color4 from a Color3 and an alpha value
  6730. * @param color3 defines the source Color3 to read from
  6731. * @param alpha defines the alpha component (1.0 by default)
  6732. * @returns a new Color4 object
  6733. */
  6734. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6735. /**
  6736. * Creates a new Color4 from the starting index element of the given array
  6737. * @param array defines the source array to read from
  6738. * @param offset defines the offset in the source array
  6739. * @returns a new Color4 object
  6740. */
  6741. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6742. /**
  6743. * Creates a new Color4 from the starting index element of the given array
  6744. * @param array defines the source array to read from
  6745. * @param offset defines the offset in the source array
  6746. * @param result defines the target Color4 object
  6747. */
  6748. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6749. /**
  6750. * Creates a new Color3 from integer values (< 256)
  6751. * @param r defines the red component to read from (value between 0 and 255)
  6752. * @param g defines the green component to read from (value between 0 and 255)
  6753. * @param b defines the blue component to read from (value between 0 and 255)
  6754. * @param a defines the alpha component to read from (value between 0 and 255)
  6755. * @returns a new Color3 object
  6756. */
  6757. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6758. /**
  6759. * Check the content of a given array and convert it to an array containing RGBA data
  6760. * If the original array was already containing count * 4 values then it is returned directly
  6761. * @param colors defines the array to check
  6762. * @param count defines the number of RGBA data to expect
  6763. * @returns an array containing count * 4 values (RGBA)
  6764. */
  6765. static CheckColors4(colors: number[], count: number): number[];
  6766. }
  6767. /**
  6768. * @hidden
  6769. */
  6770. export class TmpColors {
  6771. static Color3: Color3[];
  6772. static Color4: Color4[];
  6773. }
  6774. }
  6775. declare module BABYLON {
  6776. /**
  6777. * Defines an interface which represents an animation key frame
  6778. */
  6779. export interface IAnimationKey {
  6780. /**
  6781. * Frame of the key frame
  6782. */
  6783. frame: number;
  6784. /**
  6785. * Value at the specifies key frame
  6786. */
  6787. value: any;
  6788. /**
  6789. * The input tangent for the cubic hermite spline
  6790. */
  6791. inTangent?: any;
  6792. /**
  6793. * The output tangent for the cubic hermite spline
  6794. */
  6795. outTangent?: any;
  6796. /**
  6797. * The animation interpolation type
  6798. */
  6799. interpolation?: AnimationKeyInterpolation;
  6800. }
  6801. /**
  6802. * Enum for the animation key frame interpolation type
  6803. */
  6804. export enum AnimationKeyInterpolation {
  6805. /**
  6806. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6807. */
  6808. STEP = 1
  6809. }
  6810. }
  6811. declare module BABYLON {
  6812. /**
  6813. * Represents the range of an animation
  6814. */
  6815. export class AnimationRange {
  6816. /**The name of the animation range**/
  6817. name: string;
  6818. /**The starting frame of the animation */
  6819. from: number;
  6820. /**The ending frame of the animation*/
  6821. to: number;
  6822. /**
  6823. * Initializes the range of an animation
  6824. * @param name The name of the animation range
  6825. * @param from The starting frame of the animation
  6826. * @param to The ending frame of the animation
  6827. */
  6828. constructor(
  6829. /**The name of the animation range**/
  6830. name: string,
  6831. /**The starting frame of the animation */
  6832. from: number,
  6833. /**The ending frame of the animation*/
  6834. to: number);
  6835. /**
  6836. * Makes a copy of the animation range
  6837. * @returns A copy of the animation range
  6838. */
  6839. clone(): AnimationRange;
  6840. }
  6841. }
  6842. declare module BABYLON {
  6843. /**
  6844. * Composed of a frame, and an action function
  6845. */
  6846. export class AnimationEvent {
  6847. /** The frame for which the event is triggered **/
  6848. frame: number;
  6849. /** The event to perform when triggered **/
  6850. action: (currentFrame: number) => void;
  6851. /** Specifies if the event should be triggered only once**/
  6852. onlyOnce?: boolean | undefined;
  6853. /**
  6854. * Specifies if the animation event is done
  6855. */
  6856. isDone: boolean;
  6857. /**
  6858. * Initializes the animation event
  6859. * @param frame The frame for which the event is triggered
  6860. * @param action The event to perform when triggered
  6861. * @param onlyOnce Specifies if the event should be triggered only once
  6862. */
  6863. constructor(
  6864. /** The frame for which the event is triggered **/
  6865. frame: number,
  6866. /** The event to perform when triggered **/
  6867. action: (currentFrame: number) => void,
  6868. /** Specifies if the event should be triggered only once**/
  6869. onlyOnce?: boolean | undefined);
  6870. /** @hidden */
  6871. _clone(): AnimationEvent;
  6872. }
  6873. }
  6874. declare module BABYLON {
  6875. /**
  6876. * Interface used to define a behavior
  6877. */
  6878. export interface Behavior<T> {
  6879. /** gets or sets behavior's name */
  6880. name: string;
  6881. /**
  6882. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6883. */
  6884. init(): void;
  6885. /**
  6886. * Called when the behavior is attached to a target
  6887. * @param target defines the target where the behavior is attached to
  6888. */
  6889. attach(target: T): void;
  6890. /**
  6891. * Called when the behavior is detached from its target
  6892. */
  6893. detach(): void;
  6894. }
  6895. /**
  6896. * Interface implemented by classes supporting behaviors
  6897. */
  6898. export interface IBehaviorAware<T> {
  6899. /**
  6900. * Attach a behavior
  6901. * @param behavior defines the behavior to attach
  6902. * @returns the current host
  6903. */
  6904. addBehavior(behavior: Behavior<T>): T;
  6905. /**
  6906. * Remove a behavior from the current object
  6907. * @param behavior defines the behavior to detach
  6908. * @returns the current host
  6909. */
  6910. removeBehavior(behavior: Behavior<T>): T;
  6911. /**
  6912. * Gets a behavior using its name to search
  6913. * @param name defines the name to search
  6914. * @returns the behavior or null if not found
  6915. */
  6916. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6917. }
  6918. }
  6919. declare module BABYLON {
  6920. /**
  6921. * Class used to store data that will be store in GPU memory
  6922. */
  6923. export class Buffer {
  6924. private _engine;
  6925. private _buffer;
  6926. /** @hidden */
  6927. _data: Nullable<DataArray>;
  6928. private _updatable;
  6929. private _instanced;
  6930. private _divisor;
  6931. private _isAlreadyOwned;
  6932. /**
  6933. * Gets the byte stride.
  6934. */
  6935. readonly byteStride: number;
  6936. /**
  6937. * Constructor
  6938. * @param engine the engine
  6939. * @param data the data to use for this buffer
  6940. * @param updatable whether the data is updatable
  6941. * @param stride the stride (optional)
  6942. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6943. * @param instanced whether the buffer is instanced (optional)
  6944. * @param useBytes set to true if the stride in in bytes (optional)
  6945. * @param divisor sets an optional divisor for instances (1 by default)
  6946. */
  6947. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6948. /**
  6949. * Create a new VertexBuffer based on the current buffer
  6950. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6951. * @param offset defines offset in the buffer (0 by default)
  6952. * @param size defines the size in floats of attributes (position is 3 for instance)
  6953. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6954. * @param instanced defines if the vertex buffer contains indexed data
  6955. * @param useBytes defines if the offset and stride are in bytes *
  6956. * @param divisor sets an optional divisor for instances (1 by default)
  6957. * @returns the new vertex buffer
  6958. */
  6959. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6960. /**
  6961. * Gets a boolean indicating if the Buffer is updatable?
  6962. * @returns true if the buffer is updatable
  6963. */
  6964. isUpdatable(): boolean;
  6965. /**
  6966. * Gets current buffer's data
  6967. * @returns a DataArray or null
  6968. */
  6969. getData(): Nullable<DataArray>;
  6970. /**
  6971. * Gets underlying native buffer
  6972. * @returns underlying native buffer
  6973. */
  6974. getBuffer(): Nullable<DataBuffer>;
  6975. /**
  6976. * Gets the stride in float32 units (i.e. byte stride / 4).
  6977. * May not be an integer if the byte stride is not divisible by 4.
  6978. * @returns the stride in float32 units
  6979. * @deprecated Please use byteStride instead.
  6980. */
  6981. getStrideSize(): number;
  6982. /**
  6983. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6984. * @param data defines the data to store
  6985. */
  6986. create(data?: Nullable<DataArray>): void;
  6987. /** @hidden */
  6988. _rebuild(): void;
  6989. /**
  6990. * Update current buffer data
  6991. * @param data defines the data to store
  6992. */
  6993. update(data: DataArray): void;
  6994. /**
  6995. * Updates the data directly.
  6996. * @param data the new data
  6997. * @param offset the new offset
  6998. * @param vertexCount the vertex count (optional)
  6999. * @param useBytes set to true if the offset is in bytes
  7000. */
  7001. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  7002. /** @hidden */
  7003. _increaseReferences(): void;
  7004. /**
  7005. * Release all resources
  7006. */
  7007. dispose(): void;
  7008. }
  7009. /**
  7010. * Specialized buffer used to store vertex data
  7011. */
  7012. export class VertexBuffer {
  7013. /** @hidden */
  7014. _buffer: Buffer;
  7015. private _kind;
  7016. private _size;
  7017. private _ownsBuffer;
  7018. private _instanced;
  7019. private _instanceDivisor;
  7020. /**
  7021. * The byte type.
  7022. */
  7023. static readonly BYTE: number;
  7024. /**
  7025. * The unsigned byte type.
  7026. */
  7027. static readonly UNSIGNED_BYTE: number;
  7028. /**
  7029. * The short type.
  7030. */
  7031. static readonly SHORT: number;
  7032. /**
  7033. * The unsigned short type.
  7034. */
  7035. static readonly UNSIGNED_SHORT: number;
  7036. /**
  7037. * The integer type.
  7038. */
  7039. static readonly INT: number;
  7040. /**
  7041. * The unsigned integer type.
  7042. */
  7043. static readonly UNSIGNED_INT: number;
  7044. /**
  7045. * The float type.
  7046. */
  7047. static readonly FLOAT: number;
  7048. /**
  7049. * Gets or sets the instance divisor when in instanced mode
  7050. */
  7051. get instanceDivisor(): number;
  7052. set instanceDivisor(value: number);
  7053. /**
  7054. * Gets the byte stride.
  7055. */
  7056. readonly byteStride: number;
  7057. /**
  7058. * Gets the byte offset.
  7059. */
  7060. readonly byteOffset: number;
  7061. /**
  7062. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  7063. */
  7064. readonly normalized: boolean;
  7065. /**
  7066. * Gets the data type of each component in the array.
  7067. */
  7068. readonly type: number;
  7069. /**
  7070. * Constructor
  7071. * @param engine the engine
  7072. * @param data the data to use for this vertex buffer
  7073. * @param kind the vertex buffer kind
  7074. * @param updatable whether the data is updatable
  7075. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  7076. * @param stride the stride (optional)
  7077. * @param instanced whether the buffer is instanced (optional)
  7078. * @param offset the offset of the data (optional)
  7079. * @param size the number of components (optional)
  7080. * @param type the type of the component (optional)
  7081. * @param normalized whether the data contains normalized data (optional)
  7082. * @param useBytes set to true if stride and offset are in bytes (optional)
  7083. * @param divisor defines the instance divisor to use (1 by default)
  7084. * @param takeBufferOwnership defines if the buffer should be released when the vertex buffer is disposed
  7085. */
  7086. 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);
  7087. /** @hidden */
  7088. _rebuild(): void;
  7089. /**
  7090. * Returns the kind of the VertexBuffer (string)
  7091. * @returns a string
  7092. */
  7093. getKind(): string;
  7094. /**
  7095. * Gets a boolean indicating if the VertexBuffer is updatable?
  7096. * @returns true if the buffer is updatable
  7097. */
  7098. isUpdatable(): boolean;
  7099. /**
  7100. * Gets current buffer's data
  7101. * @returns a DataArray or null
  7102. */
  7103. getData(): Nullable<DataArray>;
  7104. /**
  7105. * Gets underlying native buffer
  7106. * @returns underlying native buffer
  7107. */
  7108. getBuffer(): Nullable<DataBuffer>;
  7109. /**
  7110. * Gets the stride in float32 units (i.e. byte stride / 4).
  7111. * May not be an integer if the byte stride is not divisible by 4.
  7112. * @returns the stride in float32 units
  7113. * @deprecated Please use byteStride instead.
  7114. */
  7115. getStrideSize(): number;
  7116. /**
  7117. * Returns the offset as a multiple of the type byte length.
  7118. * @returns the offset in bytes
  7119. * @deprecated Please use byteOffset instead.
  7120. */
  7121. getOffset(): number;
  7122. /**
  7123. * Returns the number of components per vertex attribute (integer)
  7124. * @returns the size in float
  7125. */
  7126. getSize(): number;
  7127. /**
  7128. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  7129. * @returns true if this buffer is instanced
  7130. */
  7131. getIsInstanced(): boolean;
  7132. /**
  7133. * Returns the instancing divisor, zero for non-instanced (integer).
  7134. * @returns a number
  7135. */
  7136. getInstanceDivisor(): number;
  7137. /**
  7138. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  7139. * @param data defines the data to store
  7140. */
  7141. create(data?: DataArray): void;
  7142. /**
  7143. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  7144. * This function will create a new buffer if the current one is not updatable
  7145. * @param data defines the data to store
  7146. */
  7147. update(data: DataArray): void;
  7148. /**
  7149. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  7150. * Returns the directly updated WebGLBuffer.
  7151. * @param data the new data
  7152. * @param offset the new offset
  7153. * @param useBytes set to true if the offset is in bytes
  7154. */
  7155. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  7156. /**
  7157. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  7158. */
  7159. dispose(): void;
  7160. /**
  7161. * Enumerates each value of this vertex buffer as numbers.
  7162. * @param count the number of values to enumerate
  7163. * @param callback the callback function called for each value
  7164. */
  7165. forEach(count: number, callback: (value: number, index: number) => void): void;
  7166. /**
  7167. * Positions
  7168. */
  7169. static readonly PositionKind: string;
  7170. /**
  7171. * Normals
  7172. */
  7173. static readonly NormalKind: string;
  7174. /**
  7175. * Tangents
  7176. */
  7177. static readonly TangentKind: string;
  7178. /**
  7179. * Texture coordinates
  7180. */
  7181. static readonly UVKind: string;
  7182. /**
  7183. * Texture coordinates 2
  7184. */
  7185. static readonly UV2Kind: string;
  7186. /**
  7187. * Texture coordinates 3
  7188. */
  7189. static readonly UV3Kind: string;
  7190. /**
  7191. * Texture coordinates 4
  7192. */
  7193. static readonly UV4Kind: string;
  7194. /**
  7195. * Texture coordinates 5
  7196. */
  7197. static readonly UV5Kind: string;
  7198. /**
  7199. * Texture coordinates 6
  7200. */
  7201. static readonly UV6Kind: string;
  7202. /**
  7203. * Colors
  7204. */
  7205. static readonly ColorKind: string;
  7206. /**
  7207. * Matrix indices (for bones)
  7208. */
  7209. static readonly MatricesIndicesKind: string;
  7210. /**
  7211. * Matrix weights (for bones)
  7212. */
  7213. static readonly MatricesWeightsKind: string;
  7214. /**
  7215. * Additional matrix indices (for bones)
  7216. */
  7217. static readonly MatricesIndicesExtraKind: string;
  7218. /**
  7219. * Additional matrix weights (for bones)
  7220. */
  7221. static readonly MatricesWeightsExtraKind: string;
  7222. /**
  7223. * Deduces the stride given a kind.
  7224. * @param kind The kind string to deduce
  7225. * @returns The deduced stride
  7226. */
  7227. static DeduceStride(kind: string): number;
  7228. /**
  7229. * Gets the byte length of the given type.
  7230. * @param type the type
  7231. * @returns the number of bytes
  7232. */
  7233. static GetTypeByteLength(type: number): number;
  7234. /**
  7235. * Enumerates each value of the given parameters as numbers.
  7236. * @param data the data to enumerate
  7237. * @param byteOffset the byte offset of the data
  7238. * @param byteStride the byte stride of the data
  7239. * @param componentCount the number of components per element
  7240. * @param componentType the type of the component
  7241. * @param count the number of values to enumerate
  7242. * @param normalized whether the data is normalized
  7243. * @param callback the callback function called for each value
  7244. */
  7245. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  7246. private static _GetFloatValue;
  7247. }
  7248. }
  7249. declare module BABYLON {
  7250. /**
  7251. * @hidden
  7252. */
  7253. export class IntersectionInfo {
  7254. bu: Nullable<number>;
  7255. bv: Nullable<number>;
  7256. distance: number;
  7257. faceId: number;
  7258. subMeshId: number;
  7259. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  7260. }
  7261. }
  7262. declare module BABYLON {
  7263. /**
  7264. * Class used to store bounding sphere information
  7265. */
  7266. export class BoundingSphere {
  7267. /**
  7268. * Gets the center of the bounding sphere in local space
  7269. */
  7270. readonly center: Vector3;
  7271. /**
  7272. * Radius of the bounding sphere in local space
  7273. */
  7274. radius: number;
  7275. /**
  7276. * Gets the center of the bounding sphere in world space
  7277. */
  7278. readonly centerWorld: Vector3;
  7279. /**
  7280. * Radius of the bounding sphere in world space
  7281. */
  7282. radiusWorld: number;
  7283. /**
  7284. * Gets the minimum vector in local space
  7285. */
  7286. readonly minimum: Vector3;
  7287. /**
  7288. * Gets the maximum vector in local space
  7289. */
  7290. readonly maximum: Vector3;
  7291. private _worldMatrix;
  7292. private static readonly TmpVector3;
  7293. /**
  7294. * Creates a new bounding sphere
  7295. * @param min defines the minimum vector (in local space)
  7296. * @param max defines the maximum vector (in local space)
  7297. * @param worldMatrix defines the new world matrix
  7298. */
  7299. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7300. /**
  7301. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7302. * @param min defines the new minimum vector (in local space)
  7303. * @param max defines the new maximum vector (in local space)
  7304. * @param worldMatrix defines the new world matrix
  7305. */
  7306. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7307. /**
  7308. * Scale the current bounding sphere by applying a scale factor
  7309. * @param factor defines the scale factor to apply
  7310. * @returns the current bounding box
  7311. */
  7312. scale(factor: number): BoundingSphere;
  7313. /**
  7314. * Gets the world matrix of the bounding box
  7315. * @returns a matrix
  7316. */
  7317. getWorldMatrix(): DeepImmutable<Matrix>;
  7318. /** @hidden */
  7319. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7320. /**
  7321. * Tests if the bounding sphere is intersecting the frustum planes
  7322. * @param frustumPlanes defines the frustum planes to test
  7323. * @returns true if there is an intersection
  7324. */
  7325. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7326. /**
  7327. * Tests if the bounding sphere center is in between the frustum planes.
  7328. * Used for optimistic fast inclusion.
  7329. * @param frustumPlanes defines the frustum planes to test
  7330. * @returns true if the sphere center is in between the frustum planes
  7331. */
  7332. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7333. /**
  7334. * Tests if a point is inside the bounding sphere
  7335. * @param point defines the point to test
  7336. * @returns true if the point is inside the bounding sphere
  7337. */
  7338. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7339. /**
  7340. * Checks if two sphere intersct
  7341. * @param sphere0 sphere 0
  7342. * @param sphere1 sphere 1
  7343. * @returns true if the speres intersect
  7344. */
  7345. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7346. }
  7347. }
  7348. declare module BABYLON {
  7349. /**
  7350. * Class used to store bounding box information
  7351. */
  7352. export class BoundingBox implements ICullable {
  7353. /**
  7354. * Gets the 8 vectors representing the bounding box in local space
  7355. */
  7356. readonly vectors: Vector3[];
  7357. /**
  7358. * Gets the center of the bounding box in local space
  7359. */
  7360. readonly center: Vector3;
  7361. /**
  7362. * Gets the center of the bounding box in world space
  7363. */
  7364. readonly centerWorld: Vector3;
  7365. /**
  7366. * Gets the extend size in local space
  7367. */
  7368. readonly extendSize: Vector3;
  7369. /**
  7370. * Gets the extend size in world space
  7371. */
  7372. readonly extendSizeWorld: Vector3;
  7373. /**
  7374. * Gets the OBB (object bounding box) directions
  7375. */
  7376. readonly directions: Vector3[];
  7377. /**
  7378. * Gets the 8 vectors representing the bounding box in world space
  7379. */
  7380. readonly vectorsWorld: Vector3[];
  7381. /**
  7382. * Gets the minimum vector in world space
  7383. */
  7384. readonly minimumWorld: Vector3;
  7385. /**
  7386. * Gets the maximum vector in world space
  7387. */
  7388. readonly maximumWorld: Vector3;
  7389. /**
  7390. * Gets the minimum vector in local space
  7391. */
  7392. readonly minimum: Vector3;
  7393. /**
  7394. * Gets the maximum vector in local space
  7395. */
  7396. readonly maximum: Vector3;
  7397. private _worldMatrix;
  7398. private static readonly TmpVector3;
  7399. /**
  7400. * @hidden
  7401. */
  7402. _tag: number;
  7403. /**
  7404. * Creates a new bounding box
  7405. * @param min defines the minimum vector (in local space)
  7406. * @param max defines the maximum vector (in local space)
  7407. * @param worldMatrix defines the new world matrix
  7408. */
  7409. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7410. /**
  7411. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7412. * @param min defines the new minimum vector (in local space)
  7413. * @param max defines the new maximum vector (in local space)
  7414. * @param worldMatrix defines the new world matrix
  7415. */
  7416. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7417. /**
  7418. * Scale the current bounding box by applying a scale factor
  7419. * @param factor defines the scale factor to apply
  7420. * @returns the current bounding box
  7421. */
  7422. scale(factor: number): BoundingBox;
  7423. /**
  7424. * Gets the world matrix of the bounding box
  7425. * @returns a matrix
  7426. */
  7427. getWorldMatrix(): DeepImmutable<Matrix>;
  7428. /** @hidden */
  7429. _update(world: DeepImmutable<Matrix>): void;
  7430. /**
  7431. * Tests if the bounding box is intersecting the frustum planes
  7432. * @param frustumPlanes defines the frustum planes to test
  7433. * @returns true if there is an intersection
  7434. */
  7435. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7436. /**
  7437. * Tests if the bounding box is entirely inside the frustum planes
  7438. * @param frustumPlanes defines the frustum planes to test
  7439. * @returns true if there is an inclusion
  7440. */
  7441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7442. /**
  7443. * Tests if a point is inside the bounding box
  7444. * @param point defines the point to test
  7445. * @returns true if the point is inside the bounding box
  7446. */
  7447. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7448. /**
  7449. * Tests if the bounding box intersects with a bounding sphere
  7450. * @param sphere defines the sphere to test
  7451. * @returns true if there is an intersection
  7452. */
  7453. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7454. /**
  7455. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7456. * @param min defines the min vector to use
  7457. * @param max defines the max vector to use
  7458. * @returns true if there is an intersection
  7459. */
  7460. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7461. /**
  7462. * Tests if two bounding boxes are intersections
  7463. * @param box0 defines the first box to test
  7464. * @param box1 defines the second box to test
  7465. * @returns true if there is an intersection
  7466. */
  7467. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7468. /**
  7469. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7470. * @param minPoint defines the minimum vector of the bounding box
  7471. * @param maxPoint defines the maximum vector of the bounding box
  7472. * @param sphereCenter defines the sphere center
  7473. * @param sphereRadius defines the sphere radius
  7474. * @returns true if there is an intersection
  7475. */
  7476. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7477. /**
  7478. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7479. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7480. * @param frustumPlanes defines the frustum planes to test
  7481. * @return true if there is an inclusion
  7482. */
  7483. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7484. /**
  7485. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7486. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7487. * @param frustumPlanes defines the frustum planes to test
  7488. * @return true if there is an intersection
  7489. */
  7490. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7491. }
  7492. }
  7493. declare module BABYLON {
  7494. /** @hidden */
  7495. export class Collider {
  7496. /** Define if a collision was found */
  7497. collisionFound: boolean;
  7498. /**
  7499. * Define last intersection point in local space
  7500. */
  7501. intersectionPoint: Vector3;
  7502. /**
  7503. * Define last collided mesh
  7504. */
  7505. collidedMesh: Nullable<AbstractMesh>;
  7506. private _collisionPoint;
  7507. private _planeIntersectionPoint;
  7508. private _tempVector;
  7509. private _tempVector2;
  7510. private _tempVector3;
  7511. private _tempVector4;
  7512. private _edge;
  7513. private _baseToVertex;
  7514. private _destinationPoint;
  7515. private _slidePlaneNormal;
  7516. private _displacementVector;
  7517. /** @hidden */
  7518. _radius: Vector3;
  7519. /** @hidden */
  7520. _retry: number;
  7521. private _velocity;
  7522. private _basePoint;
  7523. private _epsilon;
  7524. /** @hidden */
  7525. _velocityWorldLength: number;
  7526. /** @hidden */
  7527. _basePointWorld: Vector3;
  7528. private _velocityWorld;
  7529. private _normalizedVelocity;
  7530. /** @hidden */
  7531. _initialVelocity: Vector3;
  7532. /** @hidden */
  7533. _initialPosition: Vector3;
  7534. private _nearestDistance;
  7535. private _collisionMask;
  7536. get collisionMask(): number;
  7537. set collisionMask(mask: number);
  7538. /**
  7539. * Gets the plane normal used to compute the sliding response (in local space)
  7540. */
  7541. get slidePlaneNormal(): Vector3;
  7542. /** @hidden */
  7543. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7544. /** @hidden */
  7545. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7546. /** @hidden */
  7547. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7548. /** @hidden */
  7549. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7550. /** @hidden */
  7551. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7552. /** @hidden */
  7553. _getResponse(pos: Vector3, vel: Vector3): void;
  7554. }
  7555. }
  7556. declare module BABYLON {
  7557. /**
  7558. * Interface for cullable objects
  7559. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7560. */
  7561. export interface ICullable {
  7562. /**
  7563. * Checks if the object or part of the object is in the frustum
  7564. * @param frustumPlanes Camera near/planes
  7565. * @returns true if the object is in frustum otherwise false
  7566. */
  7567. isInFrustum(frustumPlanes: Plane[]): boolean;
  7568. /**
  7569. * Checks if a cullable object (mesh...) is in the camera frustum
  7570. * Unlike isInFrustum this cheks the full bounding box
  7571. * @param frustumPlanes Camera near/planes
  7572. * @returns true if the object is in frustum otherwise false
  7573. */
  7574. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7575. }
  7576. /**
  7577. * Info for a bounding data of a mesh
  7578. */
  7579. export class BoundingInfo implements ICullable {
  7580. /**
  7581. * Bounding box for the mesh
  7582. */
  7583. readonly boundingBox: BoundingBox;
  7584. /**
  7585. * Bounding sphere for the mesh
  7586. */
  7587. readonly boundingSphere: BoundingSphere;
  7588. private _isLocked;
  7589. private static readonly TmpVector3;
  7590. /**
  7591. * Constructs bounding info
  7592. * @param minimum min vector of the bounding box/sphere
  7593. * @param maximum max vector of the bounding box/sphere
  7594. * @param worldMatrix defines the new world matrix
  7595. */
  7596. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7597. /**
  7598. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7599. * @param min defines the new minimum vector (in local space)
  7600. * @param max defines the new maximum vector (in local space)
  7601. * @param worldMatrix defines the new world matrix
  7602. */
  7603. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7604. /**
  7605. * min vector of the bounding box/sphere
  7606. */
  7607. get minimum(): Vector3;
  7608. /**
  7609. * max vector of the bounding box/sphere
  7610. */
  7611. get maximum(): Vector3;
  7612. /**
  7613. * If the info is locked and won't be updated to avoid perf overhead
  7614. */
  7615. get isLocked(): boolean;
  7616. set isLocked(value: boolean);
  7617. /**
  7618. * Updates the bounding sphere and box
  7619. * @param world world matrix to be used to update
  7620. */
  7621. update(world: DeepImmutable<Matrix>): void;
  7622. /**
  7623. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7624. * @param center New center of the bounding info
  7625. * @param extend New extend of the bounding info
  7626. * @returns the current bounding info
  7627. */
  7628. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7629. /**
  7630. * Scale the current bounding info by applying a scale factor
  7631. * @param factor defines the scale factor to apply
  7632. * @returns the current bounding info
  7633. */
  7634. scale(factor: number): BoundingInfo;
  7635. /**
  7636. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7637. * @param frustumPlanes defines the frustum to test
  7638. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7639. * @returns true if the bounding info is in the frustum planes
  7640. */
  7641. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7642. /**
  7643. * Gets the world distance between the min and max points of the bounding box
  7644. */
  7645. get diagonalLength(): number;
  7646. /**
  7647. * Checks if a cullable object (mesh...) is in the camera frustum
  7648. * Unlike isInFrustum this cheks the full bounding box
  7649. * @param frustumPlanes Camera near/planes
  7650. * @returns true if the object is in frustum otherwise false
  7651. */
  7652. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7653. /** @hidden */
  7654. _checkCollision(collider: Collider): boolean;
  7655. /**
  7656. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7657. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7658. * @param point the point to check intersection with
  7659. * @returns if the point intersects
  7660. */
  7661. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7662. /**
  7663. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7664. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7665. * @param boundingInfo the bounding info to check intersection with
  7666. * @param precise if the intersection should be done using OBB
  7667. * @returns if the bounding info intersects
  7668. */
  7669. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7670. }
  7671. }
  7672. declare module BABYLON {
  7673. /**
  7674. * Extracts minimum and maximum values from a list of indexed positions
  7675. * @param positions defines the positions to use
  7676. * @param indices defines the indices to the positions
  7677. * @param indexStart defines the start index
  7678. * @param indexCount defines the end index
  7679. * @param bias defines bias value to add to the result
  7680. * @return minimum and maximum values
  7681. */
  7682. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7683. minimum: Vector3;
  7684. maximum: Vector3;
  7685. };
  7686. /**
  7687. * Extracts minimum and maximum values from a list of positions
  7688. * @param positions defines the positions to use
  7689. * @param start defines the start index in the positions array
  7690. * @param count defines the number of positions to handle
  7691. * @param bias defines bias value to add to the result
  7692. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7693. * @return minimum and maximum values
  7694. */
  7695. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7696. minimum: Vector3;
  7697. maximum: Vector3;
  7698. };
  7699. }
  7700. declare module BABYLON {
  7701. /**
  7702. * Class used to manipulate GUIDs
  7703. */
  7704. export class GUID {
  7705. /**
  7706. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  7707. * Be aware Math.random() could cause collisions, but:
  7708. * "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"
  7709. * @returns a pseudo random id
  7710. */
  7711. static RandomId(): string;
  7712. }
  7713. }
  7714. declare module BABYLON {
  7715. /**
  7716. * Base class of all the textures in babylon.
  7717. * It groups all the common properties the materials, post process, lights... might need
  7718. * in order to make a correct use of the texture.
  7719. */
  7720. export class BaseTexture extends ThinTexture implements IAnimatable {
  7721. /**
  7722. * Default anisotropic filtering level for the application.
  7723. * It is set to 4 as a good tradeoff between perf and quality.
  7724. */
  7725. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  7726. /**
  7727. * Gets or sets the unique id of the texture
  7728. */
  7729. uniqueId: number;
  7730. /**
  7731. * Define the name of the texture.
  7732. */
  7733. name: string;
  7734. /**
  7735. * Gets or sets an object used to store user defined information.
  7736. */
  7737. metadata: any;
  7738. /**
  7739. * For internal use only. Please do not use.
  7740. */
  7741. reservedDataStore: any;
  7742. private _hasAlpha;
  7743. /**
  7744. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  7745. */
  7746. set hasAlpha(value: boolean);
  7747. get hasAlpha(): boolean;
  7748. /**
  7749. * Defines if the alpha value should be determined via the rgb values.
  7750. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  7751. */
  7752. getAlphaFromRGB: boolean;
  7753. /**
  7754. * Intensity or strength of the texture.
  7755. * It is commonly used by materials to fine tune the intensity of the texture
  7756. */
  7757. level: number;
  7758. /**
  7759. * Define the UV chanel to use starting from 0 and defaulting to 0.
  7760. * This is part of the texture as textures usually maps to one uv set.
  7761. */
  7762. coordinatesIndex: number;
  7763. protected _coordinatesMode: number;
  7764. /**
  7765. * How a texture is mapped.
  7766. *
  7767. * | Value | Type | Description |
  7768. * | ----- | ----------------------------------- | ----------- |
  7769. * | 0 | EXPLICIT_MODE | |
  7770. * | 1 | SPHERICAL_MODE | |
  7771. * | 2 | PLANAR_MODE | |
  7772. * | 3 | CUBIC_MODE | |
  7773. * | 4 | PROJECTION_MODE | |
  7774. * | 5 | SKYBOX_MODE | |
  7775. * | 6 | INVCUBIC_MODE | |
  7776. * | 7 | EQUIRECTANGULAR_MODE | |
  7777. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  7778. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  7779. */
  7780. set coordinatesMode(value: number);
  7781. get coordinatesMode(): number;
  7782. /**
  7783. * | Value | Type | Description |
  7784. * | ----- | ------------------ | ----------- |
  7785. * | 0 | CLAMP_ADDRESSMODE | |
  7786. * | 1 | WRAP_ADDRESSMODE | |
  7787. * | 2 | MIRROR_ADDRESSMODE | |
  7788. */
  7789. get wrapU(): number;
  7790. set wrapU(value: number);
  7791. /**
  7792. * | Value | Type | Description |
  7793. * | ----- | ------------------ | ----------- |
  7794. * | 0 | CLAMP_ADDRESSMODE | |
  7795. * | 1 | WRAP_ADDRESSMODE | |
  7796. * | 2 | MIRROR_ADDRESSMODE | |
  7797. */
  7798. get wrapV(): number;
  7799. set wrapV(value: number);
  7800. /**
  7801. * | Value | Type | Description |
  7802. * | ----- | ------------------ | ----------- |
  7803. * | 0 | CLAMP_ADDRESSMODE | |
  7804. * | 1 | WRAP_ADDRESSMODE | |
  7805. * | 2 | MIRROR_ADDRESSMODE | |
  7806. */
  7807. wrapR: number;
  7808. /**
  7809. * With compliant hardware and browser (supporting anisotropic filtering)
  7810. * this defines the level of anisotropic filtering in the texture.
  7811. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  7812. */
  7813. anisotropicFilteringLevel: number;
  7814. private _isCube;
  7815. /**
  7816. * Define if the texture is a cube texture or if false a 2d texture.
  7817. */
  7818. get isCube(): boolean;
  7819. set isCube(value: boolean);
  7820. /**
  7821. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  7822. */
  7823. get is3D(): boolean;
  7824. set is3D(value: boolean);
  7825. /**
  7826. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  7827. */
  7828. get is2DArray(): boolean;
  7829. set is2DArray(value: boolean);
  7830. private _gammaSpace;
  7831. /**
  7832. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  7833. * HDR texture are usually stored in linear space.
  7834. * This only impacts the PBR and Background materials
  7835. */
  7836. get gammaSpace(): boolean;
  7837. set gammaSpace(gamma: boolean);
  7838. /**
  7839. * Gets or sets whether or not the texture contains RGBD data.
  7840. */
  7841. get isRGBD(): boolean;
  7842. set isRGBD(value: boolean);
  7843. /**
  7844. * Is Z inverted in the texture (useful in a cube texture).
  7845. */
  7846. invertZ: boolean;
  7847. /**
  7848. * Are mip maps generated for this texture or not.
  7849. */
  7850. get noMipmap(): boolean;
  7851. /**
  7852. * @hidden
  7853. */
  7854. lodLevelInAlpha: boolean;
  7855. /**
  7856. * With prefiltered texture, defined the offset used during the prefiltering steps.
  7857. */
  7858. get lodGenerationOffset(): number;
  7859. set lodGenerationOffset(value: number);
  7860. /**
  7861. * With prefiltered texture, defined the scale used during the prefiltering steps.
  7862. */
  7863. get lodGenerationScale(): number;
  7864. set lodGenerationScale(value: number);
  7865. /**
  7866. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  7867. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  7868. * average roughness values.
  7869. */
  7870. get linearSpecularLOD(): boolean;
  7871. set linearSpecularLOD(value: boolean);
  7872. /**
  7873. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  7874. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  7875. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  7876. */
  7877. get irradianceTexture(): Nullable<BaseTexture>;
  7878. set irradianceTexture(value: Nullable<BaseTexture>);
  7879. /**
  7880. * Define if the texture is a render target.
  7881. */
  7882. isRenderTarget: boolean;
  7883. /**
  7884. * Define the unique id of the texture in the scene.
  7885. */
  7886. get uid(): string;
  7887. /** @hidden */
  7888. _prefiltered: boolean;
  7889. /**
  7890. * Return a string representation of the texture.
  7891. * @returns the texture as a string
  7892. */
  7893. toString(): string;
  7894. /**
  7895. * Get the class name of the texture.
  7896. * @returns "BaseTexture"
  7897. */
  7898. getClassName(): string;
  7899. /**
  7900. * Define the list of animation attached to the texture.
  7901. */
  7902. animations: Animation[];
  7903. /**
  7904. * An event triggered when the texture is disposed.
  7905. */
  7906. onDisposeObservable: Observable<BaseTexture>;
  7907. private _onDisposeObserver;
  7908. /**
  7909. * Callback triggered when the texture has been disposed.
  7910. * Kept for back compatibility, you can use the onDisposeObservable instead.
  7911. */
  7912. set onDispose(callback: () => void);
  7913. protected _scene: Nullable<Scene>;
  7914. /** @hidden */
  7915. _texture: Nullable<InternalTexture>;
  7916. private _uid;
  7917. /**
  7918. * Define if the texture is preventinga material to render or not.
  7919. * If not and the texture is not ready, the engine will use a default black texture instead.
  7920. */
  7921. get isBlocking(): boolean;
  7922. /**
  7923. * Instantiates a new BaseTexture.
  7924. * Base class of all the textures in babylon.
  7925. * It groups all the common properties the materials, post process, lights... might need
  7926. * in order to make a correct use of the texture.
  7927. * @param sceneOrEngine Define the scene or engine the texture blongs to
  7928. */
  7929. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  7930. /**
  7931. * Get the scene the texture belongs to.
  7932. * @returns the scene or null if undefined
  7933. */
  7934. getScene(): Nullable<Scene>;
  7935. /** @hidden */
  7936. protected _getEngine(): Nullable<ThinEngine>;
  7937. /**
  7938. * Checks if the texture has the same transform matrix than another texture
  7939. * @param texture texture to check against
  7940. * @returns true if the transforms are the same, else false
  7941. */
  7942. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  7943. /**
  7944. * Get the texture transform matrix used to offset tile the texture for istance.
  7945. * @returns the transformation matrix
  7946. */
  7947. getTextureMatrix(): Matrix;
  7948. /**
  7949. * Get the texture reflection matrix used to rotate/transform the reflection.
  7950. * @returns the reflection matrix
  7951. */
  7952. getReflectionTextureMatrix(): Matrix;
  7953. /**
  7954. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  7955. * @returns true if ready or not blocking
  7956. */
  7957. isReadyOrNotBlocking(): boolean;
  7958. /**
  7959. * Scales the texture if is `canRescale()`
  7960. * @param ratio the resize factor we want to use to rescale
  7961. */
  7962. scale(ratio: number): void;
  7963. /**
  7964. * Get if the texture can rescale.
  7965. */
  7966. get canRescale(): boolean;
  7967. /** @hidden */
  7968. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  7969. /** @hidden */
  7970. _rebuild(): void;
  7971. /**
  7972. * Clones the texture.
  7973. * @returns the cloned texture
  7974. */
  7975. clone(): Nullable<BaseTexture>;
  7976. /**
  7977. * Get the texture underlying type (INT, FLOAT...)
  7978. */
  7979. get textureType(): number;
  7980. /**
  7981. * Get the texture underlying format (RGB, RGBA...)
  7982. */
  7983. get textureFormat(): number;
  7984. /**
  7985. * Indicates that textures need to be re-calculated for all materials
  7986. */
  7987. protected _markAllSubMeshesAsTexturesDirty(): void;
  7988. /**
  7989. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  7990. * This will returns an RGBA array buffer containing either in values (0-255) or
  7991. * float values (0-1) depending of the underlying buffer type.
  7992. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  7993. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  7994. * @param buffer defines a user defined buffer to fill with data (can be null)
  7995. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  7996. * @returns The Array buffer promise containing the pixels data.
  7997. */
  7998. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Nullable<Promise<ArrayBufferView>>;
  7999. /** @hidden */
  8000. get _lodTextureHigh(): Nullable<BaseTexture>;
  8001. /** @hidden */
  8002. get _lodTextureMid(): Nullable<BaseTexture>;
  8003. /** @hidden */
  8004. get _lodTextureLow(): Nullable<BaseTexture>;
  8005. /**
  8006. * Dispose the texture and release its associated resources.
  8007. */
  8008. dispose(): void;
  8009. /**
  8010. * Serialize the texture into a JSON representation that can be parsed later on.
  8011. * @returns the JSON representation of the texture
  8012. */
  8013. serialize(): any;
  8014. /**
  8015. * Helper function to be called back once a list of texture contains only ready textures.
  8016. * @param textures Define the list of textures to wait for
  8017. * @param callback Define the callback triggered once the entire list will be ready
  8018. */
  8019. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  8020. private static _isScene;
  8021. }
  8022. }
  8023. declare module BABYLON {
  8024. /** @hidden */
  8025. export class WebGLDataBuffer extends DataBuffer {
  8026. private _buffer;
  8027. constructor(resource: WebGLBuffer);
  8028. get underlyingResource(): any;
  8029. }
  8030. }
  8031. declare module BABYLON {
  8032. /** @hidden */
  8033. export class WebGLPipelineContext implements IPipelineContext {
  8034. private _valueCache;
  8035. private _uniforms;
  8036. engine: ThinEngine;
  8037. program: Nullable<WebGLProgram>;
  8038. context?: WebGLRenderingContext;
  8039. vertexShader?: WebGLShader;
  8040. fragmentShader?: WebGLShader;
  8041. isParallelCompiled: boolean;
  8042. onCompiled?: () => void;
  8043. transformFeedback?: WebGLTransformFeedback | null;
  8044. vertexCompilationError: Nullable<string>;
  8045. fragmentCompilationError: Nullable<string>;
  8046. programLinkError: Nullable<string>;
  8047. programValidationError: Nullable<string>;
  8048. get isAsync(): boolean;
  8049. get isReady(): boolean;
  8050. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  8051. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  8052. [key: string]: number;
  8053. }, uniformsNames: string[], uniforms: {
  8054. [key: string]: Nullable<WebGLUniformLocation>;
  8055. }, samplerList: string[], samplers: {
  8056. [key: string]: number;
  8057. }, attributesNames: string[], attributes: number[]): void;
  8058. /**
  8059. * Release all associated resources.
  8060. **/
  8061. dispose(): void;
  8062. /** @hidden */
  8063. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  8064. /** @hidden */
  8065. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8066. /** @hidden */
  8067. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8068. /** @hidden */
  8069. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8070. /**
  8071. * Sets an interger value on a uniform variable.
  8072. * @param uniformName Name of the variable.
  8073. * @param value Value to be set.
  8074. */
  8075. setInt(uniformName: string, value: number): void;
  8076. /**
  8077. * Sets a int2 on a uniform variable.
  8078. * @param uniformName Name of the variable.
  8079. * @param x First int in int2.
  8080. * @param y Second int in int2.
  8081. */
  8082. setInt2(uniformName: string, x: number, y: number): void;
  8083. /**
  8084. * Sets a int3 on a uniform variable.
  8085. * @param uniformName Name of the variable.
  8086. * @param x First int in int3.
  8087. * @param y Second int in int3.
  8088. * @param y Third int in int3.
  8089. */
  8090. setInt3(uniformName: string, x: number, y: number, z: number): void;
  8091. /**
  8092. * Sets a int4 on a uniform variable.
  8093. * @param uniformName Name of the variable.
  8094. * @param x First int in int4.
  8095. * @param y Second int in int4.
  8096. * @param y Third int in int4.
  8097. * @param w Fourth int in int4.
  8098. */
  8099. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8100. /**
  8101. * Sets an int array on a uniform variable.
  8102. * @param uniformName Name of the variable.
  8103. * @param array array to be set.
  8104. */
  8105. setIntArray(uniformName: string, array: Int32Array): void;
  8106. /**
  8107. * 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)
  8108. * @param uniformName Name of the variable.
  8109. * @param array array to be set.
  8110. */
  8111. setIntArray2(uniformName: string, array: Int32Array): void;
  8112. /**
  8113. * 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)
  8114. * @param uniformName Name of the variable.
  8115. * @param array array to be set.
  8116. */
  8117. setIntArray3(uniformName: string, array: Int32Array): void;
  8118. /**
  8119. * 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)
  8120. * @param uniformName Name of the variable.
  8121. * @param array array to be set.
  8122. */
  8123. setIntArray4(uniformName: string, array: Int32Array): void;
  8124. /**
  8125. * Sets an array on a uniform variable.
  8126. * @param uniformName Name of the variable.
  8127. * @param array array to be set.
  8128. */
  8129. setArray(uniformName: string, array: number[]): void;
  8130. /**
  8131. * 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)
  8132. * @param uniformName Name of the variable.
  8133. * @param array array to be set.
  8134. */
  8135. setArray2(uniformName: string, array: number[]): void;
  8136. /**
  8137. * 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)
  8138. * @param uniformName Name of the variable.
  8139. * @param array array to be set.
  8140. * @returns this effect.
  8141. */
  8142. setArray3(uniformName: string, array: number[]): void;
  8143. /**
  8144. * 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)
  8145. * @param uniformName Name of the variable.
  8146. * @param array array to be set.
  8147. */
  8148. setArray4(uniformName: string, array: number[]): void;
  8149. /**
  8150. * Sets matrices on a uniform variable.
  8151. * @param uniformName Name of the variable.
  8152. * @param matrices matrices to be set.
  8153. */
  8154. setMatrices(uniformName: string, matrices: Float32Array): void;
  8155. /**
  8156. * Sets matrix on a uniform variable.
  8157. * @param uniformName Name of the variable.
  8158. * @param matrix matrix to be set.
  8159. */
  8160. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  8161. /**
  8162. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  8163. * @param uniformName Name of the variable.
  8164. * @param matrix matrix to be set.
  8165. */
  8166. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  8167. /**
  8168. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  8169. * @param uniformName Name of the variable.
  8170. * @param matrix matrix to be set.
  8171. */
  8172. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  8173. /**
  8174. * Sets a float on a uniform variable.
  8175. * @param uniformName Name of the variable.
  8176. * @param value value to be set.
  8177. * @returns this effect.
  8178. */
  8179. setFloat(uniformName: string, value: number): void;
  8180. /**
  8181. * Sets a Vector2 on a uniform variable.
  8182. * @param uniformName Name of the variable.
  8183. * @param vector2 vector2 to be set.
  8184. */
  8185. setVector2(uniformName: string, vector2: IVector2Like): void;
  8186. /**
  8187. * Sets a float2 on a uniform variable.
  8188. * @param uniformName Name of the variable.
  8189. * @param x First float in float2.
  8190. * @param y Second float in float2.
  8191. */
  8192. setFloat2(uniformName: string, x: number, y: number): void;
  8193. /**
  8194. * Sets a Vector3 on a uniform variable.
  8195. * @param uniformName Name of the variable.
  8196. * @param vector3 Value to be set.
  8197. */
  8198. setVector3(uniformName: string, vector3: IVector3Like): void;
  8199. /**
  8200. * Sets a float3 on a uniform variable.
  8201. * @param uniformName Name of the variable.
  8202. * @param x First float in float3.
  8203. * @param y Second float in float3.
  8204. * @param z Third float in float3.
  8205. */
  8206. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  8207. /**
  8208. * Sets a Vector4 on a uniform variable.
  8209. * @param uniformName Name of the variable.
  8210. * @param vector4 Value to be set.
  8211. */
  8212. setVector4(uniformName: string, vector4: IVector4Like): void;
  8213. /**
  8214. * Sets a float4 on a uniform variable.
  8215. * @param uniformName Name of the variable.
  8216. * @param x First float in float4.
  8217. * @param y Second float in float4.
  8218. * @param z Third float in float4.
  8219. * @param w Fourth float in float4.
  8220. * @returns this effect.
  8221. */
  8222. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  8223. /**
  8224. * Sets a Color3 on a uniform variable.
  8225. * @param uniformName Name of the variable.
  8226. * @param color3 Value to be set.
  8227. */
  8228. setColor3(uniformName: string, color3: IColor3Like): void;
  8229. /**
  8230. * Sets a Color4 on a uniform variable.
  8231. * @param uniformName Name of the variable.
  8232. * @param color3 Value to be set.
  8233. * @param alpha Alpha value to be set.
  8234. */
  8235. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  8236. /**
  8237. * Sets a Color4 on a uniform variable
  8238. * @param uniformName defines the name of the variable
  8239. * @param color4 defines the value to be set
  8240. */
  8241. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  8242. _getVertexShaderCode(): string | null;
  8243. _getFragmentShaderCode(): string | null;
  8244. }
  8245. }
  8246. declare module BABYLON {
  8247. interface ThinEngine {
  8248. /**
  8249. * Create an uniform buffer
  8250. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8251. * @param elements defines the content of the uniform buffer
  8252. * @returns the webGL uniform buffer
  8253. */
  8254. createUniformBuffer(elements: FloatArray): DataBuffer;
  8255. /**
  8256. * Create a dynamic uniform buffer
  8257. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8258. * @param elements defines the content of the uniform buffer
  8259. * @returns the webGL uniform buffer
  8260. */
  8261. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  8262. /**
  8263. * Update an existing uniform buffer
  8264. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  8265. * @param uniformBuffer defines the target uniform buffer
  8266. * @param elements defines the content to update
  8267. * @param offset defines the offset in the uniform buffer where update should start
  8268. * @param count defines the size of the data to update
  8269. */
  8270. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  8271. /**
  8272. * Bind an uniform buffer to the current webGL context
  8273. * @param buffer defines the buffer to bind
  8274. */
  8275. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  8276. /**
  8277. * Bind a buffer to the current webGL context at a given location
  8278. * @param buffer defines the buffer to bind
  8279. * @param location defines the index where to bind the buffer
  8280. * @param name Name of the uniform variable to bind
  8281. */
  8282. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  8283. /**
  8284. * Bind a specific block at a given index in a specific shader program
  8285. * @param pipelineContext defines the pipeline context to use
  8286. * @param blockName defines the block name
  8287. * @param index defines the index where to bind the block
  8288. */
  8289. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  8290. }
  8291. }
  8292. declare module BABYLON {
  8293. /**
  8294. * Uniform buffer objects.
  8295. *
  8296. * Handles blocks of uniform on the GPU.
  8297. *
  8298. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8299. *
  8300. * For more information, please refer to :
  8301. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8302. */
  8303. export class UniformBuffer {
  8304. /** @hidden */
  8305. static _updatedUbosInFrame: {
  8306. [name: string]: number;
  8307. };
  8308. private _engine;
  8309. private _buffer;
  8310. private _buffers;
  8311. private _bufferIndex;
  8312. private _createBufferOnWrite;
  8313. private _data;
  8314. private _bufferData;
  8315. private _dynamic?;
  8316. private _uniformLocations;
  8317. private _uniformSizes;
  8318. private _uniformArraySizes;
  8319. private _uniformLocationPointer;
  8320. private _needSync;
  8321. private _noUBO;
  8322. private _currentEffect;
  8323. private _currentEffectName;
  8324. private _name;
  8325. private _currentFrameId;
  8326. /** @hidden */
  8327. _alreadyBound: boolean;
  8328. private static _MAX_UNIFORM_SIZE;
  8329. private static _tempBuffer;
  8330. private static _tempBufferInt32View;
  8331. /**
  8332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  8333. * This is dynamic to allow compat with webgl 1 and 2.
  8334. * You will need to pass the name of the uniform as well as the value.
  8335. */
  8336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  8337. /**
  8338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  8339. * This is dynamic to allow compat with webgl 1 and 2.
  8340. * You will need to pass the name of the uniform as well as the value.
  8341. */
  8342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  8343. /**
  8344. * Lambda to Update a single float in a uniform buffer.
  8345. * This is dynamic to allow compat with webgl 1 and 2.
  8346. * You will need to pass the name of the uniform as well as the value.
  8347. */
  8348. updateFloat: (name: string, x: number) => void;
  8349. /**
  8350. * Lambda to Update a vec2 of float in a uniform buffer.
  8351. * This is dynamic to allow compat with webgl 1 and 2.
  8352. * You will need to pass the name of the uniform as well as the value.
  8353. */
  8354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  8355. /**
  8356. * Lambda to Update a vec3 of float in a uniform buffer.
  8357. * This is dynamic to allow compat with webgl 1 and 2.
  8358. * You will need to pass the name of the uniform as well as the value.
  8359. */
  8360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8361. /**
  8362. * Lambda to Update a vec4 of float in a uniform buffer.
  8363. * This is dynamic to allow compat with webgl 1 and 2.
  8364. * You will need to pass the name of the uniform as well as the value.
  8365. */
  8366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8367. /**
  8368. * Lambda to Update an array of float in a uniform buffer.
  8369. * This is dynamic to allow compat with webgl 1 and 2.
  8370. * You will need to pass the name of the uniform as well as the value.
  8371. */
  8372. updateFloatArray: (name: string, array: Float32Array) => void;
  8373. /**
  8374. * Lambda to Update an array of number in a uniform buffer.
  8375. * This is dynamic to allow compat with webgl 1 and 2.
  8376. * You will need to pass the name of the uniform as well as the value.
  8377. */
  8378. updateArray: (name: string, array: number[]) => void;
  8379. /**
  8380. * Lambda to Update an array of number in a uniform buffer.
  8381. * This is dynamic to allow compat with webgl 1 and 2.
  8382. * You will need to pass the name of the uniform as well as the value.
  8383. */
  8384. updateIntArray: (name: string, array: Int32Array) => void;
  8385. /**
  8386. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  8387. * This is dynamic to allow compat with webgl 1 and 2.
  8388. * You will need to pass the name of the uniform as well as the value.
  8389. */
  8390. updateMatrix: (name: string, mat: IMatrixLike) => void;
  8391. /**
  8392. * Lambda to Update an array of 4x4 Matrix in a uniform buffer.
  8393. * This is dynamic to allow compat with webgl 1 and 2.
  8394. * You will need to pass the name of the uniform as well as the value.
  8395. */
  8396. updateMatrices: (name: string, mat: Float32Array) => void;
  8397. /**
  8398. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  8399. * This is dynamic to allow compat with webgl 1 and 2.
  8400. * You will need to pass the name of the uniform as well as the value.
  8401. */
  8402. updateVector3: (name: string, vector: Vector3) => void;
  8403. /**
  8404. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  8405. * This is dynamic to allow compat with webgl 1 and 2.
  8406. * You will need to pass the name of the uniform as well as the value.
  8407. */
  8408. updateVector4: (name: string, vector: Vector4) => void;
  8409. /**
  8410. * Lambda to Update vec3 of float from a Color 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. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  8415. /**
  8416. * Lambda to Update vec4 of float from a Color 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. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  8421. /**
  8422. * Lambda to Update a int 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. updateInt: (name: string, x: number, suffix?: string) => void;
  8427. /**
  8428. * Lambda to Update a vec2 of int 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. updateInt2: (name: string, x: number, y: number, suffix?: string) => void;
  8433. /**
  8434. * Lambda to Update a vec3 of int 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. updateInt3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  8439. /**
  8440. * Lambda to Update a vec4 of int 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. updateInt4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  8445. /**
  8446. * Instantiates a new Uniform buffer objects.
  8447. *
  8448. * Handles blocks of uniform on the GPU.
  8449. *
  8450. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  8451. *
  8452. * For more information, please refer to :
  8453. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  8454. * @param engine Define the engine the buffer is associated with
  8455. * @param data Define the data contained in the buffer
  8456. * @param dynamic Define if the buffer is updatable
  8457. * @param name to assign to the buffer (debugging purpose)
  8458. */
  8459. constructor(engine: Engine, data?: number[], dynamic?: boolean, name?: string);
  8460. /**
  8461. * Indicates if the buffer is using the WebGL2 UBO implementation,
  8462. * or just falling back on setUniformXXX calls.
  8463. */
  8464. get useUbo(): boolean;
  8465. /**
  8466. * Indicates if the WebGL underlying uniform buffer is in sync
  8467. * with the javascript cache data.
  8468. */
  8469. get isSync(): boolean;
  8470. /**
  8471. * Indicates if the WebGL underlying uniform buffer is dynamic.
  8472. * Also, a dynamic UniformBuffer will disable cache verification and always
  8473. * update the underlying WebGL uniform buffer to the GPU.
  8474. * @returns if Dynamic, otherwise false
  8475. */
  8476. isDynamic(): boolean;
  8477. /**
  8478. * The data cache on JS side.
  8479. * @returns the underlying data as a float array
  8480. */
  8481. getData(): Float32Array;
  8482. /**
  8483. * The underlying WebGL Uniform buffer.
  8484. * @returns the webgl buffer
  8485. */
  8486. getBuffer(): Nullable<DataBuffer>;
  8487. /**
  8488. * std140 layout specifies how to align data within an UBO structure.
  8489. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  8490. * for specs.
  8491. */
  8492. private _fillAlignment;
  8493. /**
  8494. * Adds an uniform in the buffer.
  8495. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  8496. * for the layout to be correct !
  8497. * @param name Name of the uniform, as used in the uniform block in the shader.
  8498. * @param size Data size, or data directly.
  8499. * @param arraySize The number of elements in the array, 0 if not an array.
  8500. */
  8501. addUniform(name: string, size: number | number[], arraySize?: number): void;
  8502. /**
  8503. * Adds a Matrix 4x4 to the uniform buffer.
  8504. * @param name Name of the uniform, as used in the uniform block in the shader.
  8505. * @param mat A 4x4 matrix.
  8506. */
  8507. addMatrix(name: string, mat: Matrix): void;
  8508. /**
  8509. * Adds a vec2 to the uniform buffer.
  8510. * @param name Name of the uniform, as used in the uniform block in the shader.
  8511. * @param x Define the x component value of the vec2
  8512. * @param y Define the y component value of the vec2
  8513. */
  8514. addFloat2(name: string, x: number, y: number): void;
  8515. /**
  8516. * Adds a vec3 to the uniform buffer.
  8517. * @param name Name of the uniform, as used in the uniform block in the shader.
  8518. * @param x Define the x component value of the vec3
  8519. * @param y Define the y component value of the vec3
  8520. * @param z Define the z component value of the vec3
  8521. */
  8522. addFloat3(name: string, x: number, y: number, z: number): void;
  8523. /**
  8524. * Adds a vec3 to the uniform buffer.
  8525. * @param name Name of the uniform, as used in the uniform block in the shader.
  8526. * @param color Define the vec3 from a Color
  8527. */
  8528. addColor3(name: string, color: Color3): void;
  8529. /**
  8530. * Adds a vec4 to the uniform buffer.
  8531. * @param name Name of the uniform, as used in the uniform block in the shader.
  8532. * @param color Define the rgb components from a Color
  8533. * @param alpha Define the a component of the vec4
  8534. */
  8535. addColor4(name: string, color: Color3, alpha: number): void;
  8536. /**
  8537. * Adds a vec3 to the uniform buffer.
  8538. * @param name Name of the uniform, as used in the uniform block in the shader.
  8539. * @param vector Define the vec3 components from a Vector
  8540. */
  8541. addVector3(name: string, vector: Vector3): void;
  8542. /**
  8543. * Adds a Matrix 3x3 to the uniform buffer.
  8544. * @param name Name of the uniform, as used in the uniform block in the shader.
  8545. */
  8546. addMatrix3x3(name: string): void;
  8547. /**
  8548. * Adds a Matrix 2x2 to the uniform buffer.
  8549. * @param name Name of the uniform, as used in the uniform block in the shader.
  8550. */
  8551. addMatrix2x2(name: string): void;
  8552. /**
  8553. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  8554. */
  8555. create(): void;
  8556. /** @hidden */
  8557. _rebuild(): void;
  8558. /** @hidden */
  8559. get _numBuffers(): number;
  8560. /** @hidden */
  8561. get _indexBuffer(): number;
  8562. /** Gets the name of this buffer */
  8563. get name(): string;
  8564. /**
  8565. * Updates the WebGL Uniform Buffer on the GPU.
  8566. * If the `dynamic` flag is set to true, no cache comparison is done.
  8567. * Otherwise, the buffer will be updated only if the cache differs.
  8568. */
  8569. update(): void;
  8570. private _createNewBuffer;
  8571. private _checkNewFrame;
  8572. /**
  8573. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8574. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8575. * @param data Define the flattened data
  8576. * @param size Define the size of the data.
  8577. */
  8578. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  8579. /**
  8580. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  8581. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8582. * @param data Define the flattened data
  8583. * @param size Define the size of the data.
  8584. */
  8585. updateUniformArray(uniformName: string, data: FloatArray, size: number): void;
  8586. private _valueCache;
  8587. private _cacheMatrix;
  8588. private _updateMatrix3x3ForUniform;
  8589. private _updateMatrix3x3ForEffect;
  8590. private _updateMatrix2x2ForEffect;
  8591. private _updateMatrix2x2ForUniform;
  8592. private _updateFloatForEffect;
  8593. private _updateFloatForUniform;
  8594. private _updateFloat2ForEffect;
  8595. private _updateFloat2ForUniform;
  8596. private _updateFloat3ForEffect;
  8597. private _updateFloat3ForUniform;
  8598. private _updateFloat4ForEffect;
  8599. private _updateFloat4ForUniform;
  8600. private _updateFloatArrayForEffect;
  8601. private _updateFloatArrayForUniform;
  8602. private _updateArrayForEffect;
  8603. private _updateArrayForUniform;
  8604. private _updateIntArrayForEffect;
  8605. private _updateIntArrayForUniform;
  8606. private _updateMatrixForEffect;
  8607. private _updateMatrixForUniform;
  8608. private _updateMatricesForEffect;
  8609. private _updateMatricesForUniform;
  8610. private _updateVector3ForEffect;
  8611. private _updateVector3ForUniform;
  8612. private _updateVector4ForEffect;
  8613. private _updateVector4ForUniform;
  8614. private _updateColor3ForEffect;
  8615. private _updateColor3ForUniform;
  8616. private _updateColor4ForEffect;
  8617. private _updateColor4ForUniform;
  8618. private _updateIntForEffect;
  8619. private _updateIntForUniform;
  8620. private _updateInt2ForEffect;
  8621. private _updateInt2ForUniform;
  8622. private _updateInt3ForEffect;
  8623. private _updateInt3ForUniform;
  8624. private _updateInt4ForEffect;
  8625. private _updateInt4ForUniform;
  8626. /**
  8627. * Sets a sampler uniform on the effect.
  8628. * @param name Define the name of the sampler.
  8629. * @param texture Define the texture to set in the sampler
  8630. */
  8631. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  8632. /**
  8633. * Directly updates the value of the uniform in the cache AND on the GPU.
  8634. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  8635. * @param data Define the flattened data
  8636. */
  8637. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  8638. /**
  8639. * Binds this uniform buffer to an effect.
  8640. * @param effect Define the effect to bind the buffer to
  8641. * @param name Name of the uniform block in the shader.
  8642. */
  8643. bindToEffect(effect: Effect, name: string): void;
  8644. /**
  8645. * Disposes the uniform buffer.
  8646. */
  8647. dispose(): void;
  8648. }
  8649. }
  8650. declare module BABYLON {
  8651. /**
  8652. * Manages the defines for the Material
  8653. */
  8654. export class MaterialDefines {
  8655. /** @hidden */
  8656. protected _keys: string[];
  8657. private _isDirty;
  8658. /** @hidden */
  8659. _renderId: number;
  8660. /** @hidden */
  8661. _areLightsDirty: boolean;
  8662. /** @hidden */
  8663. _areLightsDisposed: boolean;
  8664. /** @hidden */
  8665. _areAttributesDirty: boolean;
  8666. /** @hidden */
  8667. _areTexturesDirty: boolean;
  8668. /** @hidden */
  8669. _areFresnelDirty: boolean;
  8670. /** @hidden */
  8671. _areMiscDirty: boolean;
  8672. /** @hidden */
  8673. _arePrePassDirty: boolean;
  8674. /** @hidden */
  8675. _areImageProcessingDirty: boolean;
  8676. /** @hidden */
  8677. _normals: boolean;
  8678. /** @hidden */
  8679. _uvs: boolean;
  8680. /** @hidden */
  8681. _needNormals: boolean;
  8682. /** @hidden */
  8683. _needUVs: boolean;
  8684. [id: string]: any;
  8685. /**
  8686. * Specifies if the material needs to be re-calculated
  8687. */
  8688. get isDirty(): boolean;
  8689. /**
  8690. * Marks the material to indicate that it has been re-calculated
  8691. */
  8692. markAsProcessed(): void;
  8693. /**
  8694. * Marks the material to indicate that it needs to be re-calculated
  8695. */
  8696. markAsUnprocessed(): void;
  8697. /**
  8698. * Marks the material to indicate all of its defines need to be re-calculated
  8699. */
  8700. markAllAsDirty(): void;
  8701. /**
  8702. * Marks the material to indicate that image processing needs to be re-calculated
  8703. */
  8704. markAsImageProcessingDirty(): void;
  8705. /**
  8706. * Marks the material to indicate the lights need to be re-calculated
  8707. * @param disposed Defines whether the light is dirty due to dispose or not
  8708. */
  8709. markAsLightDirty(disposed?: boolean): void;
  8710. /**
  8711. * Marks the attribute state as changed
  8712. */
  8713. markAsAttributesDirty(): void;
  8714. /**
  8715. * Marks the texture state as changed
  8716. */
  8717. markAsTexturesDirty(): void;
  8718. /**
  8719. * Marks the fresnel state as changed
  8720. */
  8721. markAsFresnelDirty(): void;
  8722. /**
  8723. * Marks the misc state as changed
  8724. */
  8725. markAsMiscDirty(): void;
  8726. /**
  8727. * Marks the prepass state as changed
  8728. */
  8729. markAsPrePassDirty(): void;
  8730. /**
  8731. * Rebuilds the material defines
  8732. */
  8733. rebuild(): void;
  8734. /**
  8735. * Specifies if two material defines are equal
  8736. * @param other - A material define instance to compare to
  8737. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8738. */
  8739. isEqual(other: MaterialDefines): boolean;
  8740. /**
  8741. * Clones this instance's defines to another instance
  8742. * @param other - material defines to clone values to
  8743. */
  8744. cloneTo(other: MaterialDefines): void;
  8745. /**
  8746. * Resets the material define values
  8747. */
  8748. reset(): void;
  8749. /**
  8750. * Converts the material define values to a string
  8751. * @returns - String of material define information
  8752. */
  8753. toString(): string;
  8754. }
  8755. }
  8756. declare module BABYLON {
  8757. /**
  8758. * Enum that determines the text-wrapping mode to use.
  8759. */
  8760. export enum InspectableType {
  8761. /**
  8762. * Checkbox for booleans
  8763. */
  8764. Checkbox = 0,
  8765. /**
  8766. * Sliders for numbers
  8767. */
  8768. Slider = 1,
  8769. /**
  8770. * Vector3
  8771. */
  8772. Vector3 = 2,
  8773. /**
  8774. * Quaternions
  8775. */
  8776. Quaternion = 3,
  8777. /**
  8778. * Color3
  8779. */
  8780. Color3 = 4,
  8781. /**
  8782. * String
  8783. */
  8784. String = 5
  8785. }
  8786. /**
  8787. * Interface used to define custom inspectable properties.
  8788. * This interface is used by the inspector to display custom property grids
  8789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8790. */
  8791. export interface IInspectable {
  8792. /**
  8793. * Gets the label to display
  8794. */
  8795. label: string;
  8796. /**
  8797. * Gets the name of the property to edit
  8798. */
  8799. propertyName: string;
  8800. /**
  8801. * Gets the type of the editor to use
  8802. */
  8803. type: InspectableType;
  8804. /**
  8805. * Gets the minimum value of the property when using in "slider" mode
  8806. */
  8807. min?: number;
  8808. /**
  8809. * Gets the maximum value of the property when using in "slider" mode
  8810. */
  8811. max?: number;
  8812. /**
  8813. * Gets the setp to use when using in "slider" mode
  8814. */
  8815. step?: number;
  8816. }
  8817. }
  8818. declare module BABYLON {
  8819. /**
  8820. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  8821. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  8822. * 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.
  8823. */
  8824. export abstract class Light extends Node {
  8825. /**
  8826. * Falloff Default: light is falling off following the material specification:
  8827. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  8828. */
  8829. static readonly FALLOFF_DEFAULT: number;
  8830. /**
  8831. * Falloff Physical: light is falling off following the inverse squared distance law.
  8832. */
  8833. static readonly FALLOFF_PHYSICAL: number;
  8834. /**
  8835. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  8836. * to enhance interoperability with other engines.
  8837. */
  8838. static readonly FALLOFF_GLTF: number;
  8839. /**
  8840. * Falloff Standard: light is falling off like in the standard material
  8841. * to enhance interoperability with other materials.
  8842. */
  8843. static readonly FALLOFF_STANDARD: number;
  8844. /**
  8845. * If every light affecting the material is in this lightmapMode,
  8846. * material.lightmapTexture adds or multiplies
  8847. * (depends on material.useLightmapAsShadowmap)
  8848. * after every other light calculations.
  8849. */
  8850. static readonly LIGHTMAP_DEFAULT: number;
  8851. /**
  8852. * material.lightmapTexture as only diffuse lighting from this light
  8853. * adds only specular lighting from this light
  8854. * adds dynamic shadows
  8855. */
  8856. static readonly LIGHTMAP_SPECULAR: number;
  8857. /**
  8858. * material.lightmapTexture as only lighting
  8859. * no light calculation from this light
  8860. * only adds dynamic shadows from this light
  8861. */
  8862. static readonly LIGHTMAP_SHADOWSONLY: number;
  8863. /**
  8864. * Each light type uses the default quantity according to its type:
  8865. * point/spot lights use luminous intensity
  8866. * directional lights use illuminance
  8867. */
  8868. static readonly INTENSITYMODE_AUTOMATIC: number;
  8869. /**
  8870. * lumen (lm)
  8871. */
  8872. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  8873. /**
  8874. * candela (lm/sr)
  8875. */
  8876. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  8877. /**
  8878. * lux (lm/m^2)
  8879. */
  8880. static readonly INTENSITYMODE_ILLUMINANCE: number;
  8881. /**
  8882. * nit (cd/m^2)
  8883. */
  8884. static readonly INTENSITYMODE_LUMINANCE: number;
  8885. /**
  8886. * Light type const id of the point light.
  8887. */
  8888. static readonly LIGHTTYPEID_POINTLIGHT: number;
  8889. /**
  8890. * Light type const id of the directional light.
  8891. */
  8892. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  8893. /**
  8894. * Light type const id of the spot light.
  8895. */
  8896. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  8897. /**
  8898. * Light type const id of the hemispheric light.
  8899. */
  8900. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  8901. /**
  8902. * Diffuse gives the basic color to an object.
  8903. */
  8904. diffuse: Color3;
  8905. /**
  8906. * Specular produces a highlight color on an object.
  8907. * Note: This is note affecting PBR materials.
  8908. */
  8909. specular: Color3;
  8910. /**
  8911. * Defines the falloff type for this light. This lets overrriding how punctual light are
  8912. * falling off base on range or angle.
  8913. * This can be set to any values in Light.FALLOFF_x.
  8914. *
  8915. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  8916. * other types of materials.
  8917. */
  8918. falloffType: number;
  8919. /**
  8920. * Strength of the light.
  8921. * Note: By default it is define in the framework own unit.
  8922. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  8923. */
  8924. intensity: number;
  8925. private _range;
  8926. protected _inverseSquaredRange: number;
  8927. /**
  8928. * Defines how far from the source the light is impacting in scene units.
  8929. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8930. */
  8931. get range(): number;
  8932. /**
  8933. * Defines how far from the source the light is impacting in scene units.
  8934. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  8935. */
  8936. set range(value: number);
  8937. /**
  8938. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  8939. * of light.
  8940. */
  8941. private _photometricScale;
  8942. private _intensityMode;
  8943. /**
  8944. * Gets the photometric scale used to interpret the intensity.
  8945. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8946. */
  8947. get intensityMode(): number;
  8948. /**
  8949. * Sets the photometric scale used to interpret the intensity.
  8950. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  8951. */
  8952. set intensityMode(value: number);
  8953. private _radius;
  8954. /**
  8955. * Gets the light radius used by PBR Materials to simulate soft area lights.
  8956. */
  8957. get radius(): number;
  8958. /**
  8959. * sets the light radius used by PBR Materials to simulate soft area lights.
  8960. */
  8961. set radius(value: number);
  8962. private _renderPriority;
  8963. /**
  8964. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  8965. * exceeding the number allowed of the materials.
  8966. */
  8967. renderPriority: number;
  8968. private _shadowEnabled;
  8969. /**
  8970. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8971. * the current shadow generator.
  8972. */
  8973. get shadowEnabled(): boolean;
  8974. /**
  8975. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  8976. * the current shadow generator.
  8977. */
  8978. set shadowEnabled(value: boolean);
  8979. private _includedOnlyMeshes;
  8980. /**
  8981. * Gets the only meshes impacted by this light.
  8982. */
  8983. get includedOnlyMeshes(): AbstractMesh[];
  8984. /**
  8985. * Sets the only meshes impacted by this light.
  8986. */
  8987. set includedOnlyMeshes(value: AbstractMesh[]);
  8988. private _excludedMeshes;
  8989. /**
  8990. * Gets the meshes not impacted by this light.
  8991. */
  8992. get excludedMeshes(): AbstractMesh[];
  8993. /**
  8994. * Sets the meshes not impacted by this light.
  8995. */
  8996. set excludedMeshes(value: AbstractMesh[]);
  8997. private _excludeWithLayerMask;
  8998. /**
  8999. * Gets the layer id use to find what meshes are not impacted by the light.
  9000. * Inactive if 0
  9001. */
  9002. get excludeWithLayerMask(): number;
  9003. /**
  9004. * Sets the layer id use to find what meshes are not impacted by the light.
  9005. * Inactive if 0
  9006. */
  9007. set excludeWithLayerMask(value: number);
  9008. private _includeOnlyWithLayerMask;
  9009. /**
  9010. * Gets the layer id use to find what meshes are impacted by the light.
  9011. * Inactive if 0
  9012. */
  9013. get includeOnlyWithLayerMask(): number;
  9014. /**
  9015. * Sets the layer id use to find what meshes are impacted by the light.
  9016. * Inactive if 0
  9017. */
  9018. set includeOnlyWithLayerMask(value: number);
  9019. private _lightmapMode;
  9020. /**
  9021. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9022. */
  9023. get lightmapMode(): number;
  9024. /**
  9025. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9026. */
  9027. set lightmapMode(value: number);
  9028. /**
  9029. * Shadow generator associted to the light.
  9030. * @hidden Internal use only.
  9031. */
  9032. _shadowGenerator: Nullable<IShadowGenerator>;
  9033. /**
  9034. * @hidden Internal use only.
  9035. */
  9036. _excludedMeshesIds: string[];
  9037. /**
  9038. * @hidden Internal use only.
  9039. */
  9040. _includedOnlyMeshesIds: string[];
  9041. /**
  9042. * The current light unifom buffer.
  9043. * @hidden Internal use only.
  9044. */
  9045. _uniformBuffer: UniformBuffer;
  9046. /** @hidden */
  9047. _renderId: number;
  9048. /**
  9049. * Creates a Light object in the scene.
  9050. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9051. * @param name The firendly name of the light
  9052. * @param scene The scene the light belongs too
  9053. */
  9054. constructor(name: string, scene: Scene);
  9055. protected abstract _buildUniformLayout(): void;
  9056. /**
  9057. * Sets the passed Effect "effect" with the Light information.
  9058. * @param effect The effect to update
  9059. * @param lightIndex The index of the light in the effect to update
  9060. * @returns The light
  9061. */
  9062. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9063. /**
  9064. * Sets the passed Effect "effect" with the Light textures.
  9065. * @param effect The effect to update
  9066. * @param lightIndex The index of the light in the effect to update
  9067. * @returns The light
  9068. */
  9069. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  9070. /**
  9071. * Binds the lights information from the scene to the effect for the given mesh.
  9072. * @param lightIndex Light index
  9073. * @param scene The scene where the light belongs to
  9074. * @param effect The effect we are binding the data to
  9075. * @param useSpecular Defines if specular is supported
  9076. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9077. */
  9078. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9079. /**
  9080. * Sets the passed Effect "effect" with the Light information.
  9081. * @param effect The effect to update
  9082. * @param lightDataUniformName The uniform used to store light data (position or direction)
  9083. * @returns The light
  9084. */
  9085. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  9086. /**
  9087. * Returns the string "Light".
  9088. * @returns the class name
  9089. */
  9090. getClassName(): string;
  9091. /** @hidden */
  9092. readonly _isLight: boolean;
  9093. /**
  9094. * Converts the light information to a readable string for debug purpose.
  9095. * @param fullDetails Supports for multiple levels of logging within scene loading
  9096. * @returns the human readable light info
  9097. */
  9098. toString(fullDetails?: boolean): string;
  9099. /** @hidden */
  9100. protected _syncParentEnabledState(): void;
  9101. /**
  9102. * Set the enabled state of this node.
  9103. * @param value - the new enabled state
  9104. */
  9105. setEnabled(value: boolean): void;
  9106. /**
  9107. * Returns the Light associated shadow generator if any.
  9108. * @return the associated shadow generator.
  9109. */
  9110. getShadowGenerator(): Nullable<IShadowGenerator>;
  9111. /**
  9112. * Returns a Vector3, the absolute light position in the World.
  9113. * @returns the world space position of the light
  9114. */
  9115. getAbsolutePosition(): Vector3;
  9116. /**
  9117. * Specifies if the light will affect the passed mesh.
  9118. * @param mesh The mesh to test against the light
  9119. * @return true the mesh is affected otherwise, false.
  9120. */
  9121. canAffectMesh(mesh: AbstractMesh): boolean;
  9122. /**
  9123. * Sort function to order lights for rendering.
  9124. * @param a First Light object to compare to second.
  9125. * @param b Second Light object to compare first.
  9126. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9127. */
  9128. static CompareLightsPriority(a: Light, b: Light): number;
  9129. /**
  9130. * Releases resources associated with this node.
  9131. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9132. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9133. */
  9134. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9135. /**
  9136. * Returns the light type ID (integer).
  9137. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9138. */
  9139. getTypeID(): number;
  9140. /**
  9141. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9142. * @returns the scaled intensity in intensity mode unit
  9143. */
  9144. getScaledIntensity(): number;
  9145. /**
  9146. * Returns a new Light object, named "name", from the current one.
  9147. * @param name The name of the cloned light
  9148. * @param newParent The parent of this light, if it has one
  9149. * @returns the new created light
  9150. */
  9151. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  9152. /**
  9153. * Serializes the current light into a Serialization object.
  9154. * @returns the serialized object.
  9155. */
  9156. serialize(): any;
  9157. /**
  9158. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9159. * This new light is named "name" and added to the passed scene.
  9160. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9161. * @param name The friendly name of the light
  9162. * @param scene The scene the new light will belong to
  9163. * @returns the constructor function
  9164. */
  9165. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9166. /**
  9167. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9168. * @param parsedLight The JSON representation of the light
  9169. * @param scene The scene to create the parsed light in
  9170. * @returns the created light after parsing
  9171. */
  9172. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9173. private _hookArrayForExcluded;
  9174. private _hookArrayForIncludedOnly;
  9175. private _resyncMeshes;
  9176. /**
  9177. * Forces the meshes to update their light related information in their rendering used effects
  9178. * @hidden Internal Use Only
  9179. */
  9180. _markMeshesAsLightDirty(): void;
  9181. /**
  9182. * Recomputes the cached photometric scale if needed.
  9183. */
  9184. private _computePhotometricScale;
  9185. /**
  9186. * Returns the Photometric Scale according to the light type and intensity mode.
  9187. */
  9188. private _getPhotometricScale;
  9189. /**
  9190. * Reorder the light in the scene according to their defined priority.
  9191. * @hidden Internal Use Only
  9192. */
  9193. _reorderLightsInScene(): void;
  9194. /**
  9195. * Prepares the list of defines specific to the light type.
  9196. * @param defines the list of defines
  9197. * @param lightIndex defines the index of the light for the effect
  9198. */
  9199. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9200. }
  9201. }
  9202. declare module BABYLON {
  9203. /** Defines supported spaces */
  9204. export enum Space {
  9205. /** Local (object) space */
  9206. LOCAL = 0,
  9207. /** World space */
  9208. WORLD = 1,
  9209. /** Bone space */
  9210. BONE = 2
  9211. }
  9212. /** Defines the 3 main axes */
  9213. export class Axis {
  9214. /** X axis */
  9215. static X: Vector3;
  9216. /** Y axis */
  9217. static Y: Vector3;
  9218. /** Z axis */
  9219. static Z: Vector3;
  9220. }
  9221. /**
  9222. * Defines cartesian components.
  9223. */
  9224. export enum Coordinate {
  9225. /** X axis */
  9226. X = 0,
  9227. /** Y axis */
  9228. Y = 1,
  9229. /** Z axis */
  9230. Z = 2
  9231. }
  9232. }
  9233. declare module BABYLON {
  9234. /**
  9235. * Interface describing all the common properties and methods a shadow light needs to implement.
  9236. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9237. * as well as binding the different shadow properties to the effects.
  9238. */
  9239. export interface IShadowLight extends Light {
  9240. /**
  9241. * The light id in the scene (used in scene.findLighById for instance)
  9242. */
  9243. id: string;
  9244. /**
  9245. * The position the shdow will be casted from.
  9246. */
  9247. position: Vector3;
  9248. /**
  9249. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9250. */
  9251. direction: Vector3;
  9252. /**
  9253. * The transformed position. Position of the light in world space taking parenting in account.
  9254. */
  9255. transformedPosition: Vector3;
  9256. /**
  9257. * The transformed direction. Direction of the light in world space taking parenting in account.
  9258. */
  9259. transformedDirection: Vector3;
  9260. /**
  9261. * The friendly name of the light in the scene.
  9262. */
  9263. name: string;
  9264. /**
  9265. * Defines the shadow projection clipping minimum z value.
  9266. */
  9267. shadowMinZ: number;
  9268. /**
  9269. * Defines the shadow projection clipping maximum z value.
  9270. */
  9271. shadowMaxZ: number;
  9272. /**
  9273. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9274. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9275. */
  9276. computeTransformedInformation(): boolean;
  9277. /**
  9278. * Gets the scene the light belongs to.
  9279. * @returns The scene
  9280. */
  9281. getScene(): Scene;
  9282. /**
  9283. * Callback defining a custom Projection Matrix Builder.
  9284. * This can be used to override the default projection matrix computation.
  9285. */
  9286. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9287. /**
  9288. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9289. * @param matrix The materix to updated with the projection information
  9290. * @param viewMatrix The transform matrix of the light
  9291. * @param renderList The list of mesh to render in the map
  9292. * @returns The current light
  9293. */
  9294. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9295. /**
  9296. * Gets the current depth scale used in ESM.
  9297. * @returns The scale
  9298. */
  9299. getDepthScale(): number;
  9300. /**
  9301. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9302. * @returns true if a cube texture needs to be use
  9303. */
  9304. needCube(): boolean;
  9305. /**
  9306. * Detects if the projection matrix requires to be recomputed this frame.
  9307. * @returns true if it requires to be recomputed otherwise, false.
  9308. */
  9309. needProjectionMatrixCompute(): boolean;
  9310. /**
  9311. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9312. */
  9313. forceProjectionMatrixCompute(): void;
  9314. /**
  9315. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9316. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9317. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9318. */
  9319. getShadowDirection(faceIndex?: number): Vector3;
  9320. /**
  9321. * Gets the minZ used for shadow according to both the scene and the light.
  9322. * @param activeCamera The camera we are returning the min for
  9323. * @returns the depth min z
  9324. */
  9325. getDepthMinZ(activeCamera: Camera): number;
  9326. /**
  9327. * Gets the maxZ used for shadow according to both the scene and the light.
  9328. * @param activeCamera The camera we are returning the max for
  9329. * @returns the depth max z
  9330. */
  9331. getDepthMaxZ(activeCamera: Camera): number;
  9332. }
  9333. /**
  9334. * Base implementation IShadowLight
  9335. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9336. */
  9337. export abstract class ShadowLight extends Light implements IShadowLight {
  9338. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9339. protected _position: Vector3;
  9340. protected _setPosition(value: Vector3): void;
  9341. /**
  9342. * Sets the position the shadow will be casted from. Also use as the light position for both
  9343. * point and spot lights.
  9344. */
  9345. get position(): Vector3;
  9346. /**
  9347. * Sets the position the shadow will be casted from. Also use as the light position for both
  9348. * point and spot lights.
  9349. */
  9350. set position(value: Vector3);
  9351. protected _direction: Vector3;
  9352. protected _setDirection(value: Vector3): void;
  9353. /**
  9354. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9355. * Also use as the light direction on spot and directional lights.
  9356. */
  9357. get direction(): Vector3;
  9358. /**
  9359. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9360. * Also use as the light direction on spot and directional lights.
  9361. */
  9362. set direction(value: Vector3);
  9363. protected _shadowMinZ: number;
  9364. /**
  9365. * Gets the shadow projection clipping minimum z value.
  9366. */
  9367. get shadowMinZ(): number;
  9368. /**
  9369. * Sets the shadow projection clipping minimum z value.
  9370. */
  9371. set shadowMinZ(value: number);
  9372. protected _shadowMaxZ: number;
  9373. /**
  9374. * Sets the shadow projection clipping maximum z value.
  9375. */
  9376. get shadowMaxZ(): number;
  9377. /**
  9378. * Gets the shadow projection clipping maximum z value.
  9379. */
  9380. set shadowMaxZ(value: number);
  9381. /**
  9382. * Callback defining a custom Projection Matrix Builder.
  9383. * This can be used to override the default projection matrix computation.
  9384. */
  9385. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9386. /**
  9387. * The transformed position. Position of the light in world space taking parenting in account.
  9388. */
  9389. transformedPosition: Vector3;
  9390. /**
  9391. * The transformed direction. Direction of the light in world space taking parenting in account.
  9392. */
  9393. transformedDirection: Vector3;
  9394. private _needProjectionMatrixCompute;
  9395. /**
  9396. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9397. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9398. */
  9399. computeTransformedInformation(): boolean;
  9400. /**
  9401. * Return the depth scale used for the shadow map.
  9402. * @returns the depth scale.
  9403. */
  9404. getDepthScale(): number;
  9405. /**
  9406. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9409. */
  9410. getShadowDirection(faceIndex?: number): Vector3;
  9411. /**
  9412. * Returns the ShadowLight absolute position in the World.
  9413. * @returns the position vector in world space
  9414. */
  9415. getAbsolutePosition(): Vector3;
  9416. /**
  9417. * Sets the ShadowLight direction toward the passed target.
  9418. * @param target The point to target in local space
  9419. * @returns the updated ShadowLight direction
  9420. */
  9421. setDirectionToTarget(target: Vector3): Vector3;
  9422. /**
  9423. * Returns the light rotation in euler definition.
  9424. * @returns the x y z rotation in local space.
  9425. */
  9426. getRotation(): Vector3;
  9427. /**
  9428. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9429. * @returns true if a cube texture needs to be use
  9430. */
  9431. needCube(): boolean;
  9432. /**
  9433. * Detects if the projection matrix requires to be recomputed this frame.
  9434. * @returns true if it requires to be recomputed otherwise, false.
  9435. */
  9436. needProjectionMatrixCompute(): boolean;
  9437. /**
  9438. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9439. */
  9440. forceProjectionMatrixCompute(): void;
  9441. /** @hidden */
  9442. _initCache(): void;
  9443. /** @hidden */
  9444. _isSynchronized(): boolean;
  9445. /**
  9446. * Computes the world matrix of the node
  9447. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9448. * @returns the world matrix
  9449. */
  9450. computeWorldMatrix(force?: boolean): Matrix;
  9451. /**
  9452. * Gets the minZ used for shadow according to both the scene and the light.
  9453. * @param activeCamera The camera we are returning the min for
  9454. * @returns the depth min z
  9455. */
  9456. getDepthMinZ(activeCamera: Camera): number;
  9457. /**
  9458. * Gets the maxZ used for shadow according to both the scene and the light.
  9459. * @param activeCamera The camera we are returning the max for
  9460. * @returns the depth max z
  9461. */
  9462. getDepthMaxZ(activeCamera: Camera): number;
  9463. /**
  9464. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9465. * @param matrix The materix to updated with the projection information
  9466. * @param viewMatrix The transform matrix of the light
  9467. * @param renderList The list of mesh to render in the map
  9468. * @returns The current light
  9469. */
  9470. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9471. }
  9472. }
  9473. declare module BABYLON {
  9474. /**
  9475. * Configuration needed for prepass-capable materials
  9476. */
  9477. export class PrePassConfiguration {
  9478. /**
  9479. * Previous world matrices of meshes carrying this material
  9480. * Used for computing velocity
  9481. */
  9482. previousWorldMatrices: {
  9483. [index: number]: Matrix;
  9484. };
  9485. /**
  9486. * Previous view project matrix
  9487. * Used for computing velocity
  9488. */
  9489. previousViewProjection: Matrix;
  9490. /**
  9491. * Previous bones of meshes carrying this material
  9492. * Used for computing velocity
  9493. */
  9494. previousBones: {
  9495. [index: number]: Float32Array;
  9496. };
  9497. /**
  9498. * Add the required uniforms to the current list.
  9499. * @param uniforms defines the current uniform list.
  9500. */
  9501. static AddUniforms(uniforms: string[]): void;
  9502. /**
  9503. * Add the required samplers to the current list.
  9504. * @param samplers defines the current sampler list.
  9505. */
  9506. static AddSamplers(samplers: string[]): void;
  9507. /**
  9508. * Binds the material data.
  9509. * @param effect defines the effect to update
  9510. * @param scene defines the scene the material belongs to.
  9511. * @param mesh The mesh
  9512. * @param world World matrix of this mesh
  9513. * @param isFrozen Is the material frozen
  9514. */
  9515. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  9516. }
  9517. }
  9518. declare module BABYLON {
  9519. /**
  9520. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  9521. * This is the base of the follow, arc rotate cameras and Free camera
  9522. * @see https://doc.babylonjs.com/features/cameras
  9523. */
  9524. export class TargetCamera extends Camera {
  9525. private static _RigCamTransformMatrix;
  9526. private static _TargetTransformMatrix;
  9527. private static _TargetFocalPoint;
  9528. private _tmpUpVector;
  9529. private _tmpTargetVector;
  9530. /**
  9531. * Define the current direction the camera is moving to
  9532. */
  9533. cameraDirection: Vector3;
  9534. /**
  9535. * Define the current rotation the camera is rotating to
  9536. */
  9537. cameraRotation: Vector2;
  9538. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  9539. ignoreParentScaling: boolean;
  9540. /**
  9541. * When set, the up vector of the camera will be updated by the rotation of the camera
  9542. */
  9543. updateUpVectorFromRotation: boolean;
  9544. private _tmpQuaternion;
  9545. /**
  9546. * Define the current rotation of the camera
  9547. */
  9548. rotation: Vector3;
  9549. /**
  9550. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  9551. */
  9552. rotationQuaternion: Quaternion;
  9553. /**
  9554. * Define the current speed of the camera
  9555. */
  9556. speed: number;
  9557. /**
  9558. * Add constraint to the camera to prevent it to move freely in all directions and
  9559. * around all axis.
  9560. */
  9561. noRotationConstraint: boolean;
  9562. /**
  9563. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  9564. * panning
  9565. */
  9566. invertRotation: boolean;
  9567. /**
  9568. * Speed multiplier for inverse camera panning
  9569. */
  9570. inverseRotationSpeed: number;
  9571. /**
  9572. * Define the current target of the camera as an object or a position.
  9573. */
  9574. lockedTarget: any;
  9575. /** @hidden */
  9576. _currentTarget: Vector3;
  9577. /** @hidden */
  9578. _initialFocalDistance: number;
  9579. /** @hidden */
  9580. _viewMatrix: Matrix;
  9581. /** @hidden */
  9582. _camMatrix: Matrix;
  9583. /** @hidden */
  9584. _cameraTransformMatrix: Matrix;
  9585. /** @hidden */
  9586. _cameraRotationMatrix: Matrix;
  9587. /** @hidden */
  9588. _referencePoint: Vector3;
  9589. /** @hidden */
  9590. _transformedReferencePoint: Vector3;
  9591. /** @hidden */
  9592. _reset: () => void;
  9593. private _defaultUp;
  9594. /**
  9595. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  9596. * This is the base of the follow, arc rotate cameras and Free camera
  9597. * @see https://doc.babylonjs.com/features/cameras
  9598. * @param name Defines the name of the camera in the scene
  9599. * @param position Defines the start position of the camera in the scene
  9600. * @param scene Defines the scene the camera belongs to
  9601. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  9602. */
  9603. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  9604. /**
  9605. * Gets the position in front of the camera at a given distance.
  9606. * @param distance The distance from the camera we want the position to be
  9607. * @returns the position
  9608. */
  9609. getFrontPosition(distance: number): Vector3;
  9610. /** @hidden */
  9611. _getLockedTargetPosition(): Nullable<Vector3>;
  9612. private _storedPosition;
  9613. private _storedRotation;
  9614. private _storedRotationQuaternion;
  9615. /**
  9616. * Store current camera state of the camera (fov, position, rotation, etc..)
  9617. * @returns the camera
  9618. */
  9619. storeState(): Camera;
  9620. /**
  9621. * Restored camera state. You must call storeState() first
  9622. * @returns whether it was successful or not
  9623. * @hidden
  9624. */
  9625. _restoreStateValues(): boolean;
  9626. /** @hidden */
  9627. _initCache(): void;
  9628. /** @hidden */
  9629. _updateCache(ignoreParentClass?: boolean): void;
  9630. /** @hidden */
  9631. _isSynchronizedViewMatrix(): boolean;
  9632. /** @hidden */
  9633. _computeLocalCameraSpeed(): number;
  9634. /**
  9635. * Defines the target the camera should look at.
  9636. * @param target Defines the new target as a Vector or a mesh
  9637. */
  9638. setTarget(target: Vector3): void;
  9639. /**
  9640. * Defines the target point of the camera.
  9641. * The camera looks towards it form the radius distance.
  9642. */
  9643. get target(): Vector3;
  9644. set target(value: Vector3);
  9645. /**
  9646. * Return the current target position of the camera. This value is expressed in local space.
  9647. * @returns the target position
  9648. */
  9649. getTarget(): Vector3;
  9650. /** @hidden */
  9651. _decideIfNeedsToMove(): boolean;
  9652. /** @hidden */
  9653. _updatePosition(): void;
  9654. /** @hidden */
  9655. _checkInputs(): void;
  9656. protected _updateCameraRotationMatrix(): void;
  9657. /**
  9658. * 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)
  9659. * @returns the current camera
  9660. */
  9661. private _rotateUpVectorWithCameraRotationMatrix;
  9662. private _cachedRotationZ;
  9663. private _cachedQuaternionRotationZ;
  9664. /** @hidden */
  9665. _getViewMatrix(): Matrix;
  9666. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  9667. /**
  9668. * @hidden
  9669. */
  9670. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  9671. /**
  9672. * @hidden
  9673. */
  9674. _updateRigCameras(): void;
  9675. private _getRigCamPositionAndTarget;
  9676. /**
  9677. * Gets the current object class name.
  9678. * @return the class name
  9679. */
  9680. getClassName(): string;
  9681. }
  9682. }
  9683. declare module BABYLON {
  9684. /**
  9685. * @ignore
  9686. * This is a list of all the different input types that are available in the application.
  9687. * Fo instance: ArcRotateCameraGamepadInput...
  9688. */
  9689. export var CameraInputTypes: {};
  9690. /**
  9691. * This is the contract to implement in order to create a new input class.
  9692. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  9693. */
  9694. export interface ICameraInput<TCamera extends Camera> {
  9695. /**
  9696. * Defines the camera the input is attached to.
  9697. */
  9698. camera: Nullable<TCamera>;
  9699. /**
  9700. * Gets the class name of the current intput.
  9701. * @returns the class name
  9702. */
  9703. getClassName(): string;
  9704. /**
  9705. * Get the friendly name associated with the input class.
  9706. * @returns the input friendly name
  9707. */
  9708. getSimpleName(): string;
  9709. /**
  9710. * Attach the input controls to a specific dom element to get the input from.
  9711. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9712. */
  9713. attachControl(noPreventDefault?: boolean): void;
  9714. /**
  9715. * Detach the current controls from the specified dom element.
  9716. */
  9717. detachControl(): void;
  9718. /**
  9719. * Update the current camera state depending on the inputs that have been used this frame.
  9720. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9721. */
  9722. checkInputs?: () => void;
  9723. }
  9724. /**
  9725. * Represents a map of input types to input instance or input index to input instance.
  9726. */
  9727. export interface CameraInputsMap<TCamera extends Camera> {
  9728. /**
  9729. * Accessor to the input by input type.
  9730. */
  9731. [name: string]: ICameraInput<TCamera>;
  9732. /**
  9733. * Accessor to the input by input index.
  9734. */
  9735. [idx: number]: ICameraInput<TCamera>;
  9736. }
  9737. /**
  9738. * This represents the input manager used within a camera.
  9739. * It helps dealing with all the different kind of input attached to a camera.
  9740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9741. */
  9742. export class CameraInputsManager<TCamera extends Camera> {
  9743. /**
  9744. * Defines the list of inputs attahed to the camera.
  9745. */
  9746. attached: CameraInputsMap<TCamera>;
  9747. /**
  9748. * Defines the dom element the camera is collecting inputs from.
  9749. * This is null if the controls have not been attached.
  9750. */
  9751. attachedToElement: boolean;
  9752. /**
  9753. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9754. */
  9755. noPreventDefault: boolean;
  9756. /**
  9757. * Defined the camera the input manager belongs to.
  9758. */
  9759. camera: TCamera;
  9760. /**
  9761. * Update the current camera state depending on the inputs that have been used this frame.
  9762. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9763. */
  9764. checkInputs: () => void;
  9765. /**
  9766. * Instantiate a new Camera Input Manager.
  9767. * @param camera Defines the camera the input manager blongs to
  9768. */
  9769. constructor(camera: TCamera);
  9770. /**
  9771. * Add an input method to a camera
  9772. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9773. * @param input camera input method
  9774. */
  9775. add(input: ICameraInput<TCamera>): void;
  9776. /**
  9777. * Remove a specific input method from a camera
  9778. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  9779. * @param inputToRemove camera input method
  9780. */
  9781. remove(inputToRemove: ICameraInput<TCamera>): void;
  9782. /**
  9783. * Remove a specific input type from a camera
  9784. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  9785. * @param inputType the type of the input to remove
  9786. */
  9787. removeByType(inputType: string): void;
  9788. private _addCheckInputs;
  9789. /**
  9790. * Attach the input controls to the currently attached dom element to listen the events from.
  9791. * @param input Defines the input to attach
  9792. */
  9793. attachInput(input: ICameraInput<TCamera>): void;
  9794. /**
  9795. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9796. * @param element Defines the dom element to collect the events from
  9797. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9798. */
  9799. attachElement(noPreventDefault?: boolean): void;
  9800. /**
  9801. * Detach the current manager inputs controls from a specific dom element.
  9802. * @param element Defines the dom element to collect the events from
  9803. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9804. */
  9805. detachElement(disconnect?: boolean): void;
  9806. /**
  9807. * Rebuild the dynamic inputCheck function from the current list of
  9808. * defined inputs in the manager.
  9809. */
  9810. rebuildInputCheck(): void;
  9811. /**
  9812. * Remove all attached input methods from a camera
  9813. */
  9814. clear(): void;
  9815. /**
  9816. * Serialize the current input manager attached to a camera.
  9817. * This ensures than once parsed,
  9818. * the input associated to the camera will be identical to the current ones
  9819. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9820. */
  9821. serialize(serializedCamera: any): void;
  9822. /**
  9823. * Parses an input manager serialized JSON to restore the previous list of inputs
  9824. * and states associated to a camera.
  9825. * @param parsedCamera Defines the JSON to parse
  9826. */
  9827. parse(parsedCamera: any): void;
  9828. }
  9829. }
  9830. declare module BABYLON {
  9831. /**
  9832. * Gather the list of keyboard event types as constants.
  9833. */
  9834. export class KeyboardEventTypes {
  9835. /**
  9836. * The keydown event is fired when a key becomes active (pressed).
  9837. */
  9838. static readonly KEYDOWN: number;
  9839. /**
  9840. * The keyup event is fired when a key has been released.
  9841. */
  9842. static readonly KEYUP: number;
  9843. }
  9844. /**
  9845. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9846. */
  9847. export class KeyboardInfo {
  9848. /**
  9849. * Defines the type of event (KeyboardEventTypes)
  9850. */
  9851. type: number;
  9852. /**
  9853. * Defines the related dom event
  9854. */
  9855. event: KeyboardEvent;
  9856. /**
  9857. * Instantiates a new keyboard info.
  9858. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9859. * @param type Defines the type of event (KeyboardEventTypes)
  9860. * @param event Defines the related dom event
  9861. */
  9862. constructor(
  9863. /**
  9864. * Defines the type of event (KeyboardEventTypes)
  9865. */
  9866. type: number,
  9867. /**
  9868. * Defines the related dom event
  9869. */
  9870. event: KeyboardEvent);
  9871. }
  9872. /**
  9873. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9874. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9875. */
  9876. export class KeyboardInfoPre extends KeyboardInfo {
  9877. /**
  9878. * Defines the type of event (KeyboardEventTypes)
  9879. */
  9880. type: number;
  9881. /**
  9882. * Defines the related dom event
  9883. */
  9884. event: KeyboardEvent;
  9885. /**
  9886. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9887. */
  9888. skipOnPointerObservable: boolean;
  9889. /**
  9890. * Instantiates a new keyboard pre info.
  9891. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9892. * @param type Defines the type of event (KeyboardEventTypes)
  9893. * @param event Defines the related dom event
  9894. */
  9895. constructor(
  9896. /**
  9897. * Defines the type of event (KeyboardEventTypes)
  9898. */
  9899. type: number,
  9900. /**
  9901. * Defines the related dom event
  9902. */
  9903. event: KeyboardEvent);
  9904. }
  9905. }
  9906. declare module BABYLON {
  9907. /**
  9908. * Manage the keyboard inputs to control the movement of a free camera.
  9909. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  9910. */
  9911. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9912. /**
  9913. * Defines the camera the input is attached to.
  9914. */
  9915. camera: FreeCamera;
  9916. /**
  9917. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9918. */
  9919. keysUp: number[];
  9920. /**
  9921. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  9922. */
  9923. keysUpward: number[];
  9924. /**
  9925. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9926. */
  9927. keysDown: number[];
  9928. /**
  9929. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  9930. */
  9931. keysDownward: number[];
  9932. /**
  9933. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9934. */
  9935. keysLeft: number[];
  9936. /**
  9937. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9938. */
  9939. keysRight: number[];
  9940. private _keys;
  9941. private _onCanvasBlurObserver;
  9942. private _onKeyboardObserver;
  9943. private _engine;
  9944. private _scene;
  9945. /**
  9946. * Attach the input controls to a specific dom element to get the input from.
  9947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9948. */
  9949. attachControl(noPreventDefault?: boolean): void;
  9950. /**
  9951. * Detach the current controls from the specified dom element.
  9952. */
  9953. detachControl(): void;
  9954. /**
  9955. * Update the current camera state depending on the inputs that have been used this frame.
  9956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9957. */
  9958. checkInputs(): void;
  9959. /**
  9960. * Gets the class name of the current intput.
  9961. * @returns the class name
  9962. */
  9963. getClassName(): string;
  9964. /** @hidden */
  9965. _onLostFocus(): void;
  9966. /**
  9967. * Get the friendly name associated with the input class.
  9968. * @returns the input friendly name
  9969. */
  9970. getSimpleName(): string;
  9971. }
  9972. }
  9973. declare module BABYLON {
  9974. /**
  9975. * Interface used to define Action
  9976. */
  9977. export interface IAction {
  9978. /**
  9979. * Trigger for the action
  9980. */
  9981. trigger: number;
  9982. /** Options of the trigger */
  9983. triggerOptions: any;
  9984. /**
  9985. * Gets the trigger parameters
  9986. * @returns the trigger parameters
  9987. */
  9988. getTriggerParameter(): any;
  9989. /**
  9990. * Internal only - executes current action event
  9991. * @hidden
  9992. */
  9993. _executeCurrent(evt?: ActionEvent): void;
  9994. /**
  9995. * Serialize placeholder for child classes
  9996. * @param parent of child
  9997. * @returns the serialized object
  9998. */
  9999. serialize(parent: any): any;
  10000. /**
  10001. * Internal only
  10002. * @hidden
  10003. */
  10004. _prepare(): void;
  10005. /**
  10006. * Internal only - manager for action
  10007. * @hidden
  10008. */
  10009. _actionManager: Nullable<AbstractActionManager>;
  10010. /**
  10011. * Adds action to chain of actions, may be a DoNothingAction
  10012. * @param action defines the next action to execute
  10013. * @returns The action passed in
  10014. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10015. */
  10016. then(action: IAction): IAction;
  10017. }
  10018. /**
  10019. * The action to be carried out following a trigger
  10020. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10021. */
  10022. export class Action implements IAction {
  10023. /** the trigger, with or without parameters, for the action */
  10024. triggerOptions: any;
  10025. /**
  10026. * Trigger for the action
  10027. */
  10028. trigger: number;
  10029. /**
  10030. * Internal only - manager for action
  10031. * @hidden
  10032. */
  10033. _actionManager: ActionManager;
  10034. private _nextActiveAction;
  10035. private _child;
  10036. private _condition?;
  10037. private _triggerParameter;
  10038. /**
  10039. * An event triggered prior to action being executed.
  10040. */
  10041. onBeforeExecuteObservable: Observable<Action>;
  10042. /**
  10043. * Creates a new Action
  10044. * @param triggerOptions the trigger, with or without parameters, for the action
  10045. * @param condition an optional determinant of action
  10046. */
  10047. constructor(
  10048. /** the trigger, with or without parameters, for the action */
  10049. triggerOptions: any, condition?: Condition);
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */
  10054. _prepare(): void;
  10055. /**
  10056. * Gets the trigger parameter
  10057. * @returns the trigger parameter
  10058. */
  10059. getTriggerParameter(): any;
  10060. /**
  10061. * Sets the trigger parameter
  10062. * @param value defines the new trigger parameter
  10063. */
  10064. setTriggerParameter(value: any): void;
  10065. /**
  10066. * Internal only - executes current action event
  10067. * @hidden
  10068. */
  10069. _executeCurrent(evt?: ActionEvent): void;
  10070. /**
  10071. * Execute placeholder for child classes
  10072. * @param evt optional action event
  10073. */
  10074. execute(evt?: ActionEvent): void;
  10075. /**
  10076. * Skips to next active action
  10077. */
  10078. skipToNextActiveAction(): void;
  10079. /**
  10080. * Adds action to chain of actions, may be a DoNothingAction
  10081. * @param action defines the next action to execute
  10082. * @returns The action passed in
  10083. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10084. */
  10085. then(action: Action): Action;
  10086. /**
  10087. * Internal only
  10088. * @hidden
  10089. */
  10090. _getProperty(propertyPath: string): string;
  10091. /**
  10092. * Internal only
  10093. * @hidden
  10094. */
  10095. _getEffectiveTarget(target: any, propertyPath: string): any;
  10096. /**
  10097. * Serialize placeholder for child classes
  10098. * @param parent of child
  10099. * @returns the serialized object
  10100. */
  10101. serialize(parent: any): any;
  10102. /**
  10103. * Internal only called by serialize
  10104. * @hidden
  10105. */
  10106. protected _serialize(serializedAction: any, parent?: any): any;
  10107. /**
  10108. * Internal only
  10109. * @hidden
  10110. */
  10111. static _SerializeValueAsString: (value: any) => string;
  10112. /**
  10113. * Internal only
  10114. * @hidden
  10115. */
  10116. static _GetTargetProperty: (target: Scene | Node) => {
  10117. name: string;
  10118. targetType: string;
  10119. value: string;
  10120. };
  10121. }
  10122. }
  10123. declare module BABYLON {
  10124. /**
  10125. * A Condition applied to an Action
  10126. */
  10127. export class Condition {
  10128. /**
  10129. * Internal only - manager for action
  10130. * @hidden
  10131. */
  10132. _actionManager: ActionManager;
  10133. /**
  10134. * Internal only
  10135. * @hidden
  10136. */
  10137. _evaluationId: number;
  10138. /**
  10139. * Internal only
  10140. * @hidden
  10141. */
  10142. _currentResult: boolean;
  10143. /**
  10144. * Creates a new Condition
  10145. * @param actionManager the manager of the action the condition is applied to
  10146. */
  10147. constructor(actionManager: ActionManager);
  10148. /**
  10149. * Check if the current condition is valid
  10150. * @returns a boolean
  10151. */
  10152. isValid(): boolean;
  10153. /**
  10154. * Internal only
  10155. * @hidden
  10156. */
  10157. _getProperty(propertyPath: string): string;
  10158. /**
  10159. * Internal only
  10160. * @hidden
  10161. */
  10162. _getEffectiveTarget(target: any, propertyPath: string): any;
  10163. /**
  10164. * Serialize placeholder for child classes
  10165. * @returns the serialized object
  10166. */
  10167. serialize(): any;
  10168. /**
  10169. * Internal only
  10170. * @hidden
  10171. */
  10172. protected _serialize(serializedCondition: any): any;
  10173. }
  10174. /**
  10175. * Defines specific conditional operators as extensions of Condition
  10176. */
  10177. export class ValueCondition extends Condition {
  10178. /** path to specify the property of the target the conditional operator uses */
  10179. propertyPath: string;
  10180. /** the value compared by the conditional operator against the current value of the property */
  10181. value: any;
  10182. /** the conditional operator, default ValueCondition.IsEqual */
  10183. operator: number;
  10184. /**
  10185. * Internal only
  10186. * @hidden
  10187. */
  10188. private static _IsEqual;
  10189. /**
  10190. * Internal only
  10191. * @hidden
  10192. */
  10193. private static _IsDifferent;
  10194. /**
  10195. * Internal only
  10196. * @hidden
  10197. */
  10198. private static _IsGreater;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private static _IsLesser;
  10204. /**
  10205. * returns the number for IsEqual
  10206. */
  10207. static get IsEqual(): number;
  10208. /**
  10209. * Returns the number for IsDifferent
  10210. */
  10211. static get IsDifferent(): number;
  10212. /**
  10213. * Returns the number for IsGreater
  10214. */
  10215. static get IsGreater(): number;
  10216. /**
  10217. * Returns the number for IsLesser
  10218. */
  10219. static get IsLesser(): number;
  10220. /**
  10221. * Internal only The action manager for the condition
  10222. * @hidden
  10223. */
  10224. _actionManager: ActionManager;
  10225. /**
  10226. * Internal only
  10227. * @hidden
  10228. */
  10229. private _target;
  10230. /**
  10231. * Internal only
  10232. * @hidden
  10233. */
  10234. private _effectiveTarget;
  10235. /**
  10236. * Internal only
  10237. * @hidden
  10238. */
  10239. private _property;
  10240. /**
  10241. * Creates a new ValueCondition
  10242. * @param actionManager manager for the action the condition applies to
  10243. * @param target for the action
  10244. * @param propertyPath path to specify the property of the target the conditional operator uses
  10245. * @param value the value compared by the conditional operator against the current value of the property
  10246. * @param operator the conditional operator, default ValueCondition.IsEqual
  10247. */
  10248. constructor(actionManager: ActionManager, target: any,
  10249. /** path to specify the property of the target the conditional operator uses */
  10250. propertyPath: string,
  10251. /** the value compared by the conditional operator against the current value of the property */
  10252. value: any,
  10253. /** the conditional operator, default ValueCondition.IsEqual */
  10254. operator?: number);
  10255. /**
  10256. * Compares the given value with the property value for the specified conditional operator
  10257. * @returns the result of the comparison
  10258. */
  10259. isValid(): boolean;
  10260. /**
  10261. * Serialize the ValueCondition into a JSON compatible object
  10262. * @returns serialization object
  10263. */
  10264. serialize(): any;
  10265. /**
  10266. * Gets the name of the conditional operator for the ValueCondition
  10267. * @param operator the conditional operator
  10268. * @returns the name
  10269. */
  10270. static GetOperatorName(operator: number): string;
  10271. }
  10272. /**
  10273. * Defines a predicate condition as an extension of Condition
  10274. */
  10275. export class PredicateCondition extends Condition {
  10276. /** defines the predicate function used to validate the condition */
  10277. predicate: () => boolean;
  10278. /**
  10279. * Internal only - manager for action
  10280. * @hidden
  10281. */
  10282. _actionManager: ActionManager;
  10283. /**
  10284. * Creates a new PredicateCondition
  10285. * @param actionManager manager for the action the condition applies to
  10286. * @param predicate defines the predicate function used to validate the condition
  10287. */
  10288. constructor(actionManager: ActionManager,
  10289. /** defines the predicate function used to validate the condition */
  10290. predicate: () => boolean);
  10291. /**
  10292. * @returns the validity of the predicate condition
  10293. */
  10294. isValid(): boolean;
  10295. }
  10296. /**
  10297. * Defines a state condition as an extension of Condition
  10298. */
  10299. export class StateCondition extends Condition {
  10300. /** Value to compare with target state */
  10301. value: string;
  10302. /**
  10303. * Internal only - manager for action
  10304. * @hidden
  10305. */
  10306. _actionManager: ActionManager;
  10307. /**
  10308. * Internal only
  10309. * @hidden
  10310. */
  10311. private _target;
  10312. /**
  10313. * Creates a new StateCondition
  10314. * @param actionManager manager for the action the condition applies to
  10315. * @param target of the condition
  10316. * @param value to compare with target state
  10317. */
  10318. constructor(actionManager: ActionManager, target: any,
  10319. /** Value to compare with target state */
  10320. value: string);
  10321. /**
  10322. * Gets a boolean indicating if the current condition is met
  10323. * @returns the validity of the state
  10324. */
  10325. isValid(): boolean;
  10326. /**
  10327. * Serialize the StateCondition into a JSON compatible object
  10328. * @returns serialization object
  10329. */
  10330. serialize(): any;
  10331. }
  10332. }
  10333. declare module BABYLON {
  10334. /**
  10335. * This defines an action responsible to toggle a boolean once triggered.
  10336. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10337. */
  10338. export class SwitchBooleanAction extends Action {
  10339. /**
  10340. * The path to the boolean property in the target object
  10341. */
  10342. propertyPath: string;
  10343. private _target;
  10344. private _effectiveTarget;
  10345. private _property;
  10346. /**
  10347. * Instantiate the action
  10348. * @param triggerOptions defines the trigger options
  10349. * @param target defines the object containing the boolean
  10350. * @param propertyPath defines the path to the boolean property in the target object
  10351. * @param condition defines the trigger related conditions
  10352. */
  10353. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10354. /** @hidden */
  10355. _prepare(): void;
  10356. /**
  10357. * Execute the action toggle the boolean value.
  10358. */
  10359. execute(): void;
  10360. /**
  10361. * Serializes the actions and its related information.
  10362. * @param parent defines the object to serialize in
  10363. * @returns the serialized object
  10364. */
  10365. serialize(parent: any): any;
  10366. }
  10367. /**
  10368. * This defines an action responsible to set a the state field of the target
  10369. * to a desired value once triggered.
  10370. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10371. */
  10372. export class SetStateAction extends Action {
  10373. /**
  10374. * The value to store in the state field.
  10375. */
  10376. value: string;
  10377. private _target;
  10378. /**
  10379. * Instantiate the action
  10380. * @param triggerOptions defines the trigger options
  10381. * @param target defines the object containing the state property
  10382. * @param value defines the value to store in the state field
  10383. * @param condition defines the trigger related conditions
  10384. */
  10385. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10386. /**
  10387. * Execute the action and store the value on the target state property.
  10388. */
  10389. execute(): void;
  10390. /**
  10391. * Serializes the actions and its related information.
  10392. * @param parent defines the object to serialize in
  10393. * @returns the serialized object
  10394. */
  10395. serialize(parent: any): any;
  10396. }
  10397. /**
  10398. * This defines an action responsible to set a property of the target
  10399. * to a desired value once triggered.
  10400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10401. */
  10402. export class SetValueAction extends Action {
  10403. /**
  10404. * The path of the property to set in the target.
  10405. */
  10406. propertyPath: string;
  10407. /**
  10408. * The value to set in the property
  10409. */
  10410. value: any;
  10411. private _target;
  10412. private _effectiveTarget;
  10413. private _property;
  10414. /**
  10415. * Instantiate the action
  10416. * @param triggerOptions defines the trigger options
  10417. * @param target defines the object containing the property
  10418. * @param propertyPath defines the path of the property to set in the target
  10419. * @param value defines the value to set in the property
  10420. * @param condition defines the trigger related conditions
  10421. */
  10422. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10423. /** @hidden */
  10424. _prepare(): void;
  10425. /**
  10426. * Execute the action and set the targetted property to the desired value.
  10427. */
  10428. execute(): void;
  10429. /**
  10430. * Serializes the actions and its related information.
  10431. * @param parent defines the object to serialize in
  10432. * @returns the serialized object
  10433. */
  10434. serialize(parent: any): any;
  10435. }
  10436. /**
  10437. * This defines an action responsible to increment the target value
  10438. * to a desired value once triggered.
  10439. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10440. */
  10441. export class IncrementValueAction extends Action {
  10442. /**
  10443. * The path of the property to increment in the target.
  10444. */
  10445. propertyPath: string;
  10446. /**
  10447. * The value we should increment the property by.
  10448. */
  10449. value: any;
  10450. private _target;
  10451. private _effectiveTarget;
  10452. private _property;
  10453. /**
  10454. * Instantiate the action
  10455. * @param triggerOptions defines the trigger options
  10456. * @param target defines the object containing the property
  10457. * @param propertyPath defines the path of the property to increment in the target
  10458. * @param value defines the value value we should increment the property by
  10459. * @param condition defines the trigger related conditions
  10460. */
  10461. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10462. /** @hidden */
  10463. _prepare(): void;
  10464. /**
  10465. * Execute the action and increment the target of the value amount.
  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 start an animation once triggered.
  10477. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10478. */
  10479. export class PlayAnimationAction extends Action {
  10480. /**
  10481. * Where the animation should start (animation frame)
  10482. */
  10483. from: number;
  10484. /**
  10485. * Where the animation should stop (animation frame)
  10486. */
  10487. to: number;
  10488. /**
  10489. * Define if the animation should loop or stop after the first play.
  10490. */
  10491. loop?: boolean;
  10492. private _target;
  10493. /**
  10494. * Instantiate the action
  10495. * @param triggerOptions defines the trigger options
  10496. * @param target defines the target animation or animation name
  10497. * @param from defines from where the animation should start (animation frame)
  10498. * @param end defines where the animation should stop (animation frame)
  10499. * @param loop defines if the animation should loop or stop after the first play
  10500. * @param condition defines the trigger related conditions
  10501. */
  10502. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10503. /** @hidden */
  10504. _prepare(): void;
  10505. /**
  10506. * Execute the action and play the animation.
  10507. */
  10508. execute(): void;
  10509. /**
  10510. * Serializes the actions and its related information.
  10511. * @param parent defines the object to serialize in
  10512. * @returns the serialized object
  10513. */
  10514. serialize(parent: any): any;
  10515. }
  10516. /**
  10517. * This defines an action responsible to stop an animation once triggered.
  10518. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10519. */
  10520. export class StopAnimationAction extends Action {
  10521. private _target;
  10522. /**
  10523. * Instantiate the action
  10524. * @param triggerOptions defines the trigger options
  10525. * @param target defines the target animation or animation name
  10526. * @param condition defines the trigger related conditions
  10527. */
  10528. constructor(triggerOptions: any, target: any, condition?: Condition);
  10529. /** @hidden */
  10530. _prepare(): void;
  10531. /**
  10532. * Execute the action and stop the animation.
  10533. */
  10534. execute(): void;
  10535. /**
  10536. * Serializes the actions and its related information.
  10537. * @param parent defines the object to serialize in
  10538. * @returns the serialized object
  10539. */
  10540. serialize(parent: any): any;
  10541. }
  10542. /**
  10543. * This defines an action responsible that does nothing once triggered.
  10544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10545. */
  10546. export class DoNothingAction extends Action {
  10547. /**
  10548. * Instantiate the action
  10549. * @param triggerOptions defines the trigger options
  10550. * @param condition defines the trigger related conditions
  10551. */
  10552. constructor(triggerOptions?: any, condition?: Condition);
  10553. /**
  10554. * Execute the action and do nothing.
  10555. */
  10556. execute(): void;
  10557. /**
  10558. * Serializes the actions and its related information.
  10559. * @param parent defines the object to serialize in
  10560. * @returns the serialized object
  10561. */
  10562. serialize(parent: any): any;
  10563. }
  10564. /**
  10565. * This defines an action responsible to trigger several actions once triggered.
  10566. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class CombineAction extends Action {
  10569. /**
  10570. * The list of aggregated animations to run.
  10571. */
  10572. children: Action[];
  10573. /**
  10574. * Instantiate the action
  10575. * @param triggerOptions defines the trigger options
  10576. * @param children defines the list of aggregated animations to run
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10580. /** @hidden */
  10581. _prepare(): void;
  10582. /**
  10583. * Execute the action and executes all the aggregated actions.
  10584. */
  10585. execute(evt: ActionEvent): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to run code (external event) once triggered.
  10595. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10596. */
  10597. export class ExecuteCodeAction extends Action {
  10598. /**
  10599. * The callback function to run.
  10600. */
  10601. func: (evt: ActionEvent) => void;
  10602. /**
  10603. * Instantiate the action
  10604. * @param triggerOptions defines the trigger options
  10605. * @param func defines the callback function to run
  10606. * @param condition defines the trigger related conditions
  10607. */
  10608. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10609. /**
  10610. * Execute the action and run the attached code.
  10611. */
  10612. execute(evt: ActionEvent): void;
  10613. }
  10614. /**
  10615. * This defines an action responsible to set the parent property of the target once triggered.
  10616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10617. */
  10618. export class SetParentAction extends Action {
  10619. private _parent;
  10620. private _target;
  10621. /**
  10622. * Instantiate the action
  10623. * @param triggerOptions defines the trigger options
  10624. * @param target defines the target containing the parent property
  10625. * @param parent defines from where the animation should start (animation frame)
  10626. * @param condition defines the trigger related conditions
  10627. */
  10628. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10629. /** @hidden */
  10630. _prepare(): void;
  10631. /**
  10632. * Execute the action and set the parent property.
  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. declare module BABYLON {
  10644. /**
  10645. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10646. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10647. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10648. */
  10649. export class ActionManager extends AbstractActionManager {
  10650. /**
  10651. * Nothing
  10652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10653. */
  10654. static readonly NothingTrigger: number;
  10655. /**
  10656. * On pick
  10657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10658. */
  10659. static readonly OnPickTrigger: number;
  10660. /**
  10661. * On left pick
  10662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10663. */
  10664. static readonly OnLeftPickTrigger: number;
  10665. /**
  10666. * On right pick
  10667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10668. */
  10669. static readonly OnRightPickTrigger: number;
  10670. /**
  10671. * On center pick
  10672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10673. */
  10674. static readonly OnCenterPickTrigger: number;
  10675. /**
  10676. * On pick down
  10677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10678. */
  10679. static readonly OnPickDownTrigger: number;
  10680. /**
  10681. * On double pick
  10682. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10683. */
  10684. static readonly OnDoublePickTrigger: number;
  10685. /**
  10686. * On pick up
  10687. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10688. */
  10689. static readonly OnPickUpTrigger: number;
  10690. /**
  10691. * On pick out.
  10692. * This trigger will only be raised if you also declared a OnPickDown
  10693. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10694. */
  10695. static readonly OnPickOutTrigger: number;
  10696. /**
  10697. * On long press
  10698. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10699. */
  10700. static readonly OnLongPressTrigger: number;
  10701. /**
  10702. * On pointer over
  10703. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10704. */
  10705. static readonly OnPointerOverTrigger: number;
  10706. /**
  10707. * On pointer out
  10708. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10709. */
  10710. static readonly OnPointerOutTrigger: number;
  10711. /**
  10712. * On every frame
  10713. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10714. */
  10715. static readonly OnEveryFrameTrigger: number;
  10716. /**
  10717. * On intersection enter
  10718. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10719. */
  10720. static readonly OnIntersectionEnterTrigger: number;
  10721. /**
  10722. * On intersection exit
  10723. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10724. */
  10725. static readonly OnIntersectionExitTrigger: number;
  10726. /**
  10727. * On key down
  10728. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10729. */
  10730. static readonly OnKeyDownTrigger: number;
  10731. /**
  10732. * On key up
  10733. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10734. */
  10735. static readonly OnKeyUpTrigger: number;
  10736. private _scene;
  10737. /**
  10738. * Creates a new action manager
  10739. * @param scene defines the hosting scene
  10740. */
  10741. constructor(scene: Scene);
  10742. /**
  10743. * Releases all associated resources
  10744. */
  10745. dispose(): void;
  10746. /**
  10747. * Gets hosting scene
  10748. * @returns the hosting scene
  10749. */
  10750. getScene(): Scene;
  10751. /**
  10752. * Does this action manager handles actions of any of the given triggers
  10753. * @param triggers defines the triggers to be tested
  10754. * @return a boolean indicating whether one (or more) of the triggers is handled
  10755. */
  10756. hasSpecificTriggers(triggers: number[]): boolean;
  10757. /**
  10758. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10759. * speed.
  10760. * @param triggerA defines the trigger to be tested
  10761. * @param triggerB defines the trigger to be tested
  10762. * @return a boolean indicating whether one (or more) of the triggers is handled
  10763. */
  10764. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10765. /**
  10766. * Does this action manager handles actions of a given trigger
  10767. * @param trigger defines the trigger to be tested
  10768. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10769. * @return whether the trigger is handled
  10770. */
  10771. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10772. /**
  10773. * Does this action manager has pointer triggers
  10774. */
  10775. get hasPointerTriggers(): boolean;
  10776. /**
  10777. * Does this action manager has pick triggers
  10778. */
  10779. get hasPickTriggers(): boolean;
  10780. /**
  10781. * Registers an action to this action manager
  10782. * @param action defines the action to be registered
  10783. * @return the action amended (prepared) after registration
  10784. */
  10785. registerAction(action: IAction): Nullable<IAction>;
  10786. /**
  10787. * Unregisters an action to this action manager
  10788. * @param action defines the action to be unregistered
  10789. * @return a boolean indicating whether the action has been unregistered
  10790. */
  10791. unregisterAction(action: IAction): Boolean;
  10792. /**
  10793. * Process a specific trigger
  10794. * @param trigger defines the trigger to process
  10795. * @param evt defines the event details to be processed
  10796. */
  10797. processTrigger(trigger: number, evt?: IActionEvent): void;
  10798. /** @hidden */
  10799. _getEffectiveTarget(target: any, propertyPath: string): any;
  10800. /** @hidden */
  10801. _getProperty(propertyPath: string): string;
  10802. /**
  10803. * Serialize this manager to a JSON object
  10804. * @param name defines the property name to store this manager
  10805. * @returns a JSON representation of this manager
  10806. */
  10807. serialize(name: string): any;
  10808. /**
  10809. * Creates a new ActionManager from a JSON data
  10810. * @param parsedActions defines the JSON data to read from
  10811. * @param object defines the hosting mesh
  10812. * @param scene defines the hosting scene
  10813. */
  10814. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10815. /**
  10816. * Get a trigger name by index
  10817. * @param trigger defines the trigger index
  10818. * @returns a trigger name
  10819. */
  10820. static GetTriggerName(trigger: number): string;
  10821. }
  10822. }
  10823. declare module BABYLON {
  10824. /**
  10825. * Class representing a ray with position and direction
  10826. */
  10827. export class Ray {
  10828. /** origin point */
  10829. origin: Vector3;
  10830. /** direction */
  10831. direction: Vector3;
  10832. /** length of the ray */
  10833. length: number;
  10834. private static readonly _TmpVector3;
  10835. private _tmpRay;
  10836. /**
  10837. * Creates a new ray
  10838. * @param origin origin point
  10839. * @param direction direction
  10840. * @param length length of the ray
  10841. */
  10842. constructor(
  10843. /** origin point */
  10844. origin: Vector3,
  10845. /** direction */
  10846. direction: Vector3,
  10847. /** length of the ray */
  10848. length?: number);
  10849. /**
  10850. * Checks if the ray intersects a box
  10851. * This does not account for the ray lenght by design to improve perfs.
  10852. * @param minimum bound of the box
  10853. * @param maximum bound of the box
  10854. * @param intersectionTreshold extra extend to be added to the box in all direction
  10855. * @returns if the box was hit
  10856. */
  10857. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10858. /**
  10859. * Checks if the ray intersects a box
  10860. * This does not account for the ray lenght by design to improve perfs.
  10861. * @param box the bounding box to check
  10862. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10863. * @returns if the box was hit
  10864. */
  10865. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10866. /**
  10867. * If the ray hits a sphere
  10868. * @param sphere the bounding sphere to check
  10869. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10870. * @returns true if it hits the sphere
  10871. */
  10872. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10873. /**
  10874. * If the ray hits a triange
  10875. * @param vertex0 triangle vertex
  10876. * @param vertex1 triangle vertex
  10877. * @param vertex2 triangle vertex
  10878. * @returns intersection information if hit
  10879. */
  10880. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10881. /**
  10882. * Checks if ray intersects a plane
  10883. * @param plane the plane to check
  10884. * @returns the distance away it was hit
  10885. */
  10886. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10887. /**
  10888. * Calculate the intercept of a ray on a given axis
  10889. * @param axis to check 'x' | 'y' | 'z'
  10890. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10891. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10892. */
  10893. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10894. /**
  10895. * Checks if ray intersects a mesh
  10896. * @param mesh the mesh to check
  10897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10898. * @returns picking info of the intersecton
  10899. */
  10900. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10901. /**
  10902. * Checks if ray intersects a mesh
  10903. * @param meshes the meshes to check
  10904. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10905. * @param results array to store result in
  10906. * @returns Array of picking infos
  10907. */
  10908. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10909. private _comparePickingInfo;
  10910. private static smallnum;
  10911. private static rayl;
  10912. /**
  10913. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10914. * @param sega the first point of the segment to test the intersection against
  10915. * @param segb the second point of the segment to test the intersection against
  10916. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10917. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10918. */
  10919. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10920. /**
  10921. * Update the ray from viewport position
  10922. * @param x position
  10923. * @param y y position
  10924. * @param viewportWidth viewport width
  10925. * @param viewportHeight viewport height
  10926. * @param world world matrix
  10927. * @param view view matrix
  10928. * @param projection projection matrix
  10929. * @returns this ray updated
  10930. */
  10931. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10932. /**
  10933. * Creates a ray with origin and direction of 0,0,0
  10934. * @returns the new ray
  10935. */
  10936. static Zero(): Ray;
  10937. /**
  10938. * Creates a new ray from screen space and viewport
  10939. * @param x position
  10940. * @param y y position
  10941. * @param viewportWidth viewport width
  10942. * @param viewportHeight viewport height
  10943. * @param world world matrix
  10944. * @param view view matrix
  10945. * @param projection projection matrix
  10946. * @returns new ray
  10947. */
  10948. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10949. /**
  10950. * 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
  10951. * transformed to the given world matrix.
  10952. * @param origin The origin point
  10953. * @param end The end point
  10954. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10955. * @returns the new ray
  10956. */
  10957. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10958. /**
  10959. * Transforms a ray by a matrix
  10960. * @param ray ray to transform
  10961. * @param matrix matrix to apply
  10962. * @returns the resulting new ray
  10963. */
  10964. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10965. /**
  10966. * Transforms a ray by a matrix
  10967. * @param ray ray to transform
  10968. * @param matrix matrix to apply
  10969. * @param result ray to store result in
  10970. */
  10971. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10972. /**
  10973. * Unproject a ray from screen space to object space
  10974. * @param sourceX defines the screen space x coordinate to use
  10975. * @param sourceY defines the screen space y coordinate to use
  10976. * @param viewportWidth defines the current width of the viewport
  10977. * @param viewportHeight defines the current height of the viewport
  10978. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10979. * @param view defines the view matrix to use
  10980. * @param projection defines the projection matrix to use
  10981. */
  10982. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10983. }
  10984. /**
  10985. * Type used to define predicate used to select faces when a mesh intersection is detected
  10986. */
  10987. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10988. interface Scene {
  10989. /** @hidden */
  10990. _tempPickingRay: Nullable<Ray>;
  10991. /** @hidden */
  10992. _cachedRayForTransform: Ray;
  10993. /** @hidden */
  10994. _pickWithRayInverseMatrix: Matrix;
  10995. /** @hidden */
  10996. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10997. /** @hidden */
  10998. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10999. /** @hidden */
  11000. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate, skipBoundingInfo?: boolean): Nullable<PickingInfo>;
  11001. }
  11002. }
  11003. declare module BABYLON {
  11004. /**
  11005. * Groups all the scene component constants in one place to ease maintenance.
  11006. * @hidden
  11007. */
  11008. export class SceneComponentConstants {
  11009. static readonly NAME_EFFECTLAYER: string;
  11010. static readonly NAME_LAYER: string;
  11011. static readonly NAME_LENSFLARESYSTEM: string;
  11012. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11013. static readonly NAME_PARTICLESYSTEM: string;
  11014. static readonly NAME_GAMEPAD: string;
  11015. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11016. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11017. static readonly NAME_PREPASSRENDERER: string;
  11018. static readonly NAME_DEPTHRENDERER: string;
  11019. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11020. static readonly NAME_SPRITE: string;
  11021. static readonly NAME_SUBSURFACE: string;
  11022. static readonly NAME_OUTLINERENDERER: string;
  11023. static readonly NAME_PROCEDURALTEXTURE: string;
  11024. static readonly NAME_SHADOWGENERATOR: string;
  11025. static readonly NAME_OCTREE: string;
  11026. static readonly NAME_PHYSICSENGINE: string;
  11027. static readonly NAME_AUDIO: string;
  11028. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11029. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11030. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11031. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11032. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11033. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11034. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11035. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  11036. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11037. static readonly STEP_BEFORERENDERINGMESH_PREPASS: number;
  11038. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11039. static readonly STEP_AFTERRENDERINGMESH_PREPASS: number;
  11040. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11041. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11042. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11043. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11044. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11045. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11046. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11047. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11048. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11049. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11050. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11051. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  11052. static readonly STEP_AFTERRENDER_AUDIO: number;
  11053. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11054. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11055. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11056. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11057. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11058. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  11059. static readonly STEP_POINTERMOVE_SPRITE: number;
  11060. static readonly STEP_POINTERDOWN_SPRITE: number;
  11061. static readonly STEP_POINTERUP_SPRITE: number;
  11062. }
  11063. /**
  11064. * This represents a scene component.
  11065. *
  11066. * This is used to decouple the dependency the scene is having on the different workloads like
  11067. * layers, post processes...
  11068. */
  11069. export interface ISceneComponent {
  11070. /**
  11071. * The name of the component. Each component must have a unique name.
  11072. */
  11073. name: string;
  11074. /**
  11075. * The scene the component belongs to.
  11076. */
  11077. scene: Scene;
  11078. /**
  11079. * Register the component to one instance of a scene.
  11080. */
  11081. register(): void;
  11082. /**
  11083. * Rebuilds the elements related to this component in case of
  11084. * context lost for instance.
  11085. */
  11086. rebuild(): void;
  11087. /**
  11088. * Disposes the component and the associated ressources.
  11089. */
  11090. dispose(): void;
  11091. }
  11092. /**
  11093. * This represents a SERIALIZABLE scene component.
  11094. *
  11095. * This extends Scene Component to add Serialization methods on top.
  11096. */
  11097. export interface ISceneSerializableComponent extends ISceneComponent {
  11098. /**
  11099. * Adds all the elements from the container to the scene
  11100. * @param container the container holding the elements
  11101. */
  11102. addFromContainer(container: AbstractScene): void;
  11103. /**
  11104. * Removes all the elements in the container from the scene
  11105. * @param container contains the elements to remove
  11106. * @param dispose if the removed element should be disposed (default: false)
  11107. */
  11108. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11109. /**
  11110. * Serializes the component data to the specified json object
  11111. * @param serializationObject The object to serialize to
  11112. */
  11113. serialize(serializationObject: any): void;
  11114. }
  11115. /**
  11116. * Strong typing of a Mesh related stage step action
  11117. */
  11118. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11119. /**
  11120. * Strong typing of a Evaluate Sub Mesh related stage step action
  11121. */
  11122. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11123. /**
  11124. * Strong typing of a pre active Mesh related stage step action
  11125. */
  11126. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11127. /**
  11128. * Strong typing of a Camera related stage step action
  11129. */
  11130. export type CameraStageAction = (camera: Camera) => void;
  11131. /**
  11132. * Strong typing of a Camera Frame buffer related stage step action
  11133. */
  11134. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11135. /**
  11136. * Strong typing of a Render Target related stage step action
  11137. */
  11138. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11139. /**
  11140. * Strong typing of a RenderingGroup related stage step action
  11141. */
  11142. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11143. /**
  11144. * Strong typing of a Mesh Render related stage step action
  11145. */
  11146. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch, effect: Nullable<Effect>) => void;
  11147. /**
  11148. * Strong typing of a simple stage step action
  11149. */
  11150. export type SimpleStageAction = () => void;
  11151. /**
  11152. * Strong typing of a render target action.
  11153. */
  11154. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11155. /**
  11156. * Strong typing of a pointer move action.
  11157. */
  11158. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11159. /**
  11160. * Strong typing of a pointer up/down action.
  11161. */
  11162. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11163. /**
  11164. * Representation of a stage in the scene (Basically a list of ordered steps)
  11165. * @hidden
  11166. */
  11167. export class Stage<T extends Function> extends Array<{
  11168. index: number;
  11169. component: ISceneComponent;
  11170. action: T;
  11171. }> {
  11172. /**
  11173. * Hide ctor from the rest of the world.
  11174. * @param items The items to add.
  11175. */
  11176. private constructor();
  11177. /**
  11178. * Creates a new Stage.
  11179. * @returns A new instance of a Stage
  11180. */
  11181. static Create<T extends Function>(): Stage<T>;
  11182. /**
  11183. * Registers a step in an ordered way in the targeted stage.
  11184. * @param index Defines the position to register the step in
  11185. * @param component Defines the component attached to the step
  11186. * @param action Defines the action to launch during the step
  11187. */
  11188. registerStep(index: number, component: ISceneComponent, action: T): void;
  11189. /**
  11190. * Clears all the steps from the stage.
  11191. */
  11192. clear(): void;
  11193. }
  11194. }
  11195. declare module BABYLON {
  11196. interface Scene {
  11197. /** @hidden */
  11198. _pointerOverSprite: Nullable<Sprite>;
  11199. /** @hidden */
  11200. _pickedDownSprite: Nullable<Sprite>;
  11201. /** @hidden */
  11202. _tempSpritePickingRay: Nullable<Ray>;
  11203. /**
  11204. * All of the sprite managers added to this scene
  11205. * @see https://doc.babylonjs.com/babylon101/sprites
  11206. */
  11207. spriteManagers: Array<ISpriteManager>;
  11208. /**
  11209. * An event triggered when sprites rendering is about to start
  11210. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11211. */
  11212. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11213. /**
  11214. * An event triggered when sprites rendering is done
  11215. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11216. */
  11217. onAfterSpritesRenderingObservable: Observable<Scene>;
  11218. /** @hidden */
  11219. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11220. /** Launch a ray to try to pick a sprite in the scene
  11221. * @param x position on screen
  11222. * @param y position on screen
  11223. * @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
  11224. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11225. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11226. * @returns a PickingInfo
  11227. */
  11228. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11229. /** Use the given ray to pick a sprite in the scene
  11230. * @param ray The ray (in world space) to use to pick meshes
  11231. * @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
  11232. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11233. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11234. * @returns a PickingInfo
  11235. */
  11236. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11237. /** @hidden */
  11238. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11239. /** Launch a ray to try to pick sprites in the scene
  11240. * @param x position on screen
  11241. * @param y position on screen
  11242. * @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
  11243. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11244. * @returns a PickingInfo array
  11245. */
  11246. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11247. /** Use the given ray to pick sprites in the scene
  11248. * @param ray The ray (in world space) to use to pick meshes
  11249. * @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
  11250. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11251. * @returns a PickingInfo array
  11252. */
  11253. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11254. /**
  11255. * Force the sprite under the pointer
  11256. * @param sprite defines the sprite to use
  11257. */
  11258. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11259. /**
  11260. * Gets the sprite under the pointer
  11261. * @returns a Sprite or null if no sprite is under the pointer
  11262. */
  11263. getPointerOverSprite(): Nullable<Sprite>;
  11264. }
  11265. /**
  11266. * Defines the sprite scene component responsible to manage sprites
  11267. * in a given scene.
  11268. */
  11269. export class SpriteSceneComponent implements ISceneComponent {
  11270. /**
  11271. * The component name helpfull to identify the component in the list of scene components.
  11272. */
  11273. readonly name: string;
  11274. /**
  11275. * The scene the component belongs to.
  11276. */
  11277. scene: Scene;
  11278. /** @hidden */
  11279. private _spritePredicate;
  11280. /**
  11281. * Creates a new instance of the component for the given scene
  11282. * @param scene Defines the scene to register the component in
  11283. */
  11284. constructor(scene: Scene);
  11285. /**
  11286. * Registers the component in a given scene
  11287. */
  11288. register(): void;
  11289. /**
  11290. * Rebuilds the elements related to this component in case of
  11291. * context lost for instance.
  11292. */
  11293. rebuild(): void;
  11294. /**
  11295. * Disposes the component and the associated ressources.
  11296. */
  11297. dispose(): void;
  11298. private _pickSpriteButKeepRay;
  11299. private _pointerMove;
  11300. private _pointerDown;
  11301. private _pointerUp;
  11302. }
  11303. }
  11304. declare module BABYLON {
  11305. /**
  11306. * Class used to provide helper for timing
  11307. */
  11308. export class TimingTools {
  11309. /**
  11310. * Polyfill for setImmediate
  11311. * @param action defines the action to execute after the current execution block
  11312. */
  11313. static SetImmediate(action: () => void): void;
  11314. }
  11315. }
  11316. declare module BABYLON {
  11317. /**
  11318. * Class used to enable instatition of objects by class name
  11319. */
  11320. export class InstantiationTools {
  11321. /**
  11322. * Use this object to register external classes like custom textures or material
  11323. * to allow the laoders to instantiate them
  11324. */
  11325. static RegisteredExternalClasses: {
  11326. [key: string]: Object;
  11327. };
  11328. /**
  11329. * Tries to instantiate a new object from a given class name
  11330. * @param className defines the class name to instantiate
  11331. * @returns the new object or null if the system was not able to do the instantiation
  11332. */
  11333. static Instantiate(className: string): any;
  11334. }
  11335. }
  11336. declare module BABYLON {
  11337. /**
  11338. * Class used to host copy specific utilities
  11339. */
  11340. export class CopyTools {
  11341. /**
  11342. * Reads the pixels stored in the webgl texture and returns them as a base64 string
  11343. * @param texture defines the texture to read pixels from
  11344. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  11345. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  11346. * @returns The base64 encoded string or null
  11347. */
  11348. static GenerateBase64StringFromTexture(texture: BaseTexture, faceIndex?: number, level?: number): Promise<Nullable<string>>;
  11349. }
  11350. }
  11351. declare module BABYLON {
  11352. /**
  11353. * Define options used to create a depth texture
  11354. */
  11355. export class DepthTextureCreationOptions {
  11356. /** Specifies whether or not a stencil should be allocated in the texture */
  11357. generateStencil?: boolean;
  11358. /** Specifies whether or not bilinear filtering is enable on the texture */
  11359. bilinearFiltering?: boolean;
  11360. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  11361. comparisonFunction?: number;
  11362. /** Specifies if the created texture is a cube texture */
  11363. isCube?: boolean;
  11364. /** Specifies the sample count of the depth/stencil texture texture */
  11365. samples?: number;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface ThinEngine {
  11370. /**
  11371. * Creates a depth stencil cube texture.
  11372. * This is only available in WebGL 2.
  11373. * @param size The size of face edge in the cube texture.
  11374. * @param options The options defining the cube texture.
  11375. * @returns The cube texture
  11376. */
  11377. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  11378. /**
  11379. * Creates a cube texture
  11380. * @param rootUrl defines the url where the files to load is located
  11381. * @param scene defines the current scene
  11382. * @param files defines the list of files to load (1 per face)
  11383. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11384. * @param onLoad defines an optional callback raised when the texture is loaded
  11385. * @param onError defines an optional callback raised if there is an issue to load the texture
  11386. * @param format defines the format of the data
  11387. * @param forcedExtension defines the extension to use to pick the right loader
  11388. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11389. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11390. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11391. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  11392. * @param loaderOptions options to be passed to the loader
  11393. * @returns the cube texture as an InternalTexture
  11394. */
  11395. 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;
  11396. /**
  11397. * Creates a cube texture
  11398. * @param rootUrl defines the url where the files to load is located
  11399. * @param scene defines the current scene
  11400. * @param files defines the list of files to load (1 per face)
  11401. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11402. * @param onLoad defines an optional callback raised when the texture is loaded
  11403. * @param onError defines an optional callback raised if there is an issue to load the texture
  11404. * @param format defines the format of the data
  11405. * @param forcedExtension defines the extension to use to pick the right loader
  11406. * @returns the cube texture as an InternalTexture
  11407. */
  11408. 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;
  11409. /**
  11410. * Creates a cube texture
  11411. * @param rootUrl defines the url where the files to load is located
  11412. * @param scene defines the current scene
  11413. * @param files defines the list of files to load (1 per face)
  11414. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  11415. * @param onLoad defines an optional callback raised when the texture is loaded
  11416. * @param onError defines an optional callback raised if there is an issue to load the texture
  11417. * @param format defines the format of the data
  11418. * @param forcedExtension defines the extension to use to pick the right loader
  11419. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  11420. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11421. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11422. * @returns the cube texture as an InternalTexture
  11423. */
  11424. 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;
  11425. /** @hidden */
  11426. 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;
  11427. /** @hidden */
  11428. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  11429. /** @hidden */
  11430. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  11431. /** @hidden */
  11432. _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;
  11433. /** @hidden */
  11434. _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;
  11435. /**
  11436. * @hidden
  11437. */
  11438. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Class for creating a cube texture
  11444. */
  11445. export class CubeTexture extends BaseTexture {
  11446. private _delayedOnLoad;
  11447. /**
  11448. * Observable triggered once the texture has been loaded.
  11449. */
  11450. onLoadObservable: Observable<CubeTexture>;
  11451. /**
  11452. * The url of the texture
  11453. */
  11454. url: string;
  11455. /**
  11456. * Gets or sets the center of the bounding box associated with the cube texture.
  11457. * It must define where the camera used to render the texture was set
  11458. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11459. */
  11460. boundingBoxPosition: Vector3;
  11461. private _boundingBoxSize;
  11462. /**
  11463. * Gets or sets the size of the bounding box associated with the cube texture
  11464. * When defined, the cubemap will switch to local mode
  11465. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  11466. * @example https://www.babylonjs-playground.com/#RNASML
  11467. */
  11468. set boundingBoxSize(value: Vector3);
  11469. /**
  11470. * Returns the bounding box size
  11471. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  11472. */
  11473. get boundingBoxSize(): Vector3;
  11474. protected _rotationY: number;
  11475. /**
  11476. * Sets texture matrix rotation angle around Y axis in radians.
  11477. */
  11478. set rotationY(value: number);
  11479. /**
  11480. * Gets texture matrix rotation angle around Y axis radians.
  11481. */
  11482. get rotationY(): number;
  11483. /**
  11484. * Are mip maps generated for this texture or not.
  11485. */
  11486. get noMipmap(): boolean;
  11487. private _noMipmap;
  11488. private _files;
  11489. protected _forcedExtension: Nullable<string>;
  11490. private _extensions;
  11491. private _textureMatrix;
  11492. private _format;
  11493. private _createPolynomials;
  11494. private _loaderOptions;
  11495. /**
  11496. * Creates a cube texture from an array of image urls
  11497. * @param files defines an array of image urls
  11498. * @param scene defines the hosting scene
  11499. * @param noMipmap specifies if mip maps are not used
  11500. * @returns a cube texture
  11501. */
  11502. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  11503. /**
  11504. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  11505. * @param url defines the url of the prefiltered texture
  11506. * @param scene defines the scene the texture is attached to
  11507. * @param forcedExtension defines the extension of the file if different from the url
  11508. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11509. * @return the prefiltered texture
  11510. */
  11511. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  11512. /**
  11513. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  11514. * as prefiltered data.
  11515. * @param rootUrl defines the url of the texture or the root name of the six images
  11516. * @param null defines the scene or engine the texture is attached to
  11517. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  11518. * @param noMipmap defines if mipmaps should be created or not
  11519. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  11520. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  11521. * @param onError defines a callback triggered in case of error during load
  11522. * @param format defines the internal format to use for the texture once loaded
  11523. * @param prefiltered defines whether or not the texture is created from prefiltered data
  11524. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  11525. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  11526. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  11527. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  11528. * @param loaderOptions options to be passed to the loader
  11529. * @return the cube texture
  11530. */
  11531. 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);
  11532. /**
  11533. * Get the current class name of the texture useful for serialization or dynamic coding.
  11534. * @returns "CubeTexture"
  11535. */
  11536. getClassName(): string;
  11537. /**
  11538. * Update the url (and optional buffer) of this texture if url was null during construction.
  11539. * @param url the url of the texture
  11540. * @param forcedExtension defines the extension to use
  11541. * @param onLoad callback called when the texture is loaded (defaults to null)
  11542. * @param prefiltered Defines whether the updated texture is prefiltered or not
  11543. */
  11544. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  11545. /**
  11546. * Delays loading of the cube texture
  11547. * @param forcedExtension defines the extension to use
  11548. */
  11549. delayLoad(forcedExtension?: string): void;
  11550. /**
  11551. * Returns the reflection texture matrix
  11552. * @returns the reflection texture matrix
  11553. */
  11554. getReflectionTextureMatrix(): Matrix;
  11555. /**
  11556. * Sets the reflection texture matrix
  11557. * @param value Reflection texture matrix
  11558. */
  11559. setReflectionTextureMatrix(value: Matrix): void;
  11560. /**
  11561. * Parses text to create a cube texture
  11562. * @param parsedTexture define the serialized text to read from
  11563. * @param scene defines the hosting scene
  11564. * @param rootUrl defines the root url of the cube texture
  11565. * @returns a cube texture
  11566. */
  11567. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  11568. /**
  11569. * Makes a clone, or deep copy, of the cube texture
  11570. * @returns a new cube texture
  11571. */
  11572. clone(): CubeTexture;
  11573. }
  11574. }
  11575. declare module BABYLON {
  11576. /**
  11577. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  11578. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  11579. * 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;
  11580. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  11581. */
  11582. export class ColorCurves {
  11583. private _dirty;
  11584. private _tempColor;
  11585. private _globalCurve;
  11586. private _highlightsCurve;
  11587. private _midtonesCurve;
  11588. private _shadowsCurve;
  11589. private _positiveCurve;
  11590. private _negativeCurve;
  11591. private _globalHue;
  11592. private _globalDensity;
  11593. private _globalSaturation;
  11594. private _globalExposure;
  11595. /**
  11596. * Gets the global Hue value.
  11597. * 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).
  11598. */
  11599. get globalHue(): number;
  11600. /**
  11601. * Sets the global Hue value.
  11602. * 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).
  11603. */
  11604. set globalHue(value: number);
  11605. /**
  11606. * Gets the global Density value.
  11607. * 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.
  11608. * Values less than zero provide a filter of opposite hue.
  11609. */
  11610. get globalDensity(): number;
  11611. /**
  11612. * Sets the global Density value.
  11613. * 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.
  11614. * Values less than zero provide a filter of opposite hue.
  11615. */
  11616. set globalDensity(value: number);
  11617. /**
  11618. * Gets the global Saturation value.
  11619. * 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.
  11620. */
  11621. get globalSaturation(): number;
  11622. /**
  11623. * Sets the global Saturation value.
  11624. * 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.
  11625. */
  11626. set globalSaturation(value: number);
  11627. /**
  11628. * Gets the global Exposure value.
  11629. * 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.
  11630. */
  11631. get globalExposure(): number;
  11632. /**
  11633. * Sets the global Exposure value.
  11634. * 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.
  11635. */
  11636. set globalExposure(value: number);
  11637. private _highlightsHue;
  11638. private _highlightsDensity;
  11639. private _highlightsSaturation;
  11640. private _highlightsExposure;
  11641. /**
  11642. * Gets the highlights Hue value.
  11643. * 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).
  11644. */
  11645. get highlightsHue(): number;
  11646. /**
  11647. * Sets the highlights Hue value.
  11648. * 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).
  11649. */
  11650. set highlightsHue(value: number);
  11651. /**
  11652. * Gets the highlights Density value.
  11653. * 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.
  11654. * Values less than zero provide a filter of opposite hue.
  11655. */
  11656. get highlightsDensity(): number;
  11657. /**
  11658. * Sets the highlights Density value.
  11659. * 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.
  11660. * Values less than zero provide a filter of opposite hue.
  11661. */
  11662. set highlightsDensity(value: number);
  11663. /**
  11664. * Gets the highlights Saturation value.
  11665. * 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.
  11666. */
  11667. get highlightsSaturation(): number;
  11668. /**
  11669. * Sets the highlights Saturation value.
  11670. * 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.
  11671. */
  11672. set highlightsSaturation(value: number);
  11673. /**
  11674. * Gets the highlights Exposure value.
  11675. * 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.
  11676. */
  11677. get highlightsExposure(): number;
  11678. /**
  11679. * Sets the highlights Exposure value.
  11680. * 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.
  11681. */
  11682. set highlightsExposure(value: number);
  11683. private _midtonesHue;
  11684. private _midtonesDensity;
  11685. private _midtonesSaturation;
  11686. private _midtonesExposure;
  11687. /**
  11688. * Gets the midtones Hue value.
  11689. * 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).
  11690. */
  11691. get midtonesHue(): number;
  11692. /**
  11693. * Sets the midtones 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. set midtonesHue(value: number);
  11697. /**
  11698. * Gets the midtones Density value.
  11699. * 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.
  11700. * Values less than zero provide a filter of opposite hue.
  11701. */
  11702. get midtonesDensity(): number;
  11703. /**
  11704. * Sets the midtones Density value.
  11705. * 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.
  11706. * Values less than zero provide a filter of opposite hue.
  11707. */
  11708. set midtonesDensity(value: number);
  11709. /**
  11710. * Gets the midtones Saturation value.
  11711. * 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.
  11712. */
  11713. get midtonesSaturation(): number;
  11714. /**
  11715. * Sets the midtones 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. set midtonesSaturation(value: number);
  11719. /**
  11720. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  11722. */
  11723. get midtonesExposure(): number;
  11724. /**
  11725. * Sets the midtones 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. set midtonesExposure(value: number);
  11729. private _shadowsHue;
  11730. private _shadowsDensity;
  11731. private _shadowsSaturation;
  11732. private _shadowsExposure;
  11733. /**
  11734. * Gets the shadows Hue value.
  11735. * 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).
  11736. */
  11737. get shadowsHue(): number;
  11738. /**
  11739. * Sets the shadows 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. set shadowsHue(value: number);
  11743. /**
  11744. * Gets the shadows Density value.
  11745. * 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.
  11746. * Values less than zero provide a filter of opposite hue.
  11747. */
  11748. get shadowsDensity(): number;
  11749. /**
  11750. * Sets the shadows Density value.
  11751. * 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.
  11752. * Values less than zero provide a filter of opposite hue.
  11753. */
  11754. set shadowsDensity(value: number);
  11755. /**
  11756. * Gets the shadows Saturation value.
  11757. * 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.
  11758. */
  11759. get shadowsSaturation(): number;
  11760. /**
  11761. * Sets the shadows 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. set shadowsSaturation(value: number);
  11765. /**
  11766. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  11768. */
  11769. get shadowsExposure(): number;
  11770. /**
  11771. * Sets the shadows 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. set shadowsExposure(value: number);
  11775. /**
  11776. * Returns the class name
  11777. * @returns The class name
  11778. */
  11779. getClassName(): string;
  11780. /**
  11781. * Binds the color curves to the shader.
  11782. * @param colorCurves The color curve to bind
  11783. * @param effect The effect to bind to
  11784. * @param positiveUniform The positive uniform shader parameter
  11785. * @param neutralUniform The neutral uniform shader parameter
  11786. * @param negativeUniform The negative uniform shader parameter
  11787. */
  11788. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  11789. /**
  11790. * Prepare the list of uniforms associated with the ColorCurves effects.
  11791. * @param uniformsList The list of uniforms used in the effect
  11792. */
  11793. static PrepareUniforms(uniformsList: string[]): void;
  11794. /**
  11795. * Returns color grading data based on a hue, density, saturation and exposure value.
  11796. * @param filterHue The hue of the color filter.
  11797. * @param filterDensity The density of the color filter.
  11798. * @param saturation The saturation.
  11799. * @param exposure The exposure.
  11800. * @param result The result data container.
  11801. */
  11802. private getColorGradingDataToRef;
  11803. /**
  11804. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  11805. * @param value The input slider value in range [-100,100].
  11806. * @returns Adjusted value.
  11807. */
  11808. private static applyColorGradingSliderNonlinear;
  11809. /**
  11810. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  11811. * @param hue The hue (H) input.
  11812. * @param saturation The saturation (S) input.
  11813. * @param brightness The brightness (B) input.
  11814. * @result An RGBA color represented as Vector4.
  11815. */
  11816. private static fromHSBToRef;
  11817. /**
  11818. * Returns a value clamped between min and max
  11819. * @param value The value to clamp
  11820. * @param min The minimum of value
  11821. * @param max The maximum of value
  11822. * @returns The clamped value.
  11823. */
  11824. private static clamp;
  11825. /**
  11826. * Clones the current color curve instance.
  11827. * @return The cloned curves
  11828. */
  11829. clone(): ColorCurves;
  11830. /**
  11831. * Serializes the current color curve instance to a json representation.
  11832. * @return a JSON representation
  11833. */
  11834. serialize(): any;
  11835. /**
  11836. * Parses the color curve from a json representation.
  11837. * @param source the JSON source to parse
  11838. * @return The parsed curves
  11839. */
  11840. static Parse(source: any): ColorCurves;
  11841. }
  11842. }
  11843. declare module BABYLON {
  11844. /**
  11845. * Interface to follow in your material defines to integrate easily the
  11846. * Image proccessing functions.
  11847. * @hidden
  11848. */
  11849. export interface IImageProcessingConfigurationDefines {
  11850. IMAGEPROCESSING: boolean;
  11851. VIGNETTE: boolean;
  11852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11853. VIGNETTEBLENDMODEOPAQUE: boolean;
  11854. TONEMAPPING: boolean;
  11855. TONEMAPPING_ACES: boolean;
  11856. CONTRAST: boolean;
  11857. EXPOSURE: boolean;
  11858. COLORCURVES: boolean;
  11859. COLORGRADING: boolean;
  11860. COLORGRADING3D: boolean;
  11861. SAMPLER3DGREENDEPTH: boolean;
  11862. SAMPLER3DBGRMAP: boolean;
  11863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11864. }
  11865. /**
  11866. * @hidden
  11867. */
  11868. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  11869. IMAGEPROCESSING: boolean;
  11870. VIGNETTE: boolean;
  11871. VIGNETTEBLENDMODEMULTIPLY: boolean;
  11872. VIGNETTEBLENDMODEOPAQUE: boolean;
  11873. TONEMAPPING: boolean;
  11874. TONEMAPPING_ACES: boolean;
  11875. CONTRAST: boolean;
  11876. COLORCURVES: boolean;
  11877. COLORGRADING: boolean;
  11878. COLORGRADING3D: boolean;
  11879. SAMPLER3DGREENDEPTH: boolean;
  11880. SAMPLER3DBGRMAP: boolean;
  11881. IMAGEPROCESSINGPOSTPROCESS: boolean;
  11882. EXPOSURE: boolean;
  11883. constructor();
  11884. }
  11885. /**
  11886. * This groups together the common properties used for image processing either in direct forward pass
  11887. * or through post processing effect depending on the use of the image processing pipeline in your scene
  11888. * or not.
  11889. */
  11890. export class ImageProcessingConfiguration {
  11891. /**
  11892. * Default tone mapping applied in BabylonJS.
  11893. */
  11894. static readonly TONEMAPPING_STANDARD: number;
  11895. /**
  11896. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  11897. * to other engines rendering to increase portability.
  11898. */
  11899. static readonly TONEMAPPING_ACES: number;
  11900. /**
  11901. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  11902. */
  11903. colorCurves: Nullable<ColorCurves>;
  11904. private _colorCurvesEnabled;
  11905. /**
  11906. * Gets wether the color curves effect is enabled.
  11907. */
  11908. get colorCurvesEnabled(): boolean;
  11909. /**
  11910. * Sets wether the color curves effect is enabled.
  11911. */
  11912. set colorCurvesEnabled(value: boolean);
  11913. private _colorGradingTexture;
  11914. /**
  11915. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11916. */
  11917. get colorGradingTexture(): Nullable<BaseTexture>;
  11918. /**
  11919. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  11920. */
  11921. set colorGradingTexture(value: Nullable<BaseTexture>);
  11922. private _colorGradingEnabled;
  11923. /**
  11924. * Gets wether the color grading effect is enabled.
  11925. */
  11926. get colorGradingEnabled(): boolean;
  11927. /**
  11928. * Sets wether the color grading effect is enabled.
  11929. */
  11930. set colorGradingEnabled(value: boolean);
  11931. private _colorGradingWithGreenDepth;
  11932. /**
  11933. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  11934. */
  11935. get colorGradingWithGreenDepth(): boolean;
  11936. /**
  11937. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  11938. */
  11939. set colorGradingWithGreenDepth(value: boolean);
  11940. private _colorGradingBGR;
  11941. /**
  11942. * Gets wether the color grading texture contains BGR values.
  11943. */
  11944. get colorGradingBGR(): boolean;
  11945. /**
  11946. * Sets wether the color grading texture contains BGR values.
  11947. */
  11948. set colorGradingBGR(value: boolean);
  11949. /** @hidden */
  11950. _exposure: number;
  11951. /**
  11952. * Gets the Exposure used in the effect.
  11953. */
  11954. get exposure(): number;
  11955. /**
  11956. * Sets the Exposure used in the effect.
  11957. */
  11958. set exposure(value: number);
  11959. private _toneMappingEnabled;
  11960. /**
  11961. * Gets wether the tone mapping effect is enabled.
  11962. */
  11963. get toneMappingEnabled(): boolean;
  11964. /**
  11965. * Sets wether the tone mapping effect is enabled.
  11966. */
  11967. set toneMappingEnabled(value: boolean);
  11968. private _toneMappingType;
  11969. /**
  11970. * Gets the type of tone mapping effect.
  11971. */
  11972. get toneMappingType(): number;
  11973. /**
  11974. * Sets the type of tone mapping effect used in BabylonJS.
  11975. */
  11976. set toneMappingType(value: number);
  11977. protected _contrast: number;
  11978. /**
  11979. * Gets the contrast used in the effect.
  11980. */
  11981. get contrast(): number;
  11982. /**
  11983. * Sets the contrast used in the effect.
  11984. */
  11985. set contrast(value: number);
  11986. /**
  11987. * Vignette stretch size.
  11988. */
  11989. vignetteStretch: number;
  11990. /**
  11991. * Vignette centre X Offset.
  11992. */
  11993. vignetteCentreX: number;
  11994. /**
  11995. * Vignette centre Y Offset.
  11996. */
  11997. vignetteCentreY: number;
  11998. /**
  11999. * Vignette weight or intensity of the vignette effect.
  12000. */
  12001. vignetteWeight: number;
  12002. /**
  12003. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  12004. * if vignetteEnabled is set to true.
  12005. */
  12006. vignetteColor: Color4;
  12007. /**
  12008. * Camera field of view used by the Vignette effect.
  12009. */
  12010. vignetteCameraFov: number;
  12011. private _vignetteBlendMode;
  12012. /**
  12013. * Gets the vignette blend mode allowing different kind of effect.
  12014. */
  12015. get vignetteBlendMode(): number;
  12016. /**
  12017. * Sets the vignette blend mode allowing different kind of effect.
  12018. */
  12019. set vignetteBlendMode(value: number);
  12020. private _vignetteEnabled;
  12021. /**
  12022. * Gets wether the vignette effect is enabled.
  12023. */
  12024. get vignetteEnabled(): boolean;
  12025. /**
  12026. * Sets wether the vignette effect is enabled.
  12027. */
  12028. set vignetteEnabled(value: boolean);
  12029. private _applyByPostProcess;
  12030. /**
  12031. * Gets wether the image processing is applied through a post process or not.
  12032. */
  12033. get applyByPostProcess(): boolean;
  12034. /**
  12035. * Sets wether the image processing is applied through a post process or not.
  12036. */
  12037. set applyByPostProcess(value: boolean);
  12038. private _isEnabled;
  12039. /**
  12040. * Gets wether the image processing is enabled or not.
  12041. */
  12042. get isEnabled(): boolean;
  12043. /**
  12044. * Sets wether the image processing is enabled or not.
  12045. */
  12046. set isEnabled(value: boolean);
  12047. /**
  12048. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  12049. */
  12050. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  12051. /**
  12052. * Method called each time the image processing information changes requires to recompile the effect.
  12053. */
  12054. protected _updateParameters(): void;
  12055. /**
  12056. * Gets the current class name.
  12057. * @return "ImageProcessingConfiguration"
  12058. */
  12059. getClassName(): string;
  12060. /**
  12061. * Prepare the list of uniforms associated with the Image Processing effects.
  12062. * @param uniforms The list of uniforms used in the effect
  12063. * @param defines the list of defines currently in use
  12064. */
  12065. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  12066. /**
  12067. * Prepare the list of samplers associated with the Image Processing effects.
  12068. * @param samplersList The list of uniforms used in the effect
  12069. * @param defines the list of defines currently in use
  12070. */
  12071. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  12072. /**
  12073. * Prepare the list of defines associated to the shader.
  12074. * @param defines the list of defines to complete
  12075. * @param forPostProcess Define if we are currently in post process mode or not
  12076. */
  12077. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  12078. /**
  12079. * Returns true if all the image processing information are ready.
  12080. * @returns True if ready, otherwise, false
  12081. */
  12082. isReady(): boolean;
  12083. /**
  12084. * Binds the image processing to the shader.
  12085. * @param effect The effect to bind to
  12086. * @param overrideAspectRatio Override the aspect ratio of the effect
  12087. */
  12088. bind(effect: Effect, overrideAspectRatio?: number): void;
  12089. /**
  12090. * Clones the current image processing instance.
  12091. * @return The cloned image processing
  12092. */
  12093. clone(): ImageProcessingConfiguration;
  12094. /**
  12095. * Serializes the current image processing instance to a json representation.
  12096. * @return a JSON representation
  12097. */
  12098. serialize(): any;
  12099. /**
  12100. * Parses the image processing from a json representation.
  12101. * @param source the JSON source to parse
  12102. * @return The parsed image processing
  12103. */
  12104. static Parse(source: any): ImageProcessingConfiguration;
  12105. private static _VIGNETTEMODE_MULTIPLY;
  12106. private static _VIGNETTEMODE_OPAQUE;
  12107. /**
  12108. * Used to apply the vignette as a mix with the pixel color.
  12109. */
  12110. static get VIGNETTEMODE_MULTIPLY(): number;
  12111. /**
  12112. * Used to apply the vignette as a replacement of the pixel color.
  12113. */
  12114. static get VIGNETTEMODE_OPAQUE(): number;
  12115. }
  12116. }
  12117. declare module BABYLON {
  12118. /** @hidden */
  12119. export var postprocessVertexShader: {
  12120. name: string;
  12121. shader: string;
  12122. };
  12123. }
  12124. declare module BABYLON {
  12125. /**
  12126. * Type used to define a render target texture size (either with a number or with a rect width and height)
  12127. */
  12128. export type RenderTargetTextureSize = number | {
  12129. width: number;
  12130. height: number;
  12131. layers?: number;
  12132. };
  12133. interface ThinEngine {
  12134. /**
  12135. * Creates a new render target texture
  12136. * @param size defines the size of the texture
  12137. * @param options defines the options used to create the texture
  12138. * @returns a new render target texture stored in an InternalTexture
  12139. */
  12140. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  12141. /**
  12142. * Creates a depth stencil texture.
  12143. * This is only available in WebGL 2 or with the depth texture extension available.
  12144. * @param size The size of face edge in the texture.
  12145. * @param options The options defining the texture.
  12146. * @returns The texture
  12147. */
  12148. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12149. /** @hidden */
  12150. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  12151. }
  12152. }
  12153. declare module BABYLON {
  12154. /**
  12155. * Defines the kind of connection point for node based material
  12156. */
  12157. export enum NodeMaterialBlockConnectionPointTypes {
  12158. /** Float */
  12159. Float = 1,
  12160. /** Int */
  12161. Int = 2,
  12162. /** Vector2 */
  12163. Vector2 = 4,
  12164. /** Vector3 */
  12165. Vector3 = 8,
  12166. /** Vector4 */
  12167. Vector4 = 16,
  12168. /** Color3 */
  12169. Color3 = 32,
  12170. /** Color4 */
  12171. Color4 = 64,
  12172. /** Matrix */
  12173. Matrix = 128,
  12174. /** Custom object */
  12175. Object = 256,
  12176. /** Detect type based on connection */
  12177. AutoDetect = 1024,
  12178. /** Output type that will be defined by input type */
  12179. BasedOnInput = 2048
  12180. }
  12181. }
  12182. declare module BABYLON {
  12183. /**
  12184. * Enum used to define the target of a block
  12185. */
  12186. export enum NodeMaterialBlockTargets {
  12187. /** Vertex shader */
  12188. Vertex = 1,
  12189. /** Fragment shader */
  12190. Fragment = 2,
  12191. /** Neutral */
  12192. Neutral = 4,
  12193. /** Vertex and Fragment */
  12194. VertexAndFragment = 3
  12195. }
  12196. }
  12197. declare module BABYLON {
  12198. /**
  12199. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  12200. */
  12201. export enum NodeMaterialBlockConnectionPointMode {
  12202. /** Value is an uniform */
  12203. Uniform = 0,
  12204. /** Value is a mesh attribute */
  12205. Attribute = 1,
  12206. /** Value is a varying between vertex and fragment shaders */
  12207. Varying = 2,
  12208. /** Mode is undefined */
  12209. Undefined = 3
  12210. }
  12211. }
  12212. declare module BABYLON {
  12213. /**
  12214. * Enum used to define system values e.g. values automatically provided by the system
  12215. */
  12216. export enum NodeMaterialSystemValues {
  12217. /** World */
  12218. World = 1,
  12219. /** View */
  12220. View = 2,
  12221. /** Projection */
  12222. Projection = 3,
  12223. /** ViewProjection */
  12224. ViewProjection = 4,
  12225. /** WorldView */
  12226. WorldView = 5,
  12227. /** WorldViewProjection */
  12228. WorldViewProjection = 6,
  12229. /** CameraPosition */
  12230. CameraPosition = 7,
  12231. /** Fog Color */
  12232. FogColor = 8,
  12233. /** Delta time */
  12234. DeltaTime = 9
  12235. }
  12236. }
  12237. declare module BABYLON {
  12238. /**
  12239. * Represents a camera frustum
  12240. */
  12241. export class Frustum {
  12242. /**
  12243. * Gets the planes representing the frustum
  12244. * @param transform matrix to be applied to the returned planes
  12245. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  12246. */
  12247. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  12248. /**
  12249. * Gets the near frustum plane transformed by the transform matrix
  12250. * @param transform transformation matrix to be applied to the resulting frustum plane
  12251. * @param frustumPlane the resuling frustum plane
  12252. */
  12253. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12254. /**
  12255. * Gets the far frustum plane transformed by the transform matrix
  12256. * @param transform transformation matrix to be applied to the resulting frustum plane
  12257. * @param frustumPlane the resuling frustum plane
  12258. */
  12259. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12260. /**
  12261. * Gets the left frustum plane transformed by the transform matrix
  12262. * @param transform transformation matrix to be applied to the resulting frustum plane
  12263. * @param frustumPlane the resuling frustum plane
  12264. */
  12265. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12266. /**
  12267. * Gets the right frustum plane transformed by the transform matrix
  12268. * @param transform transformation matrix to be applied to the resulting frustum plane
  12269. * @param frustumPlane the resuling frustum plane
  12270. */
  12271. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12272. /**
  12273. * Gets the top frustum plane transformed by the transform matrix
  12274. * @param transform transformation matrix to be applied to the resulting frustum plane
  12275. * @param frustumPlane the resuling frustum plane
  12276. */
  12277. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12278. /**
  12279. * Gets the bottom frustum plane transformed by the transform matrix
  12280. * @param transform transformation matrix to be applied to the resulting frustum plane
  12281. * @param frustumPlane the resuling frustum plane
  12282. */
  12283. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  12284. /**
  12285. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  12286. * @param transform transformation matrix to be applied to the resulting frustum planes
  12287. * @param frustumPlanes the resuling frustum planes
  12288. */
  12289. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  12290. }
  12291. }
  12292. declare module BABYLON {
  12293. /**
  12294. * Contains position and normal vectors for a vertex
  12295. */
  12296. export class PositionNormalVertex {
  12297. /** the position of the vertex (defaut: 0,0,0) */
  12298. position: Vector3;
  12299. /** the normal of the vertex (defaut: 0,1,0) */
  12300. normal: Vector3;
  12301. /**
  12302. * Creates a PositionNormalVertex
  12303. * @param position the position of the vertex (defaut: 0,0,0)
  12304. * @param normal the normal of the vertex (defaut: 0,1,0)
  12305. */
  12306. constructor(
  12307. /** the position of the vertex (defaut: 0,0,0) */
  12308. position?: Vector3,
  12309. /** the normal of the vertex (defaut: 0,1,0) */
  12310. normal?: Vector3);
  12311. /**
  12312. * Clones the PositionNormalVertex
  12313. * @returns the cloned PositionNormalVertex
  12314. */
  12315. clone(): PositionNormalVertex;
  12316. }
  12317. /**
  12318. * Contains position, normal and uv vectors for a vertex
  12319. */
  12320. export class PositionNormalTextureVertex {
  12321. /** the position of the vertex (defaut: 0,0,0) */
  12322. position: Vector3;
  12323. /** the normal of the vertex (defaut: 0,1,0) */
  12324. normal: Vector3;
  12325. /** the uv of the vertex (default: 0,0) */
  12326. uv: Vector2;
  12327. /**
  12328. * Creates a PositionNormalTextureVertex
  12329. * @param position the position of the vertex (defaut: 0,0,0)
  12330. * @param normal the normal of the vertex (defaut: 0,1,0)
  12331. * @param uv the uv of the vertex (default: 0,0)
  12332. */
  12333. constructor(
  12334. /** the position of the vertex (defaut: 0,0,0) */
  12335. position?: Vector3,
  12336. /** the normal of the vertex (defaut: 0,1,0) */
  12337. normal?: Vector3,
  12338. /** the uv of the vertex (default: 0,0) */
  12339. uv?: Vector2);
  12340. /**
  12341. * Clones the PositionNormalTextureVertex
  12342. * @returns the cloned PositionNormalTextureVertex
  12343. */
  12344. clone(): PositionNormalTextureVertex;
  12345. }
  12346. }
  12347. declare module BABYLON {
  12348. /**
  12349. * Enum defining the type of animations supported by InputBlock
  12350. */
  12351. export enum AnimatedInputBlockTypes {
  12352. /** No animation */
  12353. None = 0,
  12354. /** Time based animation. Will only work for floats */
  12355. Time = 1
  12356. }
  12357. }
  12358. declare module BABYLON {
  12359. /**
  12360. * Block used to expose an input value
  12361. */
  12362. export class InputBlock extends NodeMaterialBlock {
  12363. private _mode;
  12364. private _associatedVariableName;
  12365. private _storedValue;
  12366. private _valueCallback;
  12367. private _type;
  12368. private _animationType;
  12369. /** Gets or set a value used to limit the range of float values */
  12370. min: number;
  12371. /** Gets or set a value used to limit the range of float values */
  12372. max: number;
  12373. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  12374. isBoolean: boolean;
  12375. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  12376. matrixMode: number;
  12377. /** @hidden */
  12378. _systemValue: Nullable<NodeMaterialSystemValues>;
  12379. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  12380. isConstant: boolean;
  12381. /** Gets or sets the group to use to display this block in the Inspector */
  12382. groupInInspector: string;
  12383. /** Gets an observable raised when the value is changed */
  12384. onValueChangedObservable: Observable<InputBlock>;
  12385. /** Gets or sets a boolean indicating if content needs to be converted to gamma space (for color3/4 only) */
  12386. convertToGammaSpace: boolean;
  12387. /** Gets or sets a boolean indicating if content needs to be converted to linear space (for color3/4 only) */
  12388. convertToLinearSpace: boolean;
  12389. /**
  12390. * Gets or sets the connection point type (default is float)
  12391. */
  12392. get type(): NodeMaterialBlockConnectionPointTypes;
  12393. /**
  12394. * Creates a new InputBlock
  12395. * @param name defines the block name
  12396. * @param target defines the target of that block (Vertex by default)
  12397. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  12398. */
  12399. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  12400. /**
  12401. * Validates if a name is a reserve word.
  12402. * @param newName the new name to be given to the node.
  12403. * @returns false if the name is a reserve word, else true.
  12404. */
  12405. validateBlockName(newName: string): boolean;
  12406. /**
  12407. * Gets the output component
  12408. */
  12409. get output(): NodeMaterialConnectionPoint;
  12410. /**
  12411. * Set the source of this connection point to a vertex attribute
  12412. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  12413. * @returns the current connection point
  12414. */
  12415. setAsAttribute(attributeName?: string): InputBlock;
  12416. /**
  12417. * Set the source of this connection point to a system value
  12418. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  12419. * @returns the current connection point
  12420. */
  12421. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  12422. /**
  12423. * Gets or sets the value of that point.
  12424. * Please note that this value will be ignored if valueCallback is defined
  12425. */
  12426. get value(): any;
  12427. set value(value: any);
  12428. /**
  12429. * Gets or sets a callback used to get the value of that point.
  12430. * Please note that setting this value will force the connection point to ignore the value property
  12431. */
  12432. get valueCallback(): () => any;
  12433. set valueCallback(value: () => any);
  12434. /**
  12435. * Gets or sets the associated variable name in the shader
  12436. */
  12437. get associatedVariableName(): string;
  12438. set associatedVariableName(value: string);
  12439. /** Gets or sets the type of animation applied to the input */
  12440. get animationType(): AnimatedInputBlockTypes;
  12441. set animationType(value: AnimatedInputBlockTypes);
  12442. /**
  12443. * Gets a boolean indicating that this connection point not defined yet
  12444. */
  12445. get isUndefined(): boolean;
  12446. /**
  12447. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  12448. * In this case the connection point name must be the name of the uniform to use.
  12449. * Can only be set on inputs
  12450. */
  12451. get isUniform(): boolean;
  12452. set isUniform(value: boolean);
  12453. /**
  12454. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  12455. * In this case the connection point name must be the name of the attribute to use
  12456. * Can only be set on inputs
  12457. */
  12458. get isAttribute(): boolean;
  12459. set isAttribute(value: boolean);
  12460. /**
  12461. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  12462. * Can only be set on exit points
  12463. */
  12464. get isVarying(): boolean;
  12465. set isVarying(value: boolean);
  12466. /**
  12467. * Gets a boolean indicating that the current connection point is a system value
  12468. */
  12469. get isSystemValue(): boolean;
  12470. /**
  12471. * Gets or sets the current well known value or null if not defined as a system value
  12472. */
  12473. get systemValue(): Nullable<NodeMaterialSystemValues>;
  12474. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  12475. /**
  12476. * Gets the current class name
  12477. * @returns the class name
  12478. */
  12479. getClassName(): string;
  12480. /**
  12481. * Animate the input if animationType !== None
  12482. * @param scene defines the rendering scene
  12483. */
  12484. animate(scene: Scene): void;
  12485. private _emitDefine;
  12486. initialize(state: NodeMaterialBuildState): void;
  12487. /**
  12488. * Set the input block to its default value (based on its type)
  12489. */
  12490. setDefaultValue(): void;
  12491. private _emitConstant;
  12492. /** @hidden */
  12493. get _noContextSwitch(): boolean;
  12494. private _emit;
  12495. /** @hidden */
  12496. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  12497. /** @hidden */
  12498. _transmit(effect: Effect, scene: Scene): void;
  12499. protected _buildBlock(state: NodeMaterialBuildState): void;
  12500. protected _dumpPropertiesCode(): string;
  12501. dispose(): void;
  12502. serialize(): any;
  12503. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12504. }
  12505. }
  12506. declare module BABYLON {
  12507. /**
  12508. * Enum used to define the compatibility state between two connection points
  12509. */
  12510. export enum NodeMaterialConnectionPointCompatibilityStates {
  12511. /** Points are compatibles */
  12512. Compatible = 0,
  12513. /** Points are incompatible because of their types */
  12514. TypeIncompatible = 1,
  12515. /** Points are incompatible because of their targets (vertex vs fragment) */
  12516. TargetIncompatible = 2
  12517. }
  12518. /**
  12519. * Defines the direction of a connection point
  12520. */
  12521. export enum NodeMaterialConnectionPointDirection {
  12522. /** Input */
  12523. Input = 0,
  12524. /** Output */
  12525. Output = 1
  12526. }
  12527. /**
  12528. * Defines a connection point for a block
  12529. */
  12530. export class NodeMaterialConnectionPoint {
  12531. /**
  12532. * Checks if two types are equivalent
  12533. * @param type1 type 1 to check
  12534. * @param type2 type 2 to check
  12535. * @returns true if both types are equivalent, else false
  12536. */
  12537. static AreEquivalentTypes(type1: number, type2: number): boolean;
  12538. /** @hidden */
  12539. _ownerBlock: NodeMaterialBlock;
  12540. /** @hidden */
  12541. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  12542. private _endpoints;
  12543. private _associatedVariableName;
  12544. private _direction;
  12545. /** @hidden */
  12546. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12547. /** @hidden */
  12548. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  12549. /** @hidden */
  12550. _acceptedConnectionPointType: Nullable<NodeMaterialConnectionPoint>;
  12551. private _type;
  12552. /** @hidden */
  12553. _enforceAssociatedVariableName: boolean;
  12554. /** Gets the direction of the point */
  12555. get direction(): NodeMaterialConnectionPointDirection;
  12556. /** Indicates that this connection point needs dual validation before being connected to another point */
  12557. needDualDirectionValidation: boolean;
  12558. /**
  12559. * Gets or sets the additional types supported by this connection point
  12560. */
  12561. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12562. /**
  12563. * Gets or sets the additional types excluded by this connection point
  12564. */
  12565. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  12566. /**
  12567. * Observable triggered when this point is connected
  12568. */
  12569. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  12570. /**
  12571. * Gets or sets the associated variable name in the shader
  12572. */
  12573. get associatedVariableName(): string;
  12574. set associatedVariableName(value: string);
  12575. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  12576. get innerType(): NodeMaterialBlockConnectionPointTypes;
  12577. /**
  12578. * Gets or sets the connection point type (default is float)
  12579. */
  12580. get type(): NodeMaterialBlockConnectionPointTypes;
  12581. set type(value: NodeMaterialBlockConnectionPointTypes);
  12582. /**
  12583. * Gets or sets the connection point name
  12584. */
  12585. name: string;
  12586. /**
  12587. * Gets or sets the connection point name
  12588. */
  12589. displayName: string;
  12590. /**
  12591. * Gets or sets a boolean indicating that this connection point can be omitted
  12592. */
  12593. isOptional: boolean;
  12594. /**
  12595. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  12596. */
  12597. isExposedOnFrame: boolean;
  12598. /**
  12599. * Gets or sets number indicating the position that the port is exposed to on a frame
  12600. */
  12601. exposedPortPosition: number;
  12602. /**
  12603. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  12604. */
  12605. define: string;
  12606. /** @hidden */
  12607. _prioritizeVertex: boolean;
  12608. private _target;
  12609. /** Gets or sets the target of that connection point */
  12610. get target(): NodeMaterialBlockTargets;
  12611. set target(value: NodeMaterialBlockTargets);
  12612. /**
  12613. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  12614. */
  12615. get isConnected(): boolean;
  12616. /**
  12617. * Gets a boolean indicating that the current point is connected to an input block
  12618. */
  12619. get isConnectedToInputBlock(): boolean;
  12620. /**
  12621. * Gets a the connected input block (if any)
  12622. */
  12623. get connectInputBlock(): Nullable<InputBlock>;
  12624. /** Get the other side of the connection (if any) */
  12625. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  12626. /** Get the block that owns this connection point */
  12627. get ownerBlock(): NodeMaterialBlock;
  12628. /** Get the block connected on the other side of this connection (if any) */
  12629. get sourceBlock(): Nullable<NodeMaterialBlock>;
  12630. /** Get the block connected on the endpoints of this connection (if any) */
  12631. get connectedBlocks(): Array<NodeMaterialBlock>;
  12632. /** Gets the list of connected endpoints */
  12633. get endpoints(): NodeMaterialConnectionPoint[];
  12634. /** Gets a boolean indicating if that output point is connected to at least one input */
  12635. get hasEndpoints(): boolean;
  12636. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  12637. get isConnectedInVertexShader(): boolean;
  12638. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  12639. get isConnectedInFragmentShader(): boolean;
  12640. /**
  12641. * Creates a block suitable to be used as an input for this input point.
  12642. * If null is returned, a block based on the point type will be created.
  12643. * @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
  12644. */
  12645. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12646. /**
  12647. * Creates a new connection point
  12648. * @param name defines the connection point name
  12649. * @param ownerBlock defines the block hosting this connection point
  12650. * @param direction defines the direction of the connection point
  12651. */
  12652. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  12653. /**
  12654. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  12655. * @returns the class name
  12656. */
  12657. getClassName(): string;
  12658. /**
  12659. * Gets a boolean indicating if the current point can be connected to another point
  12660. * @param connectionPoint defines the other connection point
  12661. * @returns a boolean
  12662. */
  12663. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  12664. /**
  12665. * Gets a number indicating if the current point can be connected to another point
  12666. * @param connectionPoint defines the other connection point
  12667. * @returns a number defining the compatibility state
  12668. */
  12669. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12670. /**
  12671. * Connect this point to another connection point
  12672. * @param connectionPoint defines the other connection point
  12673. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  12674. * @returns the current connection point
  12675. */
  12676. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  12677. /**
  12678. * Disconnect this point from one of his endpoint
  12679. * @param endpoint defines the other connection point
  12680. * @returns the current connection point
  12681. */
  12682. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  12683. /**
  12684. * Serializes this point in a JSON representation
  12685. * @param isInput defines if the connection point is an input (default is true)
  12686. * @returns the serialized point object
  12687. */
  12688. serialize(isInput?: boolean): any;
  12689. /**
  12690. * Release resources
  12691. */
  12692. dispose(): void;
  12693. }
  12694. }
  12695. declare module BABYLON {
  12696. /**
  12697. * Enum used to define the material modes
  12698. */
  12699. export enum NodeMaterialModes {
  12700. /** Regular material */
  12701. Material = 0,
  12702. /** For post process */
  12703. PostProcess = 1,
  12704. /** For particle system */
  12705. Particle = 2,
  12706. /** For procedural texture */
  12707. ProceduralTexture = 3
  12708. }
  12709. }
  12710. declare module BABYLON {
  12711. /** @hidden */
  12712. export var helperFunctions: {
  12713. name: string;
  12714. shader: string;
  12715. };
  12716. }
  12717. declare module BABYLON {
  12718. /**
  12719. * Block used to read a texture from a sampler
  12720. */
  12721. export class TextureBlock extends NodeMaterialBlock {
  12722. private _defineName;
  12723. private _linearDefineName;
  12724. private _gammaDefineName;
  12725. private _tempTextureRead;
  12726. private _samplerName;
  12727. private _transformedUVName;
  12728. private _textureTransformName;
  12729. private _textureInfoName;
  12730. private _mainUVName;
  12731. private _mainUVDefineName;
  12732. private _fragmentOnly;
  12733. /**
  12734. * Gets or sets the texture associated with the node
  12735. */
  12736. texture: Nullable<Texture>;
  12737. /**
  12738. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  12739. */
  12740. convertToGammaSpace: boolean;
  12741. /**
  12742. * Gets or sets a boolean indicating if content needs to be converted to linear space
  12743. */
  12744. convertToLinearSpace: boolean;
  12745. /**
  12746. * Create a new TextureBlock
  12747. * @param name defines the block name
  12748. */
  12749. constructor(name: string, fragmentOnly?: boolean);
  12750. /**
  12751. * Gets the current class name
  12752. * @returns the class name
  12753. */
  12754. getClassName(): string;
  12755. /**
  12756. * Gets the uv input component
  12757. */
  12758. get uv(): NodeMaterialConnectionPoint;
  12759. /**
  12760. * Gets the rgba output component
  12761. */
  12762. get rgba(): NodeMaterialConnectionPoint;
  12763. /**
  12764. * Gets the rgb output component
  12765. */
  12766. get rgb(): NodeMaterialConnectionPoint;
  12767. /**
  12768. * Gets the r output component
  12769. */
  12770. get r(): NodeMaterialConnectionPoint;
  12771. /**
  12772. * Gets the g output component
  12773. */
  12774. get g(): NodeMaterialConnectionPoint;
  12775. /**
  12776. * Gets the b output component
  12777. */
  12778. get b(): NodeMaterialConnectionPoint;
  12779. /**
  12780. * Gets the a output component
  12781. */
  12782. get a(): NodeMaterialConnectionPoint;
  12783. get target(): NodeMaterialBlockTargets;
  12784. autoConfigure(material: NodeMaterial): void;
  12785. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  12786. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12787. isReady(): boolean;
  12788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12789. private get _isMixed();
  12790. private _injectVertexCode;
  12791. private _writeTextureRead;
  12792. private _writeOutput;
  12793. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  12794. protected _dumpPropertiesCode(): string;
  12795. serialize(): any;
  12796. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12797. }
  12798. }
  12799. declare module BABYLON {
  12800. /** @hidden */
  12801. export var reflectionFunction: {
  12802. name: string;
  12803. shader: string;
  12804. };
  12805. }
  12806. declare module BABYLON {
  12807. /**
  12808. * Base block used to read a reflection texture from a sampler
  12809. */
  12810. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  12811. /** @hidden */
  12812. _define3DName: string;
  12813. /** @hidden */
  12814. _defineCubicName: string;
  12815. /** @hidden */
  12816. _defineExplicitName: string;
  12817. /** @hidden */
  12818. _defineProjectionName: string;
  12819. /** @hidden */
  12820. _defineLocalCubicName: string;
  12821. /** @hidden */
  12822. _defineSphericalName: string;
  12823. /** @hidden */
  12824. _definePlanarName: string;
  12825. /** @hidden */
  12826. _defineEquirectangularName: string;
  12827. /** @hidden */
  12828. _defineMirroredEquirectangularFixedName: string;
  12829. /** @hidden */
  12830. _defineEquirectangularFixedName: string;
  12831. /** @hidden */
  12832. _defineSkyboxName: string;
  12833. /** @hidden */
  12834. _defineOppositeZ: string;
  12835. /** @hidden */
  12836. _cubeSamplerName: string;
  12837. /** @hidden */
  12838. _2DSamplerName: string;
  12839. protected _positionUVWName: string;
  12840. protected _directionWName: string;
  12841. protected _reflectionVectorName: string;
  12842. /** @hidden */
  12843. _reflectionCoordsName: string;
  12844. /** @hidden */
  12845. _reflectionMatrixName: string;
  12846. protected _reflectionColorName: string;
  12847. /**
  12848. * Gets or sets the texture associated with the node
  12849. */
  12850. texture: Nullable<BaseTexture>;
  12851. /**
  12852. * Create a new ReflectionTextureBaseBlock
  12853. * @param name defines the block name
  12854. */
  12855. constructor(name: string);
  12856. /**
  12857. * Gets the current class name
  12858. * @returns the class name
  12859. */
  12860. getClassName(): string;
  12861. /**
  12862. * Gets the world position input component
  12863. */
  12864. abstract get position(): NodeMaterialConnectionPoint;
  12865. /**
  12866. * Gets the world position input component
  12867. */
  12868. abstract get worldPosition(): NodeMaterialConnectionPoint;
  12869. /**
  12870. * Gets the world normal input component
  12871. */
  12872. abstract get worldNormal(): NodeMaterialConnectionPoint;
  12873. /**
  12874. * Gets the world input component
  12875. */
  12876. abstract get world(): NodeMaterialConnectionPoint;
  12877. /**
  12878. * Gets the camera (or eye) position component
  12879. */
  12880. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  12881. /**
  12882. * Gets the view input component
  12883. */
  12884. abstract get view(): NodeMaterialConnectionPoint;
  12885. protected _getTexture(): Nullable<BaseTexture>;
  12886. autoConfigure(material: NodeMaterial): void;
  12887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  12888. isReady(): boolean;
  12889. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  12890. /**
  12891. * Gets the code to inject in the vertex shader
  12892. * @param state current state of the node material building
  12893. * @returns the shader code
  12894. */
  12895. handleVertexSide(state: NodeMaterialBuildState): string;
  12896. /**
  12897. * Handles the inits for the fragment code path
  12898. * @param state node material build state
  12899. */
  12900. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  12901. /**
  12902. * Generates the reflection coords code for the fragment code path
  12903. * @param worldNormalVarName name of the world normal variable
  12904. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  12905. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  12906. * @returns the shader code
  12907. */
  12908. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  12909. /**
  12910. * Generates the reflection color code for the fragment code path
  12911. * @param lodVarName name of the lod variable
  12912. * @param swizzleLookupTexture swizzle to use for the final color variable
  12913. * @returns the shader code
  12914. */
  12915. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  12916. /**
  12917. * Generates the code corresponding to the connected output points
  12918. * @param state node material build state
  12919. * @param varName name of the variable to output
  12920. * @returns the shader code
  12921. */
  12922. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  12923. protected _buildBlock(state: NodeMaterialBuildState): this;
  12924. protected _dumpPropertiesCode(): string;
  12925. serialize(): any;
  12926. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  12927. }
  12928. }
  12929. declare module BABYLON {
  12930. /**
  12931. * Defines a connection point to be used for points with a custom object type
  12932. */
  12933. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  12934. private _blockType;
  12935. private _blockName;
  12936. private _nameForCheking?;
  12937. /**
  12938. * Creates a new connection point
  12939. * @param name defines the connection point name
  12940. * @param ownerBlock defines the block hosting this connection point
  12941. * @param direction defines the direction of the connection point
  12942. */
  12943. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  12944. /**
  12945. * Gets a number indicating if the current point can be connected to another point
  12946. * @param connectionPoint defines the other connection point
  12947. * @returns a number defining the compatibility state
  12948. */
  12949. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  12950. /**
  12951. * Creates a block suitable to be used as an input for this input point.
  12952. * If null is returned, a block based on the point type will be created.
  12953. * @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
  12954. */
  12955. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  12956. }
  12957. }
  12958. declare module BABYLON {
  12959. /**
  12960. * Enum defining the type of properties that can be edited in the property pages in the NME
  12961. */
  12962. export enum PropertyTypeForEdition {
  12963. /** property is a boolean */
  12964. Boolean = 0,
  12965. /** property is a float */
  12966. Float = 1,
  12967. /** property is a Vector2 */
  12968. Vector2 = 2,
  12969. /** property is a list of values */
  12970. List = 3
  12971. }
  12972. /**
  12973. * Interface that defines an option in a variable of type list
  12974. */
  12975. export interface IEditablePropertyListOption {
  12976. /** label of the option */
  12977. "label": string;
  12978. /** value of the option */
  12979. "value": number;
  12980. }
  12981. /**
  12982. * Interface that defines the options available for an editable property
  12983. */
  12984. export interface IEditablePropertyOption {
  12985. /** min value */
  12986. "min"?: number;
  12987. /** max value */
  12988. "max"?: number;
  12989. /** notifiers: indicates which actions to take when the property is changed */
  12990. "notifiers"?: {
  12991. /** the material should be rebuilt */
  12992. "rebuild"?: boolean;
  12993. /** the preview should be updated */
  12994. "update"?: boolean;
  12995. };
  12996. /** list of the options for a variable of type list */
  12997. "options"?: IEditablePropertyListOption[];
  12998. }
  12999. /**
  13000. * Interface that describes an editable property
  13001. */
  13002. export interface IPropertyDescriptionForEdition {
  13003. /** name of the property */
  13004. "propertyName": string;
  13005. /** display name of the property */
  13006. "displayName": string;
  13007. /** type of the property */
  13008. "type": PropertyTypeForEdition;
  13009. /** group of the property - all properties with the same group value will be displayed in a specific section */
  13010. "groupName": string;
  13011. /** options for the property */
  13012. "options": IEditablePropertyOption;
  13013. }
  13014. /**
  13015. * Decorator that flags a property in a node material block as being editable
  13016. */
  13017. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  13018. }
  13019. declare module BABYLON {
  13020. /**
  13021. * Block used to implement the refraction part of the sub surface module of the PBR material
  13022. */
  13023. export class RefractionBlock extends NodeMaterialBlock {
  13024. /** @hidden */
  13025. _define3DName: string;
  13026. /** @hidden */
  13027. _refractionMatrixName: string;
  13028. /** @hidden */
  13029. _defineLODRefractionAlpha: string;
  13030. /** @hidden */
  13031. _defineLinearSpecularRefraction: string;
  13032. /** @hidden */
  13033. _defineOppositeZ: string;
  13034. /** @hidden */
  13035. _cubeSamplerName: string;
  13036. /** @hidden */
  13037. _2DSamplerName: string;
  13038. /** @hidden */
  13039. _vRefractionMicrosurfaceInfosName: string;
  13040. /** @hidden */
  13041. _vRefractionInfosName: string;
  13042. /** @hidden */
  13043. _vRefractionFilteringInfoName: string;
  13044. private _scene;
  13045. /**
  13046. * The properties below are set by the main PBR block prior to calling methods of this class.
  13047. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  13048. * It's less burden on the user side in the editor part.
  13049. */
  13050. /** @hidden */
  13051. viewConnectionPoint: NodeMaterialConnectionPoint;
  13052. /** @hidden */
  13053. indexOfRefractionConnectionPoint: NodeMaterialConnectionPoint;
  13054. /**
  13055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  13056. * Materials half opaque for instance using refraction could benefit from this control.
  13057. */
  13058. linkRefractionWithTransparency: boolean;
  13059. /**
  13060. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  13061. */
  13062. invertRefractionY: boolean;
  13063. /**
  13064. * Gets or sets the texture associated with the node
  13065. */
  13066. texture: Nullable<BaseTexture>;
  13067. /**
  13068. * Create a new RefractionBlock
  13069. * @param name defines the block name
  13070. */
  13071. constructor(name: string);
  13072. /**
  13073. * Gets the current class name
  13074. * @returns the class name
  13075. */
  13076. getClassName(): string;
  13077. /**
  13078. * Gets the intensity input component
  13079. */
  13080. get intensity(): NodeMaterialConnectionPoint;
  13081. /**
  13082. * Gets the tint at distance input component
  13083. */
  13084. get tintAtDistance(): NodeMaterialConnectionPoint;
  13085. /**
  13086. * Gets the view input component
  13087. */
  13088. get view(): NodeMaterialConnectionPoint;
  13089. /**
  13090. * Gets the refraction object output component
  13091. */
  13092. get refraction(): NodeMaterialConnectionPoint;
  13093. /**
  13094. * Returns true if the block has a texture
  13095. */
  13096. get hasTexture(): boolean;
  13097. protected _getTexture(): Nullable<BaseTexture>;
  13098. autoConfigure(material: NodeMaterial): void;
  13099. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13100. isReady(): boolean;
  13101. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13102. /**
  13103. * Gets the main code of the block (fragment side)
  13104. * @param state current state of the node material building
  13105. * @returns the shader code
  13106. */
  13107. getCode(state: NodeMaterialBuildState): string;
  13108. protected _buildBlock(state: NodeMaterialBuildState): this;
  13109. protected _dumpPropertiesCode(): string;
  13110. serialize(): any;
  13111. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13112. }
  13113. }
  13114. declare module BABYLON {
  13115. /**
  13116. * Base block used as input for post process
  13117. */
  13118. export class CurrentScreenBlock extends NodeMaterialBlock {
  13119. private _samplerName;
  13120. private _linearDefineName;
  13121. private _gammaDefineName;
  13122. private _mainUVName;
  13123. private _tempTextureRead;
  13124. /**
  13125. * Gets or sets the texture associated with the node
  13126. */
  13127. texture: Nullable<BaseTexture>;
  13128. /**
  13129. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13130. */
  13131. convertToGammaSpace: boolean;
  13132. /**
  13133. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13134. */
  13135. convertToLinearSpace: boolean;
  13136. /**
  13137. * Create a new CurrentScreenBlock
  13138. * @param name defines the block name
  13139. */
  13140. constructor(name: string);
  13141. /**
  13142. * Gets the current class name
  13143. * @returns the class name
  13144. */
  13145. getClassName(): string;
  13146. /**
  13147. * Gets the uv input component
  13148. */
  13149. get uv(): NodeMaterialConnectionPoint;
  13150. /**
  13151. * Gets the rgba output component
  13152. */
  13153. get rgba(): NodeMaterialConnectionPoint;
  13154. /**
  13155. * Gets the rgb output component
  13156. */
  13157. get rgb(): NodeMaterialConnectionPoint;
  13158. /**
  13159. * Gets the r output component
  13160. */
  13161. get r(): NodeMaterialConnectionPoint;
  13162. /**
  13163. * Gets the g output component
  13164. */
  13165. get g(): NodeMaterialConnectionPoint;
  13166. /**
  13167. * Gets the b output component
  13168. */
  13169. get b(): NodeMaterialConnectionPoint;
  13170. /**
  13171. * Gets the a output component
  13172. */
  13173. get a(): NodeMaterialConnectionPoint;
  13174. /**
  13175. * Initialize the block and prepare the context for build
  13176. * @param state defines the state that will be used for the build
  13177. */
  13178. initialize(state: NodeMaterialBuildState): void;
  13179. get target(): NodeMaterialBlockTargets;
  13180. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13181. isReady(): boolean;
  13182. private _injectVertexCode;
  13183. private _writeTextureRead;
  13184. private _writeOutput;
  13185. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13186. serialize(): any;
  13187. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13188. }
  13189. }
  13190. declare module BABYLON {
  13191. /**
  13192. * Base block used for the particle texture
  13193. */
  13194. export class ParticleTextureBlock extends NodeMaterialBlock {
  13195. private _samplerName;
  13196. private _linearDefineName;
  13197. private _gammaDefineName;
  13198. private _tempTextureRead;
  13199. /**
  13200. * Gets or sets the texture associated with the node
  13201. */
  13202. texture: Nullable<BaseTexture>;
  13203. /**
  13204. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  13205. */
  13206. convertToGammaSpace: boolean;
  13207. /**
  13208. * Gets or sets a boolean indicating if content needs to be converted to linear space
  13209. */
  13210. convertToLinearSpace: boolean;
  13211. /**
  13212. * Create a new ParticleTextureBlock
  13213. * @param name defines the block name
  13214. */
  13215. constructor(name: string);
  13216. /**
  13217. * Gets the current class name
  13218. * @returns the class name
  13219. */
  13220. getClassName(): string;
  13221. /**
  13222. * Gets the uv input component
  13223. */
  13224. get uv(): NodeMaterialConnectionPoint;
  13225. /**
  13226. * Gets the rgba output component
  13227. */
  13228. get rgba(): NodeMaterialConnectionPoint;
  13229. /**
  13230. * Gets the rgb output component
  13231. */
  13232. get rgb(): NodeMaterialConnectionPoint;
  13233. /**
  13234. * Gets the r output component
  13235. */
  13236. get r(): NodeMaterialConnectionPoint;
  13237. /**
  13238. * Gets the g output component
  13239. */
  13240. get g(): NodeMaterialConnectionPoint;
  13241. /**
  13242. * Gets the b output component
  13243. */
  13244. get b(): NodeMaterialConnectionPoint;
  13245. /**
  13246. * Gets the a output component
  13247. */
  13248. get a(): NodeMaterialConnectionPoint;
  13249. /**
  13250. * Initialize the block and prepare the context for build
  13251. * @param state defines the state that will be used for the build
  13252. */
  13253. initialize(state: NodeMaterialBuildState): void;
  13254. autoConfigure(material: NodeMaterial): void;
  13255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  13256. isReady(): boolean;
  13257. private _writeOutput;
  13258. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13259. serialize(): any;
  13260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13261. }
  13262. }
  13263. declare module BABYLON {
  13264. /**
  13265. * Class used to store shared data between 2 NodeMaterialBuildState
  13266. */
  13267. export class NodeMaterialBuildStateSharedData {
  13268. /**
  13269. * Gets the list of emitted varyings
  13270. */
  13271. temps: string[];
  13272. /**
  13273. * Gets the list of emitted varyings
  13274. */
  13275. varyings: string[];
  13276. /**
  13277. * Gets the varying declaration string
  13278. */
  13279. varyingDeclaration: string;
  13280. /**
  13281. * Input blocks
  13282. */
  13283. inputBlocks: InputBlock[];
  13284. /**
  13285. * Input blocks
  13286. */
  13287. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  13288. /**
  13289. * Bindable blocks (Blocks that need to set data to the effect)
  13290. */
  13291. bindableBlocks: NodeMaterialBlock[];
  13292. /**
  13293. * List of blocks that can provide a compilation fallback
  13294. */
  13295. blocksWithFallbacks: NodeMaterialBlock[];
  13296. /**
  13297. * List of blocks that can provide a define update
  13298. */
  13299. blocksWithDefines: NodeMaterialBlock[];
  13300. /**
  13301. * List of blocks that can provide a repeatable content
  13302. */
  13303. repeatableContentBlocks: NodeMaterialBlock[];
  13304. /**
  13305. * List of blocks that can provide a dynamic list of uniforms
  13306. */
  13307. dynamicUniformBlocks: NodeMaterialBlock[];
  13308. /**
  13309. * List of blocks that can block the isReady function for the material
  13310. */
  13311. blockingBlocks: NodeMaterialBlock[];
  13312. /**
  13313. * Gets the list of animated inputs
  13314. */
  13315. animatedInputs: InputBlock[];
  13316. /**
  13317. * Build Id used to avoid multiple recompilations
  13318. */
  13319. buildId: number;
  13320. /** List of emitted variables */
  13321. variableNames: {
  13322. [key: string]: number;
  13323. };
  13324. /** List of emitted defines */
  13325. defineNames: {
  13326. [key: string]: number;
  13327. };
  13328. /** Should emit comments? */
  13329. emitComments: boolean;
  13330. /** Emit build activity */
  13331. verbose: boolean;
  13332. /** Gets or sets the hosting scene */
  13333. scene: Scene;
  13334. /**
  13335. * Gets the compilation hints emitted at compilation time
  13336. */
  13337. hints: {
  13338. needWorldViewMatrix: boolean;
  13339. needWorldViewProjectionMatrix: boolean;
  13340. needAlphaBlending: boolean;
  13341. needAlphaTesting: boolean;
  13342. };
  13343. /**
  13344. * List of compilation checks
  13345. */
  13346. checks: {
  13347. emitVertex: boolean;
  13348. emitFragment: boolean;
  13349. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  13350. };
  13351. /**
  13352. * Is vertex program allowed to be empty?
  13353. */
  13354. allowEmptyVertexProgram: boolean;
  13355. /** Creates a new shared data */
  13356. constructor();
  13357. /**
  13358. * Emits console errors and exceptions if there is a failing check
  13359. */
  13360. emitErrors(): void;
  13361. }
  13362. }
  13363. declare module BABYLON {
  13364. /**
  13365. * Class used to store node based material build state
  13366. */
  13367. export class NodeMaterialBuildState {
  13368. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  13369. supportUniformBuffers: boolean;
  13370. /**
  13371. * Gets the list of emitted attributes
  13372. */
  13373. attributes: string[];
  13374. /**
  13375. * Gets the list of emitted uniforms
  13376. */
  13377. uniforms: string[];
  13378. /**
  13379. * Gets the list of emitted constants
  13380. */
  13381. constants: string[];
  13382. /**
  13383. * Gets the list of emitted samplers
  13384. */
  13385. samplers: string[];
  13386. /**
  13387. * Gets the list of emitted functions
  13388. */
  13389. functions: {
  13390. [key: string]: string;
  13391. };
  13392. /**
  13393. * Gets the list of emitted extensions
  13394. */
  13395. extensions: {
  13396. [key: string]: string;
  13397. };
  13398. /**
  13399. * Gets the target of the compilation state
  13400. */
  13401. target: NodeMaterialBlockTargets;
  13402. /**
  13403. * Gets the list of emitted counters
  13404. */
  13405. counters: {
  13406. [key: string]: number;
  13407. };
  13408. /**
  13409. * Shared data between multiple NodeMaterialBuildState instances
  13410. */
  13411. sharedData: NodeMaterialBuildStateSharedData;
  13412. /** @hidden */
  13413. _vertexState: NodeMaterialBuildState;
  13414. /** @hidden */
  13415. _attributeDeclaration: string;
  13416. /** @hidden */
  13417. _uniformDeclaration: string;
  13418. /** @hidden */
  13419. _constantDeclaration: string;
  13420. /** @hidden */
  13421. _samplerDeclaration: string;
  13422. /** @hidden */
  13423. _varyingTransfer: string;
  13424. /** @hidden */
  13425. _injectAtEnd: string;
  13426. private _repeatableContentAnchorIndex;
  13427. /** @hidden */
  13428. _builtCompilationString: string;
  13429. /**
  13430. * Gets the emitted compilation strings
  13431. */
  13432. compilationString: string;
  13433. /**
  13434. * Finalize the compilation strings
  13435. * @param state defines the current compilation state
  13436. */
  13437. finalize(state: NodeMaterialBuildState): void;
  13438. /** @hidden */
  13439. get _repeatableContentAnchor(): string;
  13440. /** @hidden */
  13441. _getFreeVariableName(prefix: string): string;
  13442. /** @hidden */
  13443. _getFreeDefineName(prefix: string): string;
  13444. /** @hidden */
  13445. _excludeVariableName(name: string): void;
  13446. /** @hidden */
  13447. _emit2DSampler(name: string): void;
  13448. /** @hidden */
  13449. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  13450. /** @hidden */
  13451. _emitExtension(name: string, extension: string, define?: string): void;
  13452. /** @hidden */
  13453. _emitFunction(name: string, code: string, comments: string): void;
  13454. /** @hidden */
  13455. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  13456. replaceStrings?: {
  13457. search: RegExp;
  13458. replace: string;
  13459. }[];
  13460. repeatKey?: string;
  13461. }): string;
  13462. /** @hidden */
  13463. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  13464. repeatKey?: string;
  13465. removeAttributes?: boolean;
  13466. removeUniforms?: boolean;
  13467. removeVaryings?: boolean;
  13468. removeIfDef?: boolean;
  13469. replaceStrings?: {
  13470. search: RegExp;
  13471. replace: string;
  13472. }[];
  13473. }, storeKey?: string): void;
  13474. /** @hidden */
  13475. _registerTempVariable(name: string): boolean;
  13476. /** @hidden */
  13477. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  13478. /** @hidden */
  13479. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  13480. /** @hidden */
  13481. _emitFloat(value: number): string;
  13482. }
  13483. }
  13484. declare module BABYLON {
  13485. /**
  13486. * Helper class used to generate session unique ID
  13487. */
  13488. export class UniqueIdGenerator {
  13489. private static _UniqueIdCounter;
  13490. /**
  13491. * Gets an unique (relatively to the current scene) Id
  13492. */
  13493. static get UniqueId(): number;
  13494. }
  13495. }
  13496. declare module BABYLON {
  13497. /**
  13498. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  13499. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  13500. */
  13501. export class EffectFallbacks implements IEffectFallbacks {
  13502. private _defines;
  13503. private _currentRank;
  13504. private _maxRank;
  13505. private _mesh;
  13506. /**
  13507. * Removes the fallback from the bound mesh.
  13508. */
  13509. unBindMesh(): void;
  13510. /**
  13511. * Adds a fallback on the specified property.
  13512. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13513. * @param define The name of the define in the shader
  13514. */
  13515. addFallback(rank: number, define: string): void;
  13516. /**
  13517. * Sets the mesh to use CPU skinning when needing to fallback.
  13518. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  13519. * @param mesh The mesh to use the fallbacks.
  13520. */
  13521. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  13522. /**
  13523. * Checks to see if more fallbacks are still availible.
  13524. */
  13525. get hasMoreFallbacks(): boolean;
  13526. /**
  13527. * Removes the defines that should be removed when falling back.
  13528. * @param currentDefines defines the current define statements for the shader.
  13529. * @param effect defines the current effect we try to compile
  13530. * @returns The resulting defines with defines of the current rank removed.
  13531. */
  13532. reduce(currentDefines: string, effect: Effect): string;
  13533. }
  13534. }
  13535. declare module BABYLON {
  13536. /**
  13537. * Defines a block that can be used inside a node based material
  13538. */
  13539. export class NodeMaterialBlock {
  13540. private _buildId;
  13541. private _buildTarget;
  13542. private _target;
  13543. private _isFinalMerger;
  13544. private _isInput;
  13545. private _name;
  13546. protected _isUnique: boolean;
  13547. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  13548. inputsAreExclusive: boolean;
  13549. /** @hidden */
  13550. _codeVariableName: string;
  13551. /** @hidden */
  13552. _inputs: NodeMaterialConnectionPoint[];
  13553. /** @hidden */
  13554. _outputs: NodeMaterialConnectionPoint[];
  13555. /** @hidden */
  13556. _preparationId: number;
  13557. /**
  13558. * Gets the name of the block
  13559. */
  13560. get name(): string;
  13561. /**
  13562. * Sets the name of the block. Will check if the name is valid.
  13563. */
  13564. set name(newName: string);
  13565. /**
  13566. * Gets or sets the unique id of the node
  13567. */
  13568. uniqueId: number;
  13569. /**
  13570. * Gets or sets the comments associated with this block
  13571. */
  13572. comments: string;
  13573. /**
  13574. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  13575. */
  13576. get isUnique(): boolean;
  13577. /**
  13578. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  13579. */
  13580. get isFinalMerger(): boolean;
  13581. /**
  13582. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  13583. */
  13584. get isInput(): boolean;
  13585. /**
  13586. * Gets or sets the build Id
  13587. */
  13588. get buildId(): number;
  13589. set buildId(value: number);
  13590. /**
  13591. * Gets or sets the target of the block
  13592. */
  13593. get target(): NodeMaterialBlockTargets;
  13594. set target(value: NodeMaterialBlockTargets);
  13595. /**
  13596. * Gets the list of input points
  13597. */
  13598. get inputs(): NodeMaterialConnectionPoint[];
  13599. /** Gets the list of output points */
  13600. get outputs(): NodeMaterialConnectionPoint[];
  13601. /**
  13602. * Find an input by its name
  13603. * @param name defines the name of the input to look for
  13604. * @returns the input or null if not found
  13605. */
  13606. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13607. /**
  13608. * Find an output by its name
  13609. * @param name defines the name of the outputto look for
  13610. * @returns the output or null if not found
  13611. */
  13612. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  13613. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  13614. visibleInInspector: boolean;
  13615. /** Gets or sets a boolean indicating that this input can be edited from a collapsed frame*/
  13616. visibleOnFrame: boolean;
  13617. /**
  13618. * Creates a new NodeMaterialBlock
  13619. * @param name defines the block name
  13620. * @param target defines the target of that block (Vertex by default)
  13621. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  13622. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  13623. */
  13624. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  13625. /**
  13626. * Initialize the block and prepare the context for build
  13627. * @param state defines the state that will be used for the build
  13628. */
  13629. initialize(state: NodeMaterialBuildState): void;
  13630. /**
  13631. * Bind data to effect. Will only be called for blocks with isBindable === true
  13632. * @param effect defines the effect to bind data to
  13633. * @param nodeMaterial defines the hosting NodeMaterial
  13634. * @param mesh defines the mesh that will be rendered
  13635. * @param subMesh defines the submesh that will be rendered
  13636. */
  13637. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  13638. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  13639. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  13640. protected _writeFloat(value: number): string;
  13641. /**
  13642. * Gets the current class name e.g. "NodeMaterialBlock"
  13643. * @returns the class name
  13644. */
  13645. getClassName(): string;
  13646. /**
  13647. * Register a new input. Must be called inside a block constructor
  13648. * @param name defines the connection point name
  13649. * @param type defines the connection point type
  13650. * @param isOptional defines a boolean indicating that this input can be omitted
  13651. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13652. * @param point an already created connection point. If not provided, create a new one
  13653. * @returns the current block
  13654. */
  13655. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13656. /**
  13657. * Register a new output. Must be called inside a block constructor
  13658. * @param name defines the connection point name
  13659. * @param type defines the connection point type
  13660. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  13661. * @param point an already created connection point. If not provided, create a new one
  13662. * @returns the current block
  13663. */
  13664. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  13665. /**
  13666. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  13667. * @param forOutput defines an optional connection point to check compatibility with
  13668. * @returns the first available input or null
  13669. */
  13670. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  13671. /**
  13672. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  13673. * @param forBlock defines an optional block to check compatibility with
  13674. * @returns the first available input or null
  13675. */
  13676. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  13677. /**
  13678. * Gets the sibling of the given output
  13679. * @param current defines the current output
  13680. * @returns the next output in the list or null
  13681. */
  13682. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  13683. /**
  13684. * Connect current block with another block
  13685. * @param other defines the block to connect with
  13686. * @param options define the various options to help pick the right connections
  13687. * @returns the current block
  13688. */
  13689. connectTo(other: NodeMaterialBlock, options?: {
  13690. input?: string;
  13691. output?: string;
  13692. outputSwizzle?: string;
  13693. }): this | undefined;
  13694. protected _buildBlock(state: NodeMaterialBuildState): void;
  13695. /**
  13696. * Add uniforms, samplers and uniform buffers at compilation time
  13697. * @param state defines the state to update
  13698. * @param nodeMaterial defines the node material requesting the update
  13699. * @param defines defines the material defines to update
  13700. * @param uniformBuffers defines the list of uniform buffer names
  13701. */
  13702. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  13703. /**
  13704. * Add potential fallbacks if shader compilation fails
  13705. * @param mesh defines the mesh to be rendered
  13706. * @param fallbacks defines the current prioritized list of fallbacks
  13707. */
  13708. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  13709. /**
  13710. * Initialize defines for shader compilation
  13711. * @param mesh defines the mesh to be rendered
  13712. * @param nodeMaterial defines the node material requesting the update
  13713. * @param defines defines the material defines to update
  13714. * @param useInstances specifies that instances should be used
  13715. */
  13716. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  13717. /**
  13718. * Update defines for shader compilation
  13719. * @param mesh defines the mesh to be rendered
  13720. * @param nodeMaterial defines the node material requesting the update
  13721. * @param defines defines the material defines to update
  13722. * @param useInstances specifies that instances should be used
  13723. * @param subMesh defines which submesh to render
  13724. */
  13725. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13726. /**
  13727. * Lets the block try to connect some inputs automatically
  13728. * @param material defines the hosting NodeMaterial
  13729. */
  13730. autoConfigure(material: NodeMaterial): void;
  13731. /**
  13732. * Function called when a block is declared as repeatable content generator
  13733. * @param vertexShaderState defines the current compilation state for the vertex shader
  13734. * @param fragmentShaderState defines the current compilation state for the fragment shader
  13735. * @param mesh defines the mesh to be rendered
  13736. * @param defines defines the material defines to update
  13737. */
  13738. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  13739. /**
  13740. * Checks if the block is ready
  13741. * @param mesh defines the mesh to be rendered
  13742. * @param nodeMaterial defines the node material requesting the update
  13743. * @param defines defines the material defines to update
  13744. * @param useInstances specifies that instances should be used
  13745. * @returns true if the block is ready
  13746. */
  13747. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  13748. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number, looseCoupling?: boolean): void;
  13749. private _processBuild;
  13750. /**
  13751. * Validates the new name for the block node.
  13752. * @param newName the new name to be given to the node.
  13753. * @returns false if the name is a reserve word, else true.
  13754. */
  13755. validateBlockName(newName: string): boolean;
  13756. /**
  13757. * Compile the current node and generate the shader code
  13758. * @param state defines the current compilation state (uniforms, samplers, current string)
  13759. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  13760. * @returns true if already built
  13761. */
  13762. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  13763. protected _inputRename(name: string): string;
  13764. protected _outputRename(name: string): string;
  13765. protected _dumpPropertiesCode(): string;
  13766. /** @hidden */
  13767. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  13768. /** @hidden */
  13769. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  13770. /**
  13771. * Clone the current block to a new identical block
  13772. * @param scene defines the hosting scene
  13773. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  13774. * @returns a copy of the current block
  13775. */
  13776. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  13777. /**
  13778. * Serializes this block in a JSON representation
  13779. * @returns the serialized block object
  13780. */
  13781. serialize(): any;
  13782. /** @hidden */
  13783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13784. private _deserializePortDisplayNamesAndExposedOnFrame;
  13785. /**
  13786. * Release resources
  13787. */
  13788. dispose(): void;
  13789. }
  13790. }
  13791. declare module BABYLON {
  13792. /**
  13793. * Base class of materials working in push mode in babylon JS
  13794. * @hidden
  13795. */
  13796. export class PushMaterial extends Material {
  13797. protected _activeEffect: Effect;
  13798. protected _normalMatrix: Matrix;
  13799. constructor(name: string, scene: Scene);
  13800. getEffect(): Effect;
  13801. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  13802. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  13803. /**
  13804. * Binds the given world matrix to the active effect
  13805. *
  13806. * @param world the matrix to bind
  13807. */
  13808. bindOnlyWorldMatrix(world: Matrix): void;
  13809. /**
  13810. * Binds the given normal matrix to the active effect
  13811. *
  13812. * @param normalMatrix the matrix to bind
  13813. */
  13814. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  13815. bind(world: Matrix, mesh?: Mesh): void;
  13816. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  13817. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  13818. }
  13819. }
  13820. declare module BABYLON {
  13821. /**
  13822. * Root class for all node material optimizers
  13823. */
  13824. export class NodeMaterialOptimizer {
  13825. /**
  13826. * Function used to optimize a NodeMaterial graph
  13827. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  13828. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  13829. */
  13830. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  13831. }
  13832. }
  13833. declare module BABYLON {
  13834. /**
  13835. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  13836. */
  13837. export class TransformBlock extends NodeMaterialBlock {
  13838. /**
  13839. * Defines the value to use to complement W value to transform it to a Vector4
  13840. */
  13841. complementW: number;
  13842. /**
  13843. * Defines the value to use to complement z value to transform it to a Vector4
  13844. */
  13845. complementZ: number;
  13846. /**
  13847. * Creates a new TransformBlock
  13848. * @param name defines the block name
  13849. */
  13850. constructor(name: string);
  13851. /**
  13852. * Gets the current class name
  13853. * @returns the class name
  13854. */
  13855. getClassName(): string;
  13856. /**
  13857. * Gets the vector input
  13858. */
  13859. get vector(): NodeMaterialConnectionPoint;
  13860. /**
  13861. * Gets the output component
  13862. */
  13863. get output(): NodeMaterialConnectionPoint;
  13864. /**
  13865. * Gets the xyz output component
  13866. */
  13867. get xyz(): NodeMaterialConnectionPoint;
  13868. /**
  13869. * Gets the matrix transform input
  13870. */
  13871. get transform(): NodeMaterialConnectionPoint;
  13872. protected _buildBlock(state: NodeMaterialBuildState): this;
  13873. /**
  13874. * Update defines for shader compilation
  13875. * @param mesh defines the mesh to be rendered
  13876. * @param nodeMaterial defines the node material requesting the update
  13877. * @param defines defines the material defines to update
  13878. * @param useInstances specifies that instances should be used
  13879. * @param subMesh defines which submesh to render
  13880. */
  13881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  13882. serialize(): any;
  13883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  13884. protected _dumpPropertiesCode(): string;
  13885. }
  13886. }
  13887. declare module BABYLON {
  13888. /**
  13889. * Block used to output the vertex position
  13890. */
  13891. export class VertexOutputBlock extends NodeMaterialBlock {
  13892. /**
  13893. * Creates a new VertexOutputBlock
  13894. * @param name defines the block name
  13895. */
  13896. constructor(name: string);
  13897. /**
  13898. * Gets the current class name
  13899. * @returns the class name
  13900. */
  13901. getClassName(): string;
  13902. /**
  13903. * Gets the vector input component
  13904. */
  13905. get vector(): NodeMaterialConnectionPoint;
  13906. protected _buildBlock(state: NodeMaterialBuildState): this;
  13907. }
  13908. }
  13909. declare module BABYLON {
  13910. /**
  13911. * Block used to output the final color
  13912. */
  13913. export class FragmentOutputBlock extends NodeMaterialBlock {
  13914. /**
  13915. * Create a new FragmentOutputBlock
  13916. * @param name defines the block name
  13917. */
  13918. constructor(name: string);
  13919. /**
  13920. * Gets the current class name
  13921. * @returns the class name
  13922. */
  13923. getClassName(): string;
  13924. /**
  13925. * Gets the rgba input component
  13926. */
  13927. get rgba(): NodeMaterialConnectionPoint;
  13928. /**
  13929. * Gets the rgb input component
  13930. */
  13931. get rgb(): NodeMaterialConnectionPoint;
  13932. /**
  13933. * Gets the a input component
  13934. */
  13935. get a(): NodeMaterialConnectionPoint;
  13936. protected _buildBlock(state: NodeMaterialBuildState): this;
  13937. }
  13938. }
  13939. declare module BABYLON {
  13940. /**
  13941. * Block used for the particle ramp gradient section
  13942. */
  13943. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  13944. /**
  13945. * Create a new ParticleRampGradientBlock
  13946. * @param name defines the block name
  13947. */
  13948. constructor(name: string);
  13949. /**
  13950. * Gets the current class name
  13951. * @returns the class name
  13952. */
  13953. getClassName(): string;
  13954. /**
  13955. * Gets the color input component
  13956. */
  13957. get color(): NodeMaterialConnectionPoint;
  13958. /**
  13959. * Gets the rampColor output component
  13960. */
  13961. get rampColor(): NodeMaterialConnectionPoint;
  13962. /**
  13963. * Initialize the block and prepare the context for build
  13964. * @param state defines the state that will be used for the build
  13965. */
  13966. initialize(state: NodeMaterialBuildState): void;
  13967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  13968. }
  13969. }
  13970. declare module BABYLON {
  13971. /**
  13972. * Block used for the particle blend multiply section
  13973. */
  13974. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  13975. /**
  13976. * Create a new ParticleBlendMultiplyBlock
  13977. * @param name defines the block name
  13978. */
  13979. constructor(name: string);
  13980. /**
  13981. * Gets the current class name
  13982. * @returns the class name
  13983. */
  13984. getClassName(): string;
  13985. /**
  13986. * Gets the color input component
  13987. */
  13988. get color(): NodeMaterialConnectionPoint;
  13989. /**
  13990. * Gets the alphaTexture input component
  13991. */
  13992. get alphaTexture(): NodeMaterialConnectionPoint;
  13993. /**
  13994. * Gets the alphaColor input component
  13995. */
  13996. get alphaColor(): NodeMaterialConnectionPoint;
  13997. /**
  13998. * Gets the blendColor output component
  13999. */
  14000. get blendColor(): NodeMaterialConnectionPoint;
  14001. /**
  14002. * Initialize the block and prepare the context for build
  14003. * @param state defines the state that will be used for the build
  14004. */
  14005. initialize(state: NodeMaterialBuildState): void;
  14006. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  14007. }
  14008. }
  14009. declare module BABYLON {
  14010. /**
  14011. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  14012. */
  14013. export class VectorMergerBlock extends NodeMaterialBlock {
  14014. /**
  14015. * Create a new VectorMergerBlock
  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 xyz component (input)
  14026. */
  14027. get xyzIn(): NodeMaterialConnectionPoint;
  14028. /**
  14029. * Gets the xy component (input)
  14030. */
  14031. get xyIn(): NodeMaterialConnectionPoint;
  14032. /**
  14033. * Gets the x component (input)
  14034. */
  14035. get x(): NodeMaterialConnectionPoint;
  14036. /**
  14037. * Gets the y component (input)
  14038. */
  14039. get y(): NodeMaterialConnectionPoint;
  14040. /**
  14041. * Gets the z component (input)
  14042. */
  14043. get z(): NodeMaterialConnectionPoint;
  14044. /**
  14045. * Gets the w component (input)
  14046. */
  14047. get w(): NodeMaterialConnectionPoint;
  14048. /**
  14049. * Gets the xyzw component (output)
  14050. */
  14051. get xyzw(): NodeMaterialConnectionPoint;
  14052. /**
  14053. * Gets the xyz component (output)
  14054. */
  14055. get xyzOut(): NodeMaterialConnectionPoint;
  14056. /**
  14057. * Gets the xy component (output)
  14058. */
  14059. get xyOut(): NodeMaterialConnectionPoint;
  14060. /**
  14061. * Gets the xy component (output)
  14062. * @deprecated Please use xyOut instead.
  14063. */
  14064. get xy(): NodeMaterialConnectionPoint;
  14065. /**
  14066. * Gets the xyz component (output)
  14067. * @deprecated Please use xyzOut instead.
  14068. */
  14069. get xyz(): NodeMaterialConnectionPoint;
  14070. protected _buildBlock(state: NodeMaterialBuildState): this;
  14071. }
  14072. }
  14073. declare module BABYLON {
  14074. /**
  14075. * Block used to remap a float from a range to a new one
  14076. */
  14077. export class RemapBlock extends NodeMaterialBlock {
  14078. /**
  14079. * Gets or sets the source range
  14080. */
  14081. sourceRange: Vector2;
  14082. /**
  14083. * Gets or sets the target range
  14084. */
  14085. targetRange: Vector2;
  14086. /**
  14087. * Creates a new RemapBlock
  14088. * @param name defines the block name
  14089. */
  14090. constructor(name: string);
  14091. /**
  14092. * Gets the current class name
  14093. * @returns the class name
  14094. */
  14095. getClassName(): string;
  14096. /**
  14097. * Gets the input component
  14098. */
  14099. get input(): NodeMaterialConnectionPoint;
  14100. /**
  14101. * Gets the source min input component
  14102. */
  14103. get sourceMin(): NodeMaterialConnectionPoint;
  14104. /**
  14105. * Gets the source max input component
  14106. */
  14107. get sourceMax(): NodeMaterialConnectionPoint;
  14108. /**
  14109. * Gets the target min input component
  14110. */
  14111. get targetMin(): NodeMaterialConnectionPoint;
  14112. /**
  14113. * Gets the target max input component
  14114. */
  14115. get targetMax(): NodeMaterialConnectionPoint;
  14116. /**
  14117. * Gets the output component
  14118. */
  14119. get output(): NodeMaterialConnectionPoint;
  14120. protected _buildBlock(state: NodeMaterialBuildState): this;
  14121. protected _dumpPropertiesCode(): string;
  14122. serialize(): any;
  14123. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  14124. }
  14125. }
  14126. declare module BABYLON {
  14127. /**
  14128. * Block used to multiply 2 values
  14129. */
  14130. export class MultiplyBlock extends NodeMaterialBlock {
  14131. /**
  14132. * Creates a new MultiplyBlock
  14133. * @param name defines the block name
  14134. */
  14135. constructor(name: string);
  14136. /**
  14137. * Gets the current class name
  14138. * @returns the class name
  14139. */
  14140. getClassName(): string;
  14141. /**
  14142. * Gets the left operand input component
  14143. */
  14144. get left(): NodeMaterialConnectionPoint;
  14145. /**
  14146. * Gets the right operand input component
  14147. */
  14148. get right(): NodeMaterialConnectionPoint;
  14149. /**
  14150. * Gets the output component
  14151. */
  14152. get output(): NodeMaterialConnectionPoint;
  14153. protected _buildBlock(state: NodeMaterialBuildState): this;
  14154. }
  14155. }
  14156. declare module BABYLON {
  14157. /** Interface used by value gradients (color, factor, ...) */
  14158. export interface IValueGradient {
  14159. /**
  14160. * Gets or sets the gradient value (between 0 and 1)
  14161. */
  14162. gradient: number;
  14163. }
  14164. /** Class used to store color4 gradient */
  14165. export class ColorGradient implements IValueGradient {
  14166. /**
  14167. * Gets or sets the gradient value (between 0 and 1)
  14168. */
  14169. gradient: number;
  14170. /**
  14171. * Gets or sets first associated color
  14172. */
  14173. color1: Color4;
  14174. /**
  14175. * Gets or sets second associated color
  14176. */
  14177. color2?: Color4 | undefined;
  14178. /**
  14179. * Creates a new color4 gradient
  14180. * @param gradient gets or sets the gradient value (between 0 and 1)
  14181. * @param color1 gets or sets first associated color
  14182. * @param color2 gets or sets first second color
  14183. */
  14184. constructor(
  14185. /**
  14186. * Gets or sets the gradient value (between 0 and 1)
  14187. */
  14188. gradient: number,
  14189. /**
  14190. * Gets or sets first associated color
  14191. */
  14192. color1: Color4,
  14193. /**
  14194. * Gets or sets second associated color
  14195. */
  14196. color2?: Color4 | undefined);
  14197. /**
  14198. * Will get a color picked randomly between color1 and color2.
  14199. * If color2 is undefined then color1 will be used
  14200. * @param result defines the target Color4 to store the result in
  14201. */
  14202. getColorToRef(result: Color4): void;
  14203. }
  14204. /** Class used to store color 3 gradient */
  14205. export class Color3Gradient implements IValueGradient {
  14206. /**
  14207. * Gets or sets the gradient value (between 0 and 1)
  14208. */
  14209. gradient: number;
  14210. /**
  14211. * Gets or sets the associated color
  14212. */
  14213. color: Color3;
  14214. /**
  14215. * Creates a new color3 gradient
  14216. * @param gradient gets or sets the gradient value (between 0 and 1)
  14217. * @param color gets or sets associated color
  14218. */
  14219. constructor(
  14220. /**
  14221. * Gets or sets the gradient value (between 0 and 1)
  14222. */
  14223. gradient: number,
  14224. /**
  14225. * Gets or sets the associated color
  14226. */
  14227. color: Color3);
  14228. }
  14229. /** Class used to store factor gradient */
  14230. export class FactorGradient implements IValueGradient {
  14231. /**
  14232. * Gets or sets the gradient value (between 0 and 1)
  14233. */
  14234. gradient: number;
  14235. /**
  14236. * Gets or sets first associated factor
  14237. */
  14238. factor1: number;
  14239. /**
  14240. * Gets or sets second associated factor
  14241. */
  14242. factor2?: number | undefined;
  14243. /**
  14244. * Creates a new factor gradient
  14245. * @param gradient gets or sets the gradient value (between 0 and 1)
  14246. * @param factor1 gets or sets first associated factor
  14247. * @param factor2 gets or sets second associated factor
  14248. */
  14249. constructor(
  14250. /**
  14251. * Gets or sets the gradient value (between 0 and 1)
  14252. */
  14253. gradient: number,
  14254. /**
  14255. * Gets or sets first associated factor
  14256. */
  14257. factor1: number,
  14258. /**
  14259. * Gets or sets second associated factor
  14260. */
  14261. factor2?: number | undefined);
  14262. /**
  14263. * Will get a number picked randomly between factor1 and factor2.
  14264. * If factor2 is undefined then factor1 will be used
  14265. * @returns the picked number
  14266. */
  14267. getFactor(): number;
  14268. }
  14269. /**
  14270. * Helper used to simplify some generic gradient tasks
  14271. */
  14272. export class GradientHelper {
  14273. /**
  14274. * Gets the current gradient from an array of IValueGradient
  14275. * @param ratio defines the current ratio to get
  14276. * @param gradients defines the array of IValueGradient
  14277. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  14278. */
  14279. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  14280. }
  14281. }
  14282. declare module BABYLON {
  14283. interface ThinEngine {
  14284. /**
  14285. * Creates a raw texture
  14286. * @param data defines the data to store in the texture
  14287. * @param width defines the width of the texture
  14288. * @param height defines the height of the texture
  14289. * @param format defines the format of the data
  14290. * @param generateMipMaps defines if the engine should generate the mip levels
  14291. * @param invertY defines if data must be stored with Y axis inverted
  14292. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  14293. * @param compression defines the compression used (null by default)
  14294. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14295. * @returns the raw texture inside an InternalTexture
  14296. */
  14297. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  14298. /**
  14299. * Update a raw texture
  14300. * @param texture defines the texture to update
  14301. * @param data defines the data to store in the texture
  14302. * @param format defines the format of the data
  14303. * @param invertY defines if data must be stored with Y axis inverted
  14304. */
  14305. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14306. /**
  14307. * Update a raw texture
  14308. * @param texture defines the texture to update
  14309. * @param data defines the data to store in the texture
  14310. * @param format defines the format of the data
  14311. * @param invertY defines if data must be stored with Y axis inverted
  14312. * @param compression defines the compression used (null by default)
  14313. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14314. */
  14315. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  14316. /**
  14317. * Creates a new raw cube texture
  14318. * @param data defines the array of data to use to create each face
  14319. * @param size defines the size of the textures
  14320. * @param format defines the format of the data
  14321. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14322. * @param generateMipMaps defines if the engine should generate the mip levels
  14323. * @param invertY defines if data must be stored with Y axis inverted
  14324. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14325. * @param compression defines the compression used (null by default)
  14326. * @returns the cube texture as an InternalTexture
  14327. */
  14328. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  14329. /**
  14330. * Update a raw cube texture
  14331. * @param texture defines the texture to udpdate
  14332. * @param data defines the data to store
  14333. * @param format defines the data format
  14334. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14335. * @param invertY defines if data must be stored with Y axis inverted
  14336. */
  14337. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  14338. /**
  14339. * Update a raw cube texture
  14340. * @param texture defines the texture to udpdate
  14341. * @param data defines the data to store
  14342. * @param format defines the data format
  14343. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14344. * @param invertY defines if data must be stored with Y axis inverted
  14345. * @param compression defines the compression used (null by default)
  14346. */
  14347. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  14348. /**
  14349. * Update a raw cube texture
  14350. * @param texture defines the texture to udpdate
  14351. * @param data defines the data to store
  14352. * @param format defines the data format
  14353. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  14354. * @param invertY defines if data must be stored with Y axis inverted
  14355. * @param compression defines the compression used (null by default)
  14356. * @param level defines which level of the texture to update
  14357. */
  14358. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  14359. /**
  14360. * Creates a new raw cube texture from a specified url
  14361. * @param url defines the url where the data is located
  14362. * @param scene defines the current scene
  14363. * @param size defines the size of the textures
  14364. * @param format defines the format of the data
  14365. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14366. * @param noMipmap defines if the engine should avoid generating the mip levels
  14367. * @param callback defines a callback used to extract texture data from loaded data
  14368. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14369. * @param onLoad defines a callback called when texture is loaded
  14370. * @param onError defines a callback called if there is an error
  14371. * @returns the cube texture as an InternalTexture
  14372. */
  14373. 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;
  14374. /**
  14375. * Creates a new raw cube texture from a specified url
  14376. * @param url defines the url where the data is located
  14377. * @param scene defines the current scene
  14378. * @param size defines the size of the textures
  14379. * @param format defines the format of the data
  14380. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  14381. * @param noMipmap defines if the engine should avoid generating the mip levels
  14382. * @param callback defines a callback used to extract texture data from loaded data
  14383. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  14384. * @param onLoad defines a callback called when texture is loaded
  14385. * @param onError defines a callback called if there is an error
  14386. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14387. * @param invertY defines if data must be stored with Y axis inverted
  14388. * @returns the cube texture as an InternalTexture
  14389. */
  14390. 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;
  14391. /**
  14392. * Creates a new raw 3D texture
  14393. * @param data defines the data used to create the texture
  14394. * @param width defines the width of the texture
  14395. * @param height defines the height of the texture
  14396. * @param depth defines the depth of the texture
  14397. * @param format defines the format of the texture
  14398. * @param generateMipMaps defines if the engine must generate mip levels
  14399. * @param invertY defines if data must be stored with Y axis inverted
  14400. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14401. * @param compression defines the compressed used (can be null)
  14402. * @param textureType defines the compressed used (can be null)
  14403. * @returns a new raw 3D texture (stored in an InternalTexture)
  14404. */
  14405. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14406. /**
  14407. * Update a raw 3D texture
  14408. * @param texture defines the texture to update
  14409. * @param data defines the data to store
  14410. * @param format defines the data format
  14411. * @param invertY defines if data must be stored with Y axis inverted
  14412. */
  14413. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14414. /**
  14415. * Update a raw 3D texture
  14416. * @param texture defines the texture to update
  14417. * @param data defines the data to store
  14418. * @param format defines the data format
  14419. * @param invertY defines if data must be stored with Y axis inverted
  14420. * @param compression defines the used compression (can be null)
  14421. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14422. */
  14423. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14424. /**
  14425. * Creates a new raw 2D array texture
  14426. * @param data defines the data used to create the texture
  14427. * @param width defines the width of the texture
  14428. * @param height defines the height of the texture
  14429. * @param depth defines the number of layers of the texture
  14430. * @param format defines the format of the texture
  14431. * @param generateMipMaps defines if the engine must generate mip levels
  14432. * @param invertY defines if data must be stored with Y axis inverted
  14433. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  14434. * @param compression defines the compressed used (can be null)
  14435. * @param textureType defines the compressed used (can be null)
  14436. * @returns a new raw 2D array texture (stored in an InternalTexture)
  14437. */
  14438. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  14439. /**
  14440. * Update a raw 2D array texture
  14441. * @param texture defines the texture to update
  14442. * @param data defines the data to store
  14443. * @param format defines the data format
  14444. * @param invertY defines if data must be stored with Y axis inverted
  14445. */
  14446. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  14447. /**
  14448. * Update a raw 2D array texture
  14449. * @param texture defines the texture to update
  14450. * @param data defines the data to store
  14451. * @param format defines the data format
  14452. * @param invertY defines if data must be stored with Y axis inverted
  14453. * @param compression defines the used compression (can be null)
  14454. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  14455. */
  14456. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  14457. }
  14458. }
  14459. declare module BABYLON {
  14460. /**
  14461. * Raw texture can help creating a texture directly from an array of data.
  14462. * This can be super useful if you either get the data from an uncompressed source or
  14463. * if you wish to create your texture pixel by pixel.
  14464. */
  14465. export class RawTexture extends Texture {
  14466. /**
  14467. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14468. */
  14469. format: number;
  14470. /**
  14471. * Instantiates a new RawTexture.
  14472. * Raw texture can help creating a texture directly from an array of data.
  14473. * This can be super useful if you either get the data from an uncompressed source or
  14474. * if you wish to create your texture pixel by pixel.
  14475. * @param data define the array of data to use to create the texture
  14476. * @param width define the width of the texture
  14477. * @param height define the height of the texture
  14478. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14479. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14480. * @param generateMipMaps define whether mip maps should be generated or not
  14481. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14482. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14483. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14484. */
  14485. constructor(data: ArrayBufferView, width: number, height: number,
  14486. /**
  14487. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  14488. */
  14489. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  14490. /**
  14491. * Updates the texture underlying data.
  14492. * @param data Define the new data of the texture
  14493. */
  14494. update(data: ArrayBufferView): void;
  14495. /**
  14496. * Creates a luminance texture from some data.
  14497. * @param data Define the texture data
  14498. * @param width Define the width of the texture
  14499. * @param height Define the height of the texture
  14500. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14501. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14502. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14503. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14504. * @returns the luminance texture
  14505. */
  14506. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14507. /**
  14508. * Creates a luminance alpha texture from some data.
  14509. * @param data Define the texture data
  14510. * @param width Define the width of the texture
  14511. * @param height Define the height of the texture
  14512. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14513. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14514. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14515. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14516. * @returns the luminance alpha texture
  14517. */
  14518. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14519. /**
  14520. * Creates an alpha texture from some data.
  14521. * @param data Define the texture data
  14522. * @param width Define the width of the texture
  14523. * @param height Define the height of the texture
  14524. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14525. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14526. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14527. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14528. * @returns the alpha texture
  14529. */
  14530. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  14531. /**
  14532. * Creates a RGB texture from some data.
  14533. * @param data Define the texture data
  14534. * @param width Define the width of the texture
  14535. * @param height Define the height of the texture
  14536. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14537. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14538. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14539. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14540. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14541. * @returns the RGB alpha texture
  14542. */
  14543. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14544. /**
  14545. * Creates a RGBA texture from some data.
  14546. * @param data Define the texture data
  14547. * @param width Define the width of the texture
  14548. * @param height Define the height of the texture
  14549. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14550. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14551. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14552. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14553. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14554. * @returns the RGBA texture
  14555. */
  14556. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14557. /**
  14558. * Creates a R texture from some data.
  14559. * @param data Define the texture data
  14560. * @param width Define the width of the texture
  14561. * @param height Define the height of the texture
  14562. * @param sceneOrEngine defines the scene or engine the texture will belong to
  14563. * @param generateMipMaps Define whether or not to create mip maps for the texture
  14564. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  14565. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  14566. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  14567. * @returns the R texture
  14568. */
  14569. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  14570. }
  14571. }
  14572. declare module BABYLON {
  14573. interface ThinEngine {
  14574. /**
  14575. * Update a dynamic index buffer
  14576. * @param indexBuffer defines the target index buffer
  14577. * @param indices defines the data to update
  14578. * @param offset defines the offset in the target index buffer where update should start
  14579. */
  14580. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  14581. /**
  14582. * Updates a dynamic vertex buffer.
  14583. * @param vertexBuffer the vertex buffer to update
  14584. * @param data the data used to update the vertex buffer
  14585. * @param byteOffset the byte offset of the data
  14586. * @param byteLength the byte length of the data
  14587. */
  14588. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  14589. }
  14590. }
  14591. declare module BABYLON {
  14592. interface AbstractScene {
  14593. /**
  14594. * The list of procedural textures added to the scene
  14595. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14596. */
  14597. proceduralTextures: Array<ProceduralTexture>;
  14598. }
  14599. /**
  14600. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14601. * in a given scene.
  14602. */
  14603. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14604. /**
  14605. * The component name helpfull to identify the component in the list of scene components.
  14606. */
  14607. readonly name: string;
  14608. /**
  14609. * The scene the component belongs to.
  14610. */
  14611. scene: Scene;
  14612. /**
  14613. * Creates a new instance of the component for the given scene
  14614. * @param scene Defines the scene to register the component in
  14615. */
  14616. constructor(scene: Scene);
  14617. /**
  14618. * Registers the component in a given scene
  14619. */
  14620. register(): void;
  14621. /**
  14622. * Rebuilds the elements related to this component in case of
  14623. * context lost for instance.
  14624. */
  14625. rebuild(): void;
  14626. /**
  14627. * Disposes the component and the associated ressources.
  14628. */
  14629. dispose(): void;
  14630. private _beforeClear;
  14631. }
  14632. }
  14633. declare module BABYLON {
  14634. interface ThinEngine {
  14635. /**
  14636. * Creates a new render target cube texture
  14637. * @param size defines the size of the texture
  14638. * @param options defines the options used to create the texture
  14639. * @returns a new render target cube texture stored in an InternalTexture
  14640. */
  14641. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14642. }
  14643. }
  14644. declare module BABYLON {
  14645. /** @hidden */
  14646. export var proceduralVertexShader: {
  14647. name: string;
  14648. shader: string;
  14649. };
  14650. }
  14651. declare module BABYLON {
  14652. /**
  14653. * 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.
  14654. * This is the base class of any Procedural texture and contains most of the shareable code.
  14655. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14656. */
  14657. export class ProceduralTexture extends Texture {
  14658. /**
  14659. * Define if the texture is enabled or not (disabled texture will not render)
  14660. */
  14661. isEnabled: boolean;
  14662. /**
  14663. * Define if the texture must be cleared before rendering (default is true)
  14664. */
  14665. autoClear: boolean;
  14666. /**
  14667. * Callback called when the texture is generated
  14668. */
  14669. onGenerated: () => void;
  14670. /**
  14671. * Event raised when the texture is generated
  14672. */
  14673. onGeneratedObservable: Observable<ProceduralTexture>;
  14674. /**
  14675. * Event raised before the texture is generated
  14676. */
  14677. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  14678. /**
  14679. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  14680. */
  14681. nodeMaterialSource: Nullable<NodeMaterial>;
  14682. /** @hidden */
  14683. _generateMipMaps: boolean;
  14684. /** @hidden **/
  14685. _effect: Effect;
  14686. /** @hidden */
  14687. _textures: {
  14688. [key: string]: Texture;
  14689. };
  14690. /** @hidden */
  14691. protected _fallbackTexture: Nullable<Texture>;
  14692. private _size;
  14693. private _textureType;
  14694. private _currentRefreshId;
  14695. private _frameId;
  14696. private _refreshRate;
  14697. private _vertexBuffers;
  14698. private _indexBuffer;
  14699. private _uniforms;
  14700. private _samplers;
  14701. private _fragment;
  14702. private _floats;
  14703. private _ints;
  14704. private _floatsArrays;
  14705. private _colors3;
  14706. private _colors4;
  14707. private _vectors2;
  14708. private _vectors3;
  14709. private _matrices;
  14710. private _fallbackTextureUsed;
  14711. private _fullEngine;
  14712. private _cachedDefines;
  14713. private _contentUpdateId;
  14714. private _contentData;
  14715. /**
  14716. * Instantiates a new procedural texture.
  14717. * 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.
  14718. * This is the base class of any Procedural texture and contains most of the shareable code.
  14719. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14720. * @param name Define the name of the texture
  14721. * @param size Define the size of the texture to create
  14722. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14723. * @param scene Define the scene the texture belongs to
  14724. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14725. * @param generateMipMaps Define if the texture should creates mip maps or not
  14726. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14727. * @param textureType The FBO internal texture type
  14728. */
  14729. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  14730. /**
  14731. * The effect that is created when initializing the post process.
  14732. * @returns The created effect corresponding the the postprocess.
  14733. */
  14734. getEffect(): Effect;
  14735. /**
  14736. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14737. * @returns an ArrayBufferView promise (Uint8Array or Float32Array)
  14738. */
  14739. getContent(): Nullable<Promise<ArrayBufferView>>;
  14740. private _createIndexBuffer;
  14741. /** @hidden */
  14742. _rebuild(): void;
  14743. /**
  14744. * Resets the texture in order to recreate its associated resources.
  14745. * This can be called in case of context loss
  14746. */
  14747. reset(): void;
  14748. protected _getDefines(): string;
  14749. /**
  14750. * Is the texture ready to be used ? (rendered at least once)
  14751. * @returns true if ready, otherwise, false.
  14752. */
  14753. isReady(): boolean;
  14754. /**
  14755. * Resets the refresh counter of the texture and start bak from scratch.
  14756. * Could be useful to regenerate the texture if it is setup to render only once.
  14757. */
  14758. resetRefreshCounter(): void;
  14759. /**
  14760. * Set the fragment shader to use in order to render the texture.
  14761. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14762. */
  14763. setFragment(fragment: any): void;
  14764. /**
  14765. * Define the refresh rate of the texture or the rendering frequency.
  14766. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14767. */
  14768. get refreshRate(): number;
  14769. set refreshRate(value: number);
  14770. /** @hidden */
  14771. _shouldRender(): boolean;
  14772. /**
  14773. * Get the size the texture is rendering at.
  14774. * @returns the size (on cube texture it is always squared)
  14775. */
  14776. getRenderSize(): RenderTargetTextureSize;
  14777. /**
  14778. * Resize the texture to new value.
  14779. * @param size Define the new size the texture should have
  14780. * @param generateMipMaps Define whether the new texture should create mip maps
  14781. */
  14782. resize(size: number, generateMipMaps: boolean): void;
  14783. private _checkUniform;
  14784. /**
  14785. * Set a texture in the shader program used to render.
  14786. * @param name Define the name of the uniform samplers as defined in the shader
  14787. * @param texture Define the texture to bind to this sampler
  14788. * @return the texture itself allowing "fluent" like uniform updates
  14789. */
  14790. setTexture(name: string, texture: Texture): ProceduralTexture;
  14791. /**
  14792. * Set a float in the shader.
  14793. * @param name Define the name of the uniform as defined in the shader
  14794. * @param value Define the value to give to the uniform
  14795. * @return the texture itself allowing "fluent" like uniform updates
  14796. */
  14797. setFloat(name: string, value: number): ProceduralTexture;
  14798. /**
  14799. * Set a int in the shader.
  14800. * @param name Define the name of the uniform as defined in the shader
  14801. * @param value Define the value to give to the uniform
  14802. * @return the texture itself allowing "fluent" like uniform updates
  14803. */
  14804. setInt(name: string, value: number): ProceduralTexture;
  14805. /**
  14806. * Set an array of floats in the shader.
  14807. * @param name Define the name of the uniform as defined in the shader
  14808. * @param value Define the value to give to the uniform
  14809. * @return the texture itself allowing "fluent" like uniform updates
  14810. */
  14811. setFloats(name: string, value: number[]): ProceduralTexture;
  14812. /**
  14813. * Set a vec3 in the shader from a Color3.
  14814. * @param name Define the name of the uniform as defined in the shader
  14815. * @param value Define the value to give to the uniform
  14816. * @return the texture itself allowing "fluent" like uniform updates
  14817. */
  14818. setColor3(name: string, value: Color3): ProceduralTexture;
  14819. /**
  14820. * Set a vec4 in the shader from a Color4.
  14821. * @param name Define the name of the uniform as defined in the shader
  14822. * @param value Define the value to give to the uniform
  14823. * @return the texture itself allowing "fluent" like uniform updates
  14824. */
  14825. setColor4(name: string, value: Color4): ProceduralTexture;
  14826. /**
  14827. * Set a vec2 in the shader from a Vector2.
  14828. * @param name Define the name of the uniform as defined in the shader
  14829. * @param value Define the value to give to the uniform
  14830. * @return the texture itself allowing "fluent" like uniform updates
  14831. */
  14832. setVector2(name: string, value: Vector2): ProceduralTexture;
  14833. /**
  14834. * Set a vec3 in the shader from a Vector3.
  14835. * @param name Define the name of the uniform as defined in the shader
  14836. * @param value Define the value to give to the uniform
  14837. * @return the texture itself allowing "fluent" like uniform updates
  14838. */
  14839. setVector3(name: string, value: Vector3): ProceduralTexture;
  14840. /**
  14841. * Set a mat4 in the shader from a MAtrix.
  14842. * @param name Define the name of the uniform as defined in the shader
  14843. * @param value Define the value to give to the uniform
  14844. * @return the texture itself allowing "fluent" like uniform updates
  14845. */
  14846. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14847. /**
  14848. * Render the texture to its associated render target.
  14849. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14850. */
  14851. render(useCameraPostProcess?: boolean): void;
  14852. /**
  14853. * Clone the texture.
  14854. * @returns the cloned texture
  14855. */
  14856. clone(): ProceduralTexture;
  14857. /**
  14858. * Dispose the texture and release its asoociated resources.
  14859. */
  14860. dispose(): void;
  14861. }
  14862. }
  14863. declare module BABYLON {
  14864. /**
  14865. * This represents the base class for particle system in Babylon.
  14866. * 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.
  14867. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14868. * @example https://doc.babylonjs.com/babylon101/particles
  14869. */
  14870. export class BaseParticleSystem {
  14871. /**
  14872. * Source color is added to the destination color without alpha affecting the result
  14873. */
  14874. static BLENDMODE_ONEONE: number;
  14875. /**
  14876. * Blend current color and particle color using particle’s alpha
  14877. */
  14878. static BLENDMODE_STANDARD: number;
  14879. /**
  14880. * Add current color and particle color multiplied by particle’s alpha
  14881. */
  14882. static BLENDMODE_ADD: number;
  14883. /**
  14884. * Multiply current color with particle color
  14885. */
  14886. static BLENDMODE_MULTIPLY: number;
  14887. /**
  14888. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14889. */
  14890. static BLENDMODE_MULTIPLYADD: number;
  14891. /**
  14892. * List of animations used by the particle system.
  14893. */
  14894. animations: Animation[];
  14895. /**
  14896. * Gets or sets the unique id of the particle system
  14897. */
  14898. uniqueId: number;
  14899. /**
  14900. * The id of the Particle system.
  14901. */
  14902. id: string;
  14903. /**
  14904. * The friendly name of the Particle system.
  14905. */
  14906. name: string;
  14907. /**
  14908. * Snippet ID if the particle system was created from the snippet server
  14909. */
  14910. snippetId: string;
  14911. /**
  14912. * The rendering group used by the Particle system to chose when to render.
  14913. */
  14914. renderingGroupId: number;
  14915. /**
  14916. * The emitter represents the Mesh or position we are attaching the particle system to.
  14917. */
  14918. emitter: Nullable<AbstractMesh | Vector3>;
  14919. /**
  14920. * The maximum number of particles to emit per frame
  14921. */
  14922. emitRate: number;
  14923. /**
  14924. * If you want to launch only a few particles at once, that can be done, as well.
  14925. */
  14926. manualEmitCount: number;
  14927. /**
  14928. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14929. */
  14930. updateSpeed: number;
  14931. /**
  14932. * The amount of time the particle system is running (depends of the overall update speed).
  14933. */
  14934. targetStopDuration: number;
  14935. /**
  14936. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14937. */
  14938. disposeOnStop: boolean;
  14939. /**
  14940. * Minimum power of emitting particles.
  14941. */
  14942. minEmitPower: number;
  14943. /**
  14944. * Maximum power of emitting particles.
  14945. */
  14946. maxEmitPower: number;
  14947. /**
  14948. * Minimum life time of emitting particles.
  14949. */
  14950. minLifeTime: number;
  14951. /**
  14952. * Maximum life time of emitting particles.
  14953. */
  14954. maxLifeTime: number;
  14955. /**
  14956. * Minimum Size of emitting particles.
  14957. */
  14958. minSize: number;
  14959. /**
  14960. * Maximum Size of emitting particles.
  14961. */
  14962. maxSize: number;
  14963. /**
  14964. * Minimum scale of emitting particles on X axis.
  14965. */
  14966. minScaleX: number;
  14967. /**
  14968. * Maximum scale of emitting particles on X axis.
  14969. */
  14970. maxScaleX: number;
  14971. /**
  14972. * Minimum scale of emitting particles on Y axis.
  14973. */
  14974. minScaleY: number;
  14975. /**
  14976. * Maximum scale of emitting particles on Y axis.
  14977. */
  14978. maxScaleY: number;
  14979. /**
  14980. * Gets or sets the minimal initial rotation in radians.
  14981. */
  14982. minInitialRotation: number;
  14983. /**
  14984. * Gets or sets the maximal initial rotation in radians.
  14985. */
  14986. maxInitialRotation: number;
  14987. /**
  14988. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14989. */
  14990. minAngularSpeed: number;
  14991. /**
  14992. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14993. */
  14994. maxAngularSpeed: number;
  14995. /**
  14996. * The texture used to render each particle. (this can be a spritesheet)
  14997. */
  14998. particleTexture: Nullable<BaseTexture>;
  14999. /**
  15000. * The layer mask we are rendering the particles through.
  15001. */
  15002. layerMask: number;
  15003. /**
  15004. * This can help using your own shader to render the particle system.
  15005. * The according effect will be created
  15006. */
  15007. customShader: any;
  15008. /**
  15009. * By default particle system starts as soon as they are created. This prevents the
  15010. * automatic start to happen and let you decide when to start emitting particles.
  15011. */
  15012. preventAutoStart: boolean;
  15013. private _noiseTexture;
  15014. /**
  15015. * Gets or sets a texture used to add random noise to particle positions
  15016. */
  15017. get noiseTexture(): Nullable<ProceduralTexture>;
  15018. set noiseTexture(value: Nullable<ProceduralTexture>);
  15019. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15020. noiseStrength: Vector3;
  15021. /**
  15022. * Callback triggered when the particle animation is ending.
  15023. */
  15024. onAnimationEnd: Nullable<() => void>;
  15025. /**
  15026. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  15027. */
  15028. blendMode: number;
  15029. /**
  15030. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  15031. * to override the particles.
  15032. */
  15033. forceDepthWrite: boolean;
  15034. /** 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 */
  15035. preWarmCycles: number;
  15036. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  15037. preWarmStepOffset: number;
  15038. /**
  15039. * 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)
  15040. */
  15041. spriteCellChangeSpeed: number;
  15042. /**
  15043. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15044. */
  15045. startSpriteCellID: number;
  15046. /**
  15047. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15048. */
  15049. endSpriteCellID: number;
  15050. /**
  15051. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15052. */
  15053. spriteCellWidth: number;
  15054. /**
  15055. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15056. */
  15057. spriteCellHeight: number;
  15058. /**
  15059. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15060. */
  15061. spriteRandomStartCell: boolean;
  15062. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15063. translationPivot: Vector2;
  15064. /** @hidden */
  15065. protected _isAnimationSheetEnabled: boolean;
  15066. /**
  15067. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15068. */
  15069. beginAnimationOnStart: boolean;
  15070. /**
  15071. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15072. */
  15073. beginAnimationFrom: number;
  15074. /**
  15075. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15076. */
  15077. beginAnimationTo: number;
  15078. /**
  15079. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15080. */
  15081. beginAnimationLoop: boolean;
  15082. /**
  15083. * Gets or sets a world offset applied to all particles
  15084. */
  15085. worldOffset: Vector3;
  15086. /**
  15087. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  15088. */
  15089. get isAnimationSheetEnabled(): boolean;
  15090. set isAnimationSheetEnabled(value: boolean);
  15091. /**
  15092. * Get hosting scene
  15093. * @returns the scene
  15094. */
  15095. getScene(): Nullable<Scene>;
  15096. /**
  15097. * You can use gravity if you want to give an orientation to your particles.
  15098. */
  15099. gravity: Vector3;
  15100. protected _colorGradients: Nullable<Array<ColorGradient>>;
  15101. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  15102. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  15103. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  15104. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  15105. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  15106. protected _dragGradients: Nullable<Array<FactorGradient>>;
  15107. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  15108. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  15109. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  15110. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  15111. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  15112. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  15113. /**
  15114. * Defines the delay in milliseconds before starting the system (0 by default)
  15115. */
  15116. startDelay: number;
  15117. /**
  15118. * Gets the current list of drag gradients.
  15119. * You must use addDragGradient and removeDragGradient to udpate this list
  15120. * @returns the list of drag gradients
  15121. */
  15122. getDragGradients(): Nullable<Array<FactorGradient>>;
  15123. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15124. limitVelocityDamping: number;
  15125. /**
  15126. * Gets the current list of limit velocity gradients.
  15127. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  15128. * @returns the list of limit velocity gradients
  15129. */
  15130. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  15131. /**
  15132. * Gets the current list of color gradients.
  15133. * You must use addColorGradient and removeColorGradient to udpate this list
  15134. * @returns the list of color gradients
  15135. */
  15136. getColorGradients(): Nullable<Array<ColorGradient>>;
  15137. /**
  15138. * Gets the current list of size gradients.
  15139. * You must use addSizeGradient and removeSizeGradient to udpate this list
  15140. * @returns the list of size gradients
  15141. */
  15142. getSizeGradients(): Nullable<Array<FactorGradient>>;
  15143. /**
  15144. * Gets the current list of color remap gradients.
  15145. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15146. * @returns the list of color remap gradients
  15147. */
  15148. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15149. /**
  15150. * Gets the current list of alpha remap gradients.
  15151. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15152. * @returns the list of alpha remap gradients
  15153. */
  15154. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15155. /**
  15156. * Gets the current list of life time gradients.
  15157. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  15158. * @returns the list of life time gradients
  15159. */
  15160. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  15161. /**
  15162. * Gets the current list of angular speed gradients.
  15163. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  15164. * @returns the list of angular speed gradients
  15165. */
  15166. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  15167. /**
  15168. * Gets the current list of velocity gradients.
  15169. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  15170. * @returns the list of velocity gradients
  15171. */
  15172. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  15173. /**
  15174. * Gets the current list of start size gradients.
  15175. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  15176. * @returns the list of start size gradients
  15177. */
  15178. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  15179. /**
  15180. * Gets the current list of emit rate gradients.
  15181. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  15182. * @returns the list of emit rate gradients
  15183. */
  15184. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  15185. /**
  15186. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15187. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15188. */
  15189. get direction1(): Vector3;
  15190. set direction1(value: Vector3);
  15191. /**
  15192. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15193. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15194. */
  15195. get direction2(): Vector3;
  15196. set direction2(value: Vector3);
  15197. /**
  15198. * 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.
  15199. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15200. */
  15201. get minEmitBox(): Vector3;
  15202. set minEmitBox(value: Vector3);
  15203. /**
  15204. * 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.
  15205. * This only works when particleEmitterTyps is a BoxParticleEmitter
  15206. */
  15207. get maxEmitBox(): Vector3;
  15208. set maxEmitBox(value: Vector3);
  15209. /**
  15210. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15211. */
  15212. color1: Color4;
  15213. /**
  15214. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  15215. */
  15216. color2: Color4;
  15217. /**
  15218. * Color the particle will have at the end of its lifetime
  15219. */
  15220. colorDead: Color4;
  15221. /**
  15222. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  15223. */
  15224. textureMask: Color4;
  15225. /**
  15226. * The particle emitter type defines the emitter used by the particle system.
  15227. * It can be for example box, sphere, or cone...
  15228. */
  15229. particleEmitterType: IParticleEmitterType;
  15230. /** @hidden */
  15231. _isSubEmitter: boolean;
  15232. /**
  15233. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15234. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15235. */
  15236. billboardMode: number;
  15237. protected _isBillboardBased: boolean;
  15238. /**
  15239. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15240. */
  15241. get isBillboardBased(): boolean;
  15242. set isBillboardBased(value: boolean);
  15243. /**
  15244. * The scene the particle system belongs to.
  15245. */
  15246. protected _scene: Nullable<Scene>;
  15247. /**
  15248. * The engine the particle system belongs to.
  15249. */
  15250. protected _engine: ThinEngine;
  15251. /**
  15252. * Local cache of defines for image processing.
  15253. */
  15254. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  15255. /**
  15256. * Default configuration related to image processing available in the standard Material.
  15257. */
  15258. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  15259. /**
  15260. * Gets the image processing configuration used either in this material.
  15261. */
  15262. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  15263. /**
  15264. * Sets the Default image processing configuration used either in the this material.
  15265. *
  15266. * If sets to null, the scene one is in use.
  15267. */
  15268. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  15269. /**
  15270. * Attaches a new image processing configuration to the Standard Material.
  15271. * @param configuration
  15272. */
  15273. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  15274. /** @hidden */
  15275. protected _reset(): void;
  15276. /** @hidden */
  15277. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  15278. /**
  15279. * Instantiates a particle system.
  15280. * 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.
  15281. * @param name The name of the particle system
  15282. */
  15283. constructor(name: string);
  15284. /**
  15285. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15286. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15287. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15288. * @returns the emitter
  15289. */
  15290. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15291. /**
  15292. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15293. * @param radius The radius of the hemisphere to emit from
  15294. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15295. * @returns the emitter
  15296. */
  15297. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  15298. /**
  15299. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15300. * @param radius The radius of the sphere to emit from
  15301. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15302. * @returns the emitter
  15303. */
  15304. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15305. /**
  15306. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15307. * @param radius The radius of the sphere to emit from
  15308. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15309. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15310. * @returns the emitter
  15311. */
  15312. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15313. /**
  15314. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15315. * @param radius The radius of the emission cylinder
  15316. * @param height The height of the emission cylinder
  15317. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15318. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15319. * @returns the emitter
  15320. */
  15321. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15322. /**
  15323. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15324. * @param radius The radius of the cylinder to emit from
  15325. * @param height The height of the emission cylinder
  15326. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15327. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15328. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15329. * @returns the emitter
  15330. */
  15331. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15332. /**
  15333. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15334. * @param radius The radius of the cone to emit from
  15335. * @param angle The base angle of the cone
  15336. * @returns the emitter
  15337. */
  15338. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15339. /**
  15340. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15343. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15344. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15345. * @returns the emitter
  15346. */
  15347. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15348. }
  15349. }
  15350. declare module BABYLON {
  15351. /**
  15352. * Type of sub emitter
  15353. */
  15354. export enum SubEmitterType {
  15355. /**
  15356. * Attached to the particle over it's lifetime
  15357. */
  15358. ATTACHED = 0,
  15359. /**
  15360. * Created when the particle dies
  15361. */
  15362. END = 1
  15363. }
  15364. /**
  15365. * Sub emitter class used to emit particles from an existing particle
  15366. */
  15367. export class SubEmitter {
  15368. /**
  15369. * the particle system to be used by the sub emitter
  15370. */
  15371. particleSystem: ParticleSystem;
  15372. /**
  15373. * Type of the submitter (Default: END)
  15374. */
  15375. type: SubEmitterType;
  15376. /**
  15377. * 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)
  15378. * Note: This only is supported when using an emitter of type Mesh
  15379. */
  15380. inheritDirection: boolean;
  15381. /**
  15382. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15383. */
  15384. inheritedVelocityAmount: number;
  15385. /**
  15386. * Creates a sub emitter
  15387. * @param particleSystem the particle system to be used by the sub emitter
  15388. */
  15389. constructor(
  15390. /**
  15391. * the particle system to be used by the sub emitter
  15392. */
  15393. particleSystem: ParticleSystem);
  15394. /**
  15395. * Clones the sub emitter
  15396. * @returns the cloned sub emitter
  15397. */
  15398. clone(): SubEmitter;
  15399. /**
  15400. * Serialize current object to a JSON object
  15401. * @returns the serialized object
  15402. */
  15403. serialize(): any;
  15404. /** @hidden */
  15405. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  15406. /**
  15407. * Creates a new SubEmitter from a serialized JSON version
  15408. * @param serializationObject defines the JSON object to read from
  15409. * @param sceneOrEngine defines the hosting scene or the hosting engine
  15410. * @param rootUrl defines the rootUrl for data loading
  15411. * @returns a new SubEmitter
  15412. */
  15413. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  15414. /** Release associated resources */
  15415. dispose(): void;
  15416. }
  15417. }
  15418. declare module BABYLON {
  15419. /** @hidden */
  15420. export var clipPlaneFragmentDeclaration: {
  15421. name: string;
  15422. shader: string;
  15423. };
  15424. }
  15425. declare module BABYLON {
  15426. /** @hidden */
  15427. export var imageProcessingDeclaration: {
  15428. name: string;
  15429. shader: string;
  15430. };
  15431. }
  15432. declare module BABYLON {
  15433. /** @hidden */
  15434. export var imageProcessingFunctions: {
  15435. name: string;
  15436. shader: string;
  15437. };
  15438. }
  15439. declare module BABYLON {
  15440. /** @hidden */
  15441. export var clipPlaneFragment: {
  15442. name: string;
  15443. shader: string;
  15444. };
  15445. }
  15446. declare module BABYLON {
  15447. /** @hidden */
  15448. export var particlesPixelShader: {
  15449. name: string;
  15450. shader: string;
  15451. };
  15452. }
  15453. declare module BABYLON {
  15454. /** @hidden */
  15455. export var clipPlaneVertexDeclaration: {
  15456. name: string;
  15457. shader: string;
  15458. };
  15459. }
  15460. declare module BABYLON {
  15461. /** @hidden */
  15462. export var clipPlaneVertex: {
  15463. name: string;
  15464. shader: string;
  15465. };
  15466. }
  15467. declare module BABYLON {
  15468. /** @hidden */
  15469. export var particlesVertexShader: {
  15470. name: string;
  15471. shader: string;
  15472. };
  15473. }
  15474. declare module BABYLON {
  15475. /**
  15476. * Interface used to define entities containing multiple clip planes
  15477. */
  15478. export interface IClipPlanesHolder {
  15479. /**
  15480. * Gets or sets the active clipplane 1
  15481. */
  15482. clipPlane: Nullable<Plane>;
  15483. /**
  15484. * Gets or sets the active clipplane 2
  15485. */
  15486. clipPlane2: Nullable<Plane>;
  15487. /**
  15488. * Gets or sets the active clipplane 3
  15489. */
  15490. clipPlane3: Nullable<Plane>;
  15491. /**
  15492. * Gets or sets the active clipplane 4
  15493. */
  15494. clipPlane4: Nullable<Plane>;
  15495. /**
  15496. * Gets or sets the active clipplane 5
  15497. */
  15498. clipPlane5: Nullable<Plane>;
  15499. /**
  15500. * Gets or sets the active clipplane 6
  15501. */
  15502. clipPlane6: Nullable<Plane>;
  15503. }
  15504. }
  15505. declare module BABYLON {
  15506. /**
  15507. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  15508. *
  15509. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  15510. *
  15511. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  15512. */
  15513. export class ThinMaterialHelper {
  15514. /**
  15515. * Binds the clip plane information from the holder to the effect.
  15516. * @param effect The effect we are binding the data to
  15517. * @param holder The entity containing the clip plane information
  15518. */
  15519. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  15520. }
  15521. }
  15522. declare module BABYLON {
  15523. interface ThinEngine {
  15524. /**
  15525. * Sets alpha constants used by some alpha blending modes
  15526. * @param r defines the red component
  15527. * @param g defines the green component
  15528. * @param b defines the blue component
  15529. * @param a defines the alpha component
  15530. */
  15531. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  15532. /**
  15533. * Sets the current alpha mode
  15534. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  15535. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  15536. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15537. */
  15538. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  15539. /**
  15540. * Gets the current alpha mode
  15541. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  15542. * @returns the current alpha mode
  15543. */
  15544. getAlphaMode(): number;
  15545. /**
  15546. * Sets the current alpha equation
  15547. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  15548. */
  15549. setAlphaEquation(equation: number): void;
  15550. /**
  15551. * Gets the current alpha equation.
  15552. * @returns the current alpha equation
  15553. */
  15554. getAlphaEquation(): number;
  15555. }
  15556. }
  15557. declare module BABYLON {
  15558. /**
  15559. * This represents a particle system in Babylon.
  15560. * 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.
  15561. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15562. * @example https://doc.babylonjs.com/babylon101/particles
  15563. */
  15564. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15565. /**
  15566. * Billboard mode will only apply to Y axis
  15567. */
  15568. static readonly BILLBOARDMODE_Y: number;
  15569. /**
  15570. * Billboard mode will apply to all axes
  15571. */
  15572. static readonly BILLBOARDMODE_ALL: number;
  15573. /**
  15574. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15575. */
  15576. static readonly BILLBOARDMODE_STRETCHED: number;
  15577. /**
  15578. * This function can be defined to provide custom update for active particles.
  15579. * This function will be called instead of regular update (age, position, color, etc.).
  15580. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15581. */
  15582. updateFunction: (particles: Particle[]) => void;
  15583. private _emitterWorldMatrix;
  15584. /**
  15585. * This function can be defined to specify initial direction for every new particle.
  15586. * It by default use the emitterType defined function
  15587. */
  15588. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15589. /**
  15590. * This function can be defined to specify initial position for every new particle.
  15591. * It by default use the emitterType defined function
  15592. */
  15593. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  15594. /**
  15595. * @hidden
  15596. */
  15597. _inheritedVelocityOffset: Vector3;
  15598. /**
  15599. * An event triggered when the system is disposed
  15600. */
  15601. onDisposeObservable: Observable<IParticleSystem>;
  15602. /**
  15603. * An event triggered when the system is stopped
  15604. */
  15605. onStoppedObservable: Observable<IParticleSystem>;
  15606. private _onDisposeObserver;
  15607. /**
  15608. * Sets a callback that will be triggered when the system is disposed
  15609. */
  15610. set onDispose(callback: () => void);
  15611. private _particles;
  15612. private _epsilon;
  15613. private _capacity;
  15614. private _stockParticles;
  15615. private _newPartsExcess;
  15616. private _vertexData;
  15617. private _vertexBuffer;
  15618. private _vertexBuffers;
  15619. private _spriteBuffer;
  15620. private _indexBuffer;
  15621. private _effect;
  15622. private _customEffect;
  15623. private _cachedDefines;
  15624. private _scaledColorStep;
  15625. private _colorDiff;
  15626. private _scaledDirection;
  15627. private _scaledGravity;
  15628. private _currentRenderId;
  15629. private _alive;
  15630. private _useInstancing;
  15631. private _vertexArrayObject;
  15632. private _started;
  15633. private _stopped;
  15634. private _actualFrame;
  15635. private _scaledUpdateSpeed;
  15636. private _vertexBufferSize;
  15637. /** @hidden */
  15638. _currentEmitRateGradient: Nullable<FactorGradient>;
  15639. /** @hidden */
  15640. _currentEmitRate1: number;
  15641. /** @hidden */
  15642. _currentEmitRate2: number;
  15643. /** @hidden */
  15644. _currentStartSizeGradient: Nullable<FactorGradient>;
  15645. /** @hidden */
  15646. _currentStartSize1: number;
  15647. /** @hidden */
  15648. _currentStartSize2: number;
  15649. private readonly _rawTextureWidth;
  15650. private _rampGradientsTexture;
  15651. private _useRampGradients;
  15652. /** Gets or sets a matrix to use to compute projection */
  15653. defaultProjectionMatrix: Matrix;
  15654. /** Gets or sets a matrix to use to compute view */
  15655. defaultViewMatrix: Matrix;
  15656. /** Gets or sets a boolean indicating that ramp gradients must be used
  15657. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15658. */
  15659. get useRampGradients(): boolean;
  15660. set useRampGradients(value: boolean);
  15661. /**
  15662. * 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.
  15663. * 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: [])
  15664. */
  15665. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15666. private _subEmitters;
  15667. /**
  15668. * @hidden
  15669. * If the particle systems emitter should be disposed when the particle system is disposed
  15670. */
  15671. _disposeEmitterOnDispose: boolean;
  15672. /**
  15673. * The current active Sub-systems, this property is used by the root particle system only.
  15674. */
  15675. activeSubSystems: Array<ParticleSystem>;
  15676. /**
  15677. * Specifies if the particles are updated in emitter local space or world space
  15678. */
  15679. isLocal: boolean;
  15680. private _rootParticleSystem;
  15681. /**
  15682. * Gets the current list of active particles
  15683. */
  15684. get particles(): Particle[];
  15685. /**
  15686. * Gets the number of particles active at the same time.
  15687. * @returns The number of active particles.
  15688. */
  15689. getActiveCount(): number;
  15690. /**
  15691. * Returns the string "ParticleSystem"
  15692. * @returns a string containing the class name
  15693. */
  15694. getClassName(): string;
  15695. /**
  15696. * Gets a boolean indicating that the system is stopping
  15697. * @returns true if the system is currently stopping
  15698. */
  15699. isStopping(): boolean;
  15700. /**
  15701. * Gets the custom effect used to render the particles
  15702. * @param blendMode Blend mode for which the effect should be retrieved
  15703. * @returns The effect
  15704. */
  15705. getCustomEffect(blendMode?: number): Nullable<Effect>;
  15706. /**
  15707. * Sets the custom effect used to render the particles
  15708. * @param effect The effect to set
  15709. * @param blendMode Blend mode for which the effect should be set
  15710. */
  15711. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  15712. /** @hidden */
  15713. private _onBeforeDrawParticlesObservable;
  15714. /**
  15715. * Observable that will be called just before the particles are drawn
  15716. */
  15717. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  15718. /**
  15719. * Gets the name of the particle vertex shader
  15720. */
  15721. get vertexShaderName(): string;
  15722. /**
  15723. * Instantiates a particle system.
  15724. * 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.
  15725. * @param name The name of the particle system
  15726. * @param capacity The max number of particles alive at the same time
  15727. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  15728. * @param customEffect a custom effect used to change the way particles are rendered by default
  15729. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15730. * @param epsilon Offset used to render the particles
  15731. */
  15732. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15733. private _addFactorGradient;
  15734. private _removeFactorGradient;
  15735. /**
  15736. * Adds a new life time gradient
  15737. * @param gradient defines the gradient to use (between 0 and 1)
  15738. * @param factor defines the life time factor to affect to the specified gradient
  15739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15740. * @returns the current particle system
  15741. */
  15742. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15743. /**
  15744. * Remove a specific life time gradient
  15745. * @param gradient defines the gradient to remove
  15746. * @returns the current particle system
  15747. */
  15748. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15749. /**
  15750. * Adds a new size gradient
  15751. * @param gradient defines the gradient to use (between 0 and 1)
  15752. * @param factor defines the size factor to affect to the specified gradient
  15753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15754. * @returns the current particle system
  15755. */
  15756. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15757. /**
  15758. * Remove a specific size gradient
  15759. * @param gradient defines the gradient to remove
  15760. * @returns the current particle system
  15761. */
  15762. removeSizeGradient(gradient: number): IParticleSystem;
  15763. /**
  15764. * Adds a new color remap gradient
  15765. * @param gradient defines the gradient to use (between 0 and 1)
  15766. * @param min defines the color remap minimal range
  15767. * @param max defines the color remap maximal range
  15768. * @returns the current particle system
  15769. */
  15770. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15771. /**
  15772. * Remove a specific color remap gradient
  15773. * @param gradient defines the gradient to remove
  15774. * @returns the current particle system
  15775. */
  15776. removeColorRemapGradient(gradient: number): IParticleSystem;
  15777. /**
  15778. * Adds a new alpha remap gradient
  15779. * @param gradient defines the gradient to use (between 0 and 1)
  15780. * @param min defines the alpha remap minimal range
  15781. * @param max defines the alpha remap maximal range
  15782. * @returns the current particle system
  15783. */
  15784. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15785. /**
  15786. * Remove a specific alpha remap gradient
  15787. * @param gradient defines the gradient to remove
  15788. * @returns the current particle system
  15789. */
  15790. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15791. /**
  15792. * Adds a new angular speed gradient
  15793. * @param gradient defines the gradient to use (between 0 and 1)
  15794. * @param factor defines the angular speed to affect to the specified gradient
  15795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15796. * @returns the current particle system
  15797. */
  15798. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15799. /**
  15800. * Remove a specific angular speed gradient
  15801. * @param gradient defines the gradient to remove
  15802. * @returns the current particle system
  15803. */
  15804. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15805. /**
  15806. * Adds a new velocity gradient
  15807. * @param gradient defines the gradient to use (between 0 and 1)
  15808. * @param factor defines the velocity to affect to the specified gradient
  15809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15810. * @returns the current particle system
  15811. */
  15812. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15813. /**
  15814. * Remove a specific velocity gradient
  15815. * @param gradient defines the gradient to remove
  15816. * @returns the current particle system
  15817. */
  15818. removeVelocityGradient(gradient: number): IParticleSystem;
  15819. /**
  15820. * Adds a new limit velocity gradient
  15821. * @param gradient defines the gradient to use (between 0 and 1)
  15822. * @param factor defines the limit velocity value to affect to the specified gradient
  15823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15824. * @returns the current particle system
  15825. */
  15826. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15827. /**
  15828. * Remove a specific limit velocity gradient
  15829. * @param gradient defines the gradient to remove
  15830. * @returns the current particle system
  15831. */
  15832. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15833. /**
  15834. * Adds a new drag gradient
  15835. * @param gradient defines the gradient to use (between 0 and 1)
  15836. * @param factor defines the drag value to affect to the specified gradient
  15837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15838. * @returns the current particle system
  15839. */
  15840. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15841. /**
  15842. * Remove a specific drag gradient
  15843. * @param gradient defines the gradient to remove
  15844. * @returns the current particle system
  15845. */
  15846. removeDragGradient(gradient: number): IParticleSystem;
  15847. /**
  15848. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15849. * @param gradient defines the gradient to use (between 0 and 1)
  15850. * @param factor defines the emit rate value to affect to the specified gradient
  15851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15852. * @returns the current particle system
  15853. */
  15854. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15855. /**
  15856. * Remove a specific emit rate gradient
  15857. * @param gradient defines the gradient to remove
  15858. * @returns the current particle system
  15859. */
  15860. removeEmitRateGradient(gradient: number): IParticleSystem;
  15861. /**
  15862. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15863. * @param gradient defines the gradient to use (between 0 and 1)
  15864. * @param factor defines the start size value to affect to the specified gradient
  15865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15866. * @returns the current particle system
  15867. */
  15868. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15869. /**
  15870. * Remove a specific start size gradient
  15871. * @param gradient defines the gradient to remove
  15872. * @returns the current particle system
  15873. */
  15874. removeStartSizeGradient(gradient: number): IParticleSystem;
  15875. private _createRampGradientTexture;
  15876. /**
  15877. * Gets the current list of ramp gradients.
  15878. * You must use addRampGradient and removeRampGradient to udpate this list
  15879. * @returns the list of ramp gradients
  15880. */
  15881. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15882. /** Force the system to rebuild all gradients that need to be resync */
  15883. forceRefreshGradients(): void;
  15884. private _syncRampGradientTexture;
  15885. /**
  15886. * Adds a new ramp gradient used to remap particle colors
  15887. * @param gradient defines the gradient to use (between 0 and 1)
  15888. * @param color defines the color to affect to the specified gradient
  15889. * @returns the current particle system
  15890. */
  15891. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15892. /**
  15893. * Remove a specific ramp gradient
  15894. * @param gradient defines the gradient to remove
  15895. * @returns the current particle system
  15896. */
  15897. removeRampGradient(gradient: number): ParticleSystem;
  15898. /**
  15899. * Adds a new color gradient
  15900. * @param gradient defines the gradient to use (between 0 and 1)
  15901. * @param color1 defines the color to affect to the specified gradient
  15902. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15903. * @returns this particle system
  15904. */
  15905. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15906. /**
  15907. * Remove a specific color gradient
  15908. * @param gradient defines the gradient to remove
  15909. * @returns this particle system
  15910. */
  15911. removeColorGradient(gradient: number): IParticleSystem;
  15912. private _fetchR;
  15913. protected _reset(): void;
  15914. private _resetEffect;
  15915. private _createVertexBuffers;
  15916. private _createIndexBuffer;
  15917. /**
  15918. * Gets the maximum number of particles active at the same time.
  15919. * @returns The max number of active particles.
  15920. */
  15921. getCapacity(): number;
  15922. /**
  15923. * Gets whether there are still active particles in the system.
  15924. * @returns True if it is alive, otherwise false.
  15925. */
  15926. isAlive(): boolean;
  15927. /**
  15928. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15929. * @returns True if it has been started, otherwise false.
  15930. */
  15931. isStarted(): boolean;
  15932. private _prepareSubEmitterInternalArray;
  15933. /**
  15934. * Starts the particle system and begins to emit
  15935. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15936. */
  15937. start(delay?: number): void;
  15938. /**
  15939. * Stops the particle system.
  15940. * @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.
  15941. */
  15942. stop(stopSubEmitters?: boolean): void;
  15943. /**
  15944. * Remove all active particles
  15945. */
  15946. reset(): void;
  15947. /**
  15948. * @hidden (for internal use only)
  15949. */
  15950. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15951. /**
  15952. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15953. * Its lifetime will start back at 0.
  15954. */
  15955. recycleParticle: (particle: Particle) => void;
  15956. private _stopSubEmitters;
  15957. private _createParticle;
  15958. private _removeFromRoot;
  15959. private _emitFromParticle;
  15960. private _update;
  15961. /** @hidden */
  15962. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15963. /** @hidden */
  15964. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15965. /**
  15966. * Fill the defines array according to the current settings of the particle system
  15967. * @param defines Array to be updated
  15968. * @param blendMode blend mode to take into account when updating the array
  15969. */
  15970. fillDefines(defines: Array<string>, blendMode: number): void;
  15971. /**
  15972. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  15973. * @param uniforms Uniforms array to fill
  15974. * @param attributes Attributes array to fill
  15975. * @param samplers Samplers array to fill
  15976. */
  15977. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  15978. /** @hidden */
  15979. private _getEffect;
  15980. /**
  15981. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15982. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15983. */
  15984. animate(preWarmOnly?: boolean): void;
  15985. private _appendParticleVertices;
  15986. /**
  15987. * Rebuilds the particle system.
  15988. */
  15989. rebuild(): void;
  15990. /**
  15991. * Is this system ready to be used/rendered
  15992. * @return true if the system is ready
  15993. */
  15994. isReady(): boolean;
  15995. private _render;
  15996. /**
  15997. * Renders the particle system in its current state.
  15998. * @returns the current number of particles
  15999. */
  16000. render(): number;
  16001. /**
  16002. * Disposes the particle system and free the associated resources
  16003. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16004. */
  16005. dispose(disposeTexture?: boolean): void;
  16006. /**
  16007. * Clones the particle system.
  16008. * @param name The name of the cloned object
  16009. * @param newEmitter The new emitter to use
  16010. * @returns the cloned particle system
  16011. */
  16012. clone(name: string, newEmitter: any): ParticleSystem;
  16013. /**
  16014. * Serializes the particle system to a JSON object
  16015. * @param serializeTexture defines if the texture must be serialized as well
  16016. * @returns the JSON object
  16017. */
  16018. serialize(serializeTexture?: boolean): any;
  16019. /** @hidden */
  16020. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  16021. /** @hidden */
  16022. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  16023. /**
  16024. * Parses a JSON object to create a particle system.
  16025. * @param parsedParticleSystem The JSON object to parse
  16026. * @param sceneOrEngine The scene or the engine to create the particle system in
  16027. * @param rootUrl The root url to use to load external dependencies like texture
  16028. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16029. * @returns the Parsed particle system
  16030. */
  16031. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16032. }
  16033. }
  16034. declare module BABYLON {
  16035. /**
  16036. * A particle represents one of the element emitted by a particle system.
  16037. * This is mainly define by its coordinates, direction, velocity and age.
  16038. */
  16039. export class Particle {
  16040. /**
  16041. * The particle system the particle belongs to.
  16042. */
  16043. particleSystem: ParticleSystem;
  16044. private static _Count;
  16045. /**
  16046. * Unique ID of the particle
  16047. */
  16048. id: number;
  16049. /**
  16050. * The world position of the particle in the scene.
  16051. */
  16052. position: Vector3;
  16053. /**
  16054. * The world direction of the particle in the scene.
  16055. */
  16056. direction: Vector3;
  16057. /**
  16058. * The color of the particle.
  16059. */
  16060. color: Color4;
  16061. /**
  16062. * The color change of the particle per step.
  16063. */
  16064. colorStep: Color4;
  16065. /**
  16066. * Defines how long will the life of the particle be.
  16067. */
  16068. lifeTime: number;
  16069. /**
  16070. * The current age of the particle.
  16071. */
  16072. age: number;
  16073. /**
  16074. * The current size of the particle.
  16075. */
  16076. size: number;
  16077. /**
  16078. * The current scale of the particle.
  16079. */
  16080. scale: Vector2;
  16081. /**
  16082. * The current angle of the particle.
  16083. */
  16084. angle: number;
  16085. /**
  16086. * Defines how fast is the angle changing.
  16087. */
  16088. angularSpeed: number;
  16089. /**
  16090. * Defines the cell index used by the particle to be rendered from a sprite.
  16091. */
  16092. cellIndex: number;
  16093. /**
  16094. * The information required to support color remapping
  16095. */
  16096. remapData: Vector4;
  16097. /** @hidden */
  16098. _randomCellOffset?: number;
  16099. /** @hidden */
  16100. _initialDirection: Nullable<Vector3>;
  16101. /** @hidden */
  16102. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  16103. /** @hidden */
  16104. _initialStartSpriteCellID: number;
  16105. /** @hidden */
  16106. _initialEndSpriteCellID: number;
  16107. /** @hidden */
  16108. _currentColorGradient: Nullable<ColorGradient>;
  16109. /** @hidden */
  16110. _currentColor1: Color4;
  16111. /** @hidden */
  16112. _currentColor2: Color4;
  16113. /** @hidden */
  16114. _currentSizeGradient: Nullable<FactorGradient>;
  16115. /** @hidden */
  16116. _currentSize1: number;
  16117. /** @hidden */
  16118. _currentSize2: number;
  16119. /** @hidden */
  16120. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  16121. /** @hidden */
  16122. _currentAngularSpeed1: number;
  16123. /** @hidden */
  16124. _currentAngularSpeed2: number;
  16125. /** @hidden */
  16126. _currentVelocityGradient: Nullable<FactorGradient>;
  16127. /** @hidden */
  16128. _currentVelocity1: number;
  16129. /** @hidden */
  16130. _currentVelocity2: number;
  16131. /** @hidden */
  16132. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  16133. /** @hidden */
  16134. _currentLimitVelocity1: number;
  16135. /** @hidden */
  16136. _currentLimitVelocity2: number;
  16137. /** @hidden */
  16138. _currentDragGradient: Nullable<FactorGradient>;
  16139. /** @hidden */
  16140. _currentDrag1: number;
  16141. /** @hidden */
  16142. _currentDrag2: number;
  16143. /** @hidden */
  16144. _randomNoiseCoordinates1: Vector3;
  16145. /** @hidden */
  16146. _randomNoiseCoordinates2: Vector3;
  16147. /** @hidden */
  16148. _localPosition?: Vector3;
  16149. /**
  16150. * Creates a new instance Particle
  16151. * @param particleSystem the particle system the particle belongs to
  16152. */
  16153. constructor(
  16154. /**
  16155. * The particle system the particle belongs to.
  16156. */
  16157. particleSystem: ParticleSystem);
  16158. private updateCellInfoFromSystem;
  16159. /**
  16160. * Defines how the sprite cell index is updated for the particle
  16161. */
  16162. updateCellIndex(): void;
  16163. /** @hidden */
  16164. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  16165. /** @hidden */
  16166. _inheritParticleInfoToSubEmitters(): void;
  16167. /** @hidden */
  16168. _reset(): void;
  16169. /**
  16170. * Copy the properties of particle to another one.
  16171. * @param other the particle to copy the information to.
  16172. */
  16173. copyTo(other: Particle): void;
  16174. }
  16175. }
  16176. declare module BABYLON {
  16177. /**
  16178. * Particle emitter represents a volume emitting particles.
  16179. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  16180. */
  16181. export interface IParticleEmitterType {
  16182. /**
  16183. * Called by the particle System when the direction is computed for the created particle.
  16184. * @param worldMatrix is the world matrix of the particle system
  16185. * @param directionToUpdate is the direction vector to update with the result
  16186. * @param particle is the particle we are computed the direction for
  16187. * @param isLocal defines if the direction should be set in local space
  16188. */
  16189. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16190. /**
  16191. * Called by the particle System when the position is computed for the created particle.
  16192. * @param worldMatrix is the world matrix of the particle system
  16193. * @param positionToUpdate is the position vector to update with the result
  16194. * @param particle is the particle we are computed the position for
  16195. * @param isLocal defines if the position should be set in local space
  16196. */
  16197. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16198. /**
  16199. * Clones the current emitter and returns a copy of it
  16200. * @returns the new emitter
  16201. */
  16202. clone(): IParticleEmitterType;
  16203. /**
  16204. * Called by the GPUParticleSystem to setup the update shader
  16205. * @param effect defines the update shader
  16206. */
  16207. applyToShader(effect: Effect): void;
  16208. /**
  16209. * Returns a string to use to update the GPU particles update shader
  16210. * @returns the effect defines string
  16211. */
  16212. getEffectDefines(): string;
  16213. /**
  16214. * Returns a string representing the class name
  16215. * @returns a string containing the class name
  16216. */
  16217. getClassName(): string;
  16218. /**
  16219. * Serializes the particle system to a JSON object.
  16220. * @returns the JSON object
  16221. */
  16222. serialize(): any;
  16223. /**
  16224. * Parse properties from a JSON object
  16225. * @param serializationObject defines the JSON object
  16226. * @param scene defines the hosting scene
  16227. */
  16228. parse(serializationObject: any, scene: Nullable<Scene>): void;
  16229. }
  16230. }
  16231. declare module BABYLON {
  16232. /**
  16233. * Particle emitter emitting particles from the inside of a box.
  16234. * It emits the particles randomly between 2 given directions.
  16235. */
  16236. export class BoxParticleEmitter implements IParticleEmitterType {
  16237. /**
  16238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16239. */
  16240. direction1: Vector3;
  16241. /**
  16242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16243. */
  16244. direction2: Vector3;
  16245. /**
  16246. * 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.
  16247. */
  16248. minEmitBox: Vector3;
  16249. /**
  16250. * 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.
  16251. */
  16252. maxEmitBox: Vector3;
  16253. /**
  16254. * Creates a new instance BoxParticleEmitter
  16255. */
  16256. constructor();
  16257. /**
  16258. * Called by the particle System when the direction is computed for the created particle.
  16259. * @param worldMatrix is the world matrix of the particle system
  16260. * @param directionToUpdate is the direction vector to update with the result
  16261. * @param particle is the particle we are computed the direction for
  16262. * @param isLocal defines if the direction should be set in local space
  16263. */
  16264. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16265. /**
  16266. * Called by the particle System when the position is computed for the created particle.
  16267. * @param worldMatrix is the world matrix of the particle system
  16268. * @param positionToUpdate is the position vector to update with the result
  16269. * @param particle is the particle we are computed the position for
  16270. * @param isLocal defines if the position should be set in local space
  16271. */
  16272. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16273. /**
  16274. * Clones the current emitter and returns a copy of it
  16275. * @returns the new emitter
  16276. */
  16277. clone(): BoxParticleEmitter;
  16278. /**
  16279. * Called by the GPUParticleSystem to setup the update shader
  16280. * @param effect defines the update shader
  16281. */
  16282. applyToShader(effect: Effect): void;
  16283. /**
  16284. * Returns a string to use to update the GPU particles update shader
  16285. * @returns a string containng the defines string
  16286. */
  16287. getEffectDefines(): string;
  16288. /**
  16289. * Returns the string "BoxParticleEmitter"
  16290. * @returns a string containing the class name
  16291. */
  16292. getClassName(): string;
  16293. /**
  16294. * Serializes the particle system to a JSON object.
  16295. * @returns the JSON object
  16296. */
  16297. serialize(): any;
  16298. /**
  16299. * Parse properties from a JSON object
  16300. * @param serializationObject defines the JSON object
  16301. */
  16302. parse(serializationObject: any): void;
  16303. }
  16304. }
  16305. declare module BABYLON {
  16306. /**
  16307. * Particle emitter emitting particles from the inside of a cone.
  16308. * It emits the particles alongside the cone volume from the base to the particle.
  16309. * The emission direction might be randomized.
  16310. */
  16311. export class ConeParticleEmitter implements IParticleEmitterType {
  16312. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16313. directionRandomizer: number;
  16314. private _radius;
  16315. private _angle;
  16316. private _height;
  16317. /**
  16318. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  16319. */
  16320. radiusRange: number;
  16321. /**
  16322. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  16323. */
  16324. heightRange: number;
  16325. /**
  16326. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  16327. */
  16328. emitFromSpawnPointOnly: boolean;
  16329. /**
  16330. * Gets or sets the radius of the emission cone
  16331. */
  16332. get radius(): number;
  16333. set radius(value: number);
  16334. /**
  16335. * Gets or sets the angle of the emission cone
  16336. */
  16337. get angle(): number;
  16338. set angle(value: number);
  16339. private _buildHeight;
  16340. /**
  16341. * Creates a new instance ConeParticleEmitter
  16342. * @param radius the radius of the emission cone (1 by default)
  16343. * @param angle the cone base angle (PI by default)
  16344. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  16345. */
  16346. constructor(radius?: number, angle?: number,
  16347. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  16348. directionRandomizer?: number);
  16349. /**
  16350. * Called by the particle System when the direction is computed for the created particle.
  16351. * @param worldMatrix is the world matrix of the particle system
  16352. * @param directionToUpdate is the direction vector to update with the result
  16353. * @param particle is the particle we are computed the direction for
  16354. * @param isLocal defines if the direction should be set in local space
  16355. */
  16356. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16357. /**
  16358. * Called by the particle System when the position is computed for the created particle.
  16359. * @param worldMatrix is the world matrix of the particle system
  16360. * @param positionToUpdate is the position vector to update with the result
  16361. * @param particle is the particle we are computed the position for
  16362. * @param isLocal defines if the position should be set in local space
  16363. */
  16364. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16365. /**
  16366. * Clones the current emitter and returns a copy of it
  16367. * @returns the new emitter
  16368. */
  16369. clone(): ConeParticleEmitter;
  16370. /**
  16371. * Called by the GPUParticleSystem to setup the update shader
  16372. * @param effect defines the update shader
  16373. */
  16374. applyToShader(effect: Effect): void;
  16375. /**
  16376. * Returns a string to use to update the GPU particles update shader
  16377. * @returns a string containng the defines string
  16378. */
  16379. getEffectDefines(): string;
  16380. /**
  16381. * Returns the string "ConeParticleEmitter"
  16382. * @returns a string containing the class name
  16383. */
  16384. getClassName(): string;
  16385. /**
  16386. * Serializes the particle system to a JSON object.
  16387. * @returns the JSON object
  16388. */
  16389. serialize(): any;
  16390. /**
  16391. * Parse properties from a JSON object
  16392. * @param serializationObject defines the JSON object
  16393. */
  16394. parse(serializationObject: any): void;
  16395. }
  16396. }
  16397. declare module BABYLON {
  16398. /**
  16399. * Particle emitter emitting particles from the inside of a cylinder.
  16400. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  16401. */
  16402. export class CylinderParticleEmitter implements IParticleEmitterType {
  16403. /**
  16404. * The radius of the emission cylinder.
  16405. */
  16406. radius: number;
  16407. /**
  16408. * The height of the emission cylinder.
  16409. */
  16410. height: number;
  16411. /**
  16412. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16413. */
  16414. radiusRange: number;
  16415. /**
  16416. * How much to randomize the particle direction [0-1].
  16417. */
  16418. directionRandomizer: number;
  16419. /**
  16420. * Creates a new instance CylinderParticleEmitter
  16421. * @param radius the radius of the emission cylinder (1 by default)
  16422. * @param height the height of the emission cylinder (1 by default)
  16423. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16424. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16425. */
  16426. constructor(
  16427. /**
  16428. * The radius of the emission cylinder.
  16429. */
  16430. radius?: number,
  16431. /**
  16432. * The height of the emission cylinder.
  16433. */
  16434. height?: number,
  16435. /**
  16436. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16437. */
  16438. radiusRange?: number,
  16439. /**
  16440. * How much to randomize the particle direction [0-1].
  16441. */
  16442. directionRandomizer?: number);
  16443. /**
  16444. * Called by the particle System when the direction is computed for the created particle.
  16445. * @param worldMatrix is the world matrix of the particle system
  16446. * @param directionToUpdate is the direction vector to update with the result
  16447. * @param particle is the particle we are computed the direction for
  16448. * @param isLocal defines if the direction should be set in local space
  16449. */
  16450. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16451. /**
  16452. * Called by the particle System when the position is computed for the created particle.
  16453. * @param worldMatrix is the world matrix of the particle system
  16454. * @param positionToUpdate is the position vector to update with the result
  16455. * @param particle is the particle we are computed the position for
  16456. * @param isLocal defines if the position should be set in local space
  16457. */
  16458. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16459. /**
  16460. * Clones the current emitter and returns a copy of it
  16461. * @returns the new emitter
  16462. */
  16463. clone(): CylinderParticleEmitter;
  16464. /**
  16465. * Called by the GPUParticleSystem to setup the update shader
  16466. * @param effect defines the update shader
  16467. */
  16468. applyToShader(effect: Effect): void;
  16469. /**
  16470. * Returns a string to use to update the GPU particles update shader
  16471. * @returns a string containng the defines string
  16472. */
  16473. getEffectDefines(): string;
  16474. /**
  16475. * Returns the string "CylinderParticleEmitter"
  16476. * @returns a string containing the class name
  16477. */
  16478. getClassName(): string;
  16479. /**
  16480. * Serializes the particle system to a JSON object.
  16481. * @returns the JSON object
  16482. */
  16483. serialize(): any;
  16484. /**
  16485. * Parse properties from a JSON object
  16486. * @param serializationObject defines the JSON object
  16487. */
  16488. parse(serializationObject: any): void;
  16489. }
  16490. /**
  16491. * Particle emitter emitting particles from the inside of a cylinder.
  16492. * It emits the particles randomly between two vectors.
  16493. */
  16494. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16495. /**
  16496. * The min limit of the emission direction.
  16497. */
  16498. direction1: Vector3;
  16499. /**
  16500. * The max limit of the emission direction.
  16501. */
  16502. direction2: Vector3;
  16503. /**
  16504. * Creates a new instance CylinderDirectedParticleEmitter
  16505. * @param radius the radius of the emission cylinder (1 by default)
  16506. * @param height the height of the emission cylinder (1 by default)
  16507. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16508. * @param direction1 the min limit of the emission direction (up vector by default)
  16509. * @param direction2 the max limit of the emission direction (up vector by default)
  16510. */
  16511. constructor(radius?: number, height?: number, radiusRange?: number,
  16512. /**
  16513. * The min limit of the emission direction.
  16514. */
  16515. direction1?: Vector3,
  16516. /**
  16517. * The max limit of the emission direction.
  16518. */
  16519. direction2?: Vector3);
  16520. /**
  16521. * Called by the particle System when the direction is computed for the created particle.
  16522. * @param worldMatrix is the world matrix of the particle system
  16523. * @param directionToUpdate is the direction vector to update with the result
  16524. * @param particle is the particle we are computed the direction for
  16525. */
  16526. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16527. /**
  16528. * Clones the current emitter and returns a copy of it
  16529. * @returns the new emitter
  16530. */
  16531. clone(): CylinderDirectedParticleEmitter;
  16532. /**
  16533. * Called by the GPUParticleSystem to setup the update shader
  16534. * @param effect defines the update shader
  16535. */
  16536. applyToShader(effect: Effect): void;
  16537. /**
  16538. * Returns a string to use to update the GPU particles update shader
  16539. * @returns a string containng the defines string
  16540. */
  16541. getEffectDefines(): string;
  16542. /**
  16543. * Returns the string "CylinderDirectedParticleEmitter"
  16544. * @returns a string containing the class name
  16545. */
  16546. getClassName(): string;
  16547. /**
  16548. * Serializes the particle system to a JSON object.
  16549. * @returns the JSON object
  16550. */
  16551. serialize(): any;
  16552. /**
  16553. * Parse properties from a JSON object
  16554. * @param serializationObject defines the JSON object
  16555. */
  16556. parse(serializationObject: any): void;
  16557. }
  16558. }
  16559. declare module BABYLON {
  16560. /**
  16561. * Particle emitter emitting particles from the inside of a hemisphere.
  16562. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16563. */
  16564. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16565. /**
  16566. * The radius of the emission hemisphere.
  16567. */
  16568. radius: number;
  16569. /**
  16570. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16571. */
  16572. radiusRange: number;
  16573. /**
  16574. * How much to randomize the particle direction [0-1].
  16575. */
  16576. directionRandomizer: number;
  16577. /**
  16578. * Creates a new instance HemisphericParticleEmitter
  16579. * @param radius the radius of the emission hemisphere (1 by default)
  16580. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16581. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16582. */
  16583. constructor(
  16584. /**
  16585. * The radius of the emission hemisphere.
  16586. */
  16587. radius?: number,
  16588. /**
  16589. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16590. */
  16591. radiusRange?: number,
  16592. /**
  16593. * How much to randomize the particle direction [0-1].
  16594. */
  16595. directionRandomizer?: number);
  16596. /**
  16597. * Called by the particle System when the direction is computed for the created particle.
  16598. * @param worldMatrix is the world matrix of the particle system
  16599. * @param directionToUpdate is the direction vector to update with the result
  16600. * @param particle is the particle we are computed the direction for
  16601. * @param isLocal defines if the direction should be set in local space
  16602. */
  16603. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16604. /**
  16605. * Called by the particle System when the position is computed for the created particle.
  16606. * @param worldMatrix is the world matrix of the particle system
  16607. * @param positionToUpdate is the position vector to update with the result
  16608. * @param particle is the particle we are computed the position for
  16609. * @param isLocal defines if the position should be set in local space
  16610. */
  16611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16612. /**
  16613. * Clones the current emitter and returns a copy of it
  16614. * @returns the new emitter
  16615. */
  16616. clone(): HemisphericParticleEmitter;
  16617. /**
  16618. * Called by the GPUParticleSystem to setup the update shader
  16619. * @param effect defines the update shader
  16620. */
  16621. applyToShader(effect: Effect): void;
  16622. /**
  16623. * Returns a string to use to update the GPU particles update shader
  16624. * @returns a string containng the defines string
  16625. */
  16626. getEffectDefines(): string;
  16627. /**
  16628. * Returns the string "HemisphericParticleEmitter"
  16629. * @returns a string containing the class name
  16630. */
  16631. getClassName(): string;
  16632. /**
  16633. * Serializes the particle system to a JSON object.
  16634. * @returns the JSON object
  16635. */
  16636. serialize(): any;
  16637. /**
  16638. * Parse properties from a JSON object
  16639. * @param serializationObject defines the JSON object
  16640. */
  16641. parse(serializationObject: any): void;
  16642. }
  16643. }
  16644. declare module BABYLON {
  16645. /**
  16646. * Particle emitter emitting particles from a point.
  16647. * It emits the particles randomly between 2 given directions.
  16648. */
  16649. export class PointParticleEmitter implements IParticleEmitterType {
  16650. /**
  16651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16652. */
  16653. direction1: Vector3;
  16654. /**
  16655. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16656. */
  16657. direction2: Vector3;
  16658. /**
  16659. * Creates a new instance PointParticleEmitter
  16660. */
  16661. constructor();
  16662. /**
  16663. * Called by the particle System when the direction is computed for the created particle.
  16664. * @param worldMatrix is the world matrix of the particle system
  16665. * @param directionToUpdate is the direction vector to update with the result
  16666. * @param particle is the particle we are computed the direction for
  16667. * @param isLocal defines if the direction should be set in local space
  16668. */
  16669. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16670. /**
  16671. * Called by the particle System when the position is computed for the created particle.
  16672. * @param worldMatrix is the world matrix of the particle system
  16673. * @param positionToUpdate is the position vector to update with the result
  16674. * @param particle is the particle we are computed the position for
  16675. * @param isLocal defines if the position should be set in local space
  16676. */
  16677. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16678. /**
  16679. * Clones the current emitter and returns a copy of it
  16680. * @returns the new emitter
  16681. */
  16682. clone(): PointParticleEmitter;
  16683. /**
  16684. * Called by the GPUParticleSystem to setup the update shader
  16685. * @param effect defines the update shader
  16686. */
  16687. applyToShader(effect: Effect): void;
  16688. /**
  16689. * Returns a string to use to update the GPU particles update shader
  16690. * @returns a string containng the defines string
  16691. */
  16692. getEffectDefines(): string;
  16693. /**
  16694. * Returns the string "PointParticleEmitter"
  16695. * @returns a string containing the class name
  16696. */
  16697. getClassName(): string;
  16698. /**
  16699. * Serializes the particle system to a JSON object.
  16700. * @returns the JSON object
  16701. */
  16702. serialize(): any;
  16703. /**
  16704. * Parse properties from a JSON object
  16705. * @param serializationObject defines the JSON object
  16706. */
  16707. parse(serializationObject: any): void;
  16708. }
  16709. }
  16710. declare module BABYLON {
  16711. /**
  16712. * Particle emitter emitting particles from the inside of a sphere.
  16713. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16714. */
  16715. export class SphereParticleEmitter implements IParticleEmitterType {
  16716. /**
  16717. * The radius of the emission sphere.
  16718. */
  16719. radius: number;
  16720. /**
  16721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16722. */
  16723. radiusRange: number;
  16724. /**
  16725. * How much to randomize the particle direction [0-1].
  16726. */
  16727. directionRandomizer: number;
  16728. /**
  16729. * Creates a new instance SphereParticleEmitter
  16730. * @param radius the radius of the emission sphere (1 by default)
  16731. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16733. */
  16734. constructor(
  16735. /**
  16736. * The radius of the emission sphere.
  16737. */
  16738. radius?: number,
  16739. /**
  16740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16741. */
  16742. radiusRange?: number,
  16743. /**
  16744. * How much to randomize the particle direction [0-1].
  16745. */
  16746. directionRandomizer?: number);
  16747. /**
  16748. * Called by the particle System when the direction is computed for the created particle.
  16749. * @param worldMatrix is the world matrix of the particle system
  16750. * @param directionToUpdate is the direction vector to update with the result
  16751. * @param particle is the particle we are computed the direction for
  16752. * @param isLocal defines if the direction should be set in local space
  16753. */
  16754. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16755. /**
  16756. * Called by the particle System when the position is computed for the created particle.
  16757. * @param worldMatrix is the world matrix of the particle system
  16758. * @param positionToUpdate is the position vector to update with the result
  16759. * @param particle is the particle we are computed the position for
  16760. * @param isLocal defines if the position should be set in local space
  16761. */
  16762. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16763. /**
  16764. * Clones the current emitter and returns a copy of it
  16765. * @returns the new emitter
  16766. */
  16767. clone(): SphereParticleEmitter;
  16768. /**
  16769. * Called by the GPUParticleSystem to setup the update shader
  16770. * @param effect defines the update shader
  16771. */
  16772. applyToShader(effect: Effect): void;
  16773. /**
  16774. * Returns a string to use to update the GPU particles update shader
  16775. * @returns a string containng the defines string
  16776. */
  16777. getEffectDefines(): string;
  16778. /**
  16779. * Returns the string "SphereParticleEmitter"
  16780. * @returns a string containing the class name
  16781. */
  16782. getClassName(): string;
  16783. /**
  16784. * Serializes the particle system to a JSON object.
  16785. * @returns the JSON object
  16786. */
  16787. serialize(): any;
  16788. /**
  16789. * Parse properties from a JSON object
  16790. * @param serializationObject defines the JSON object
  16791. */
  16792. parse(serializationObject: any): void;
  16793. }
  16794. /**
  16795. * Particle emitter emitting particles from the inside of a sphere.
  16796. * It emits the particles randomly between two vectors.
  16797. */
  16798. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16799. /**
  16800. * The min limit of the emission direction.
  16801. */
  16802. direction1: Vector3;
  16803. /**
  16804. * The max limit of the emission direction.
  16805. */
  16806. direction2: Vector3;
  16807. /**
  16808. * Creates a new instance SphereDirectedParticleEmitter
  16809. * @param radius the radius of the emission sphere (1 by default)
  16810. * @param direction1 the min limit of the emission direction (up vector by default)
  16811. * @param direction2 the max limit of the emission direction (up vector by default)
  16812. */
  16813. constructor(radius?: number,
  16814. /**
  16815. * The min limit of the emission direction.
  16816. */
  16817. direction1?: Vector3,
  16818. /**
  16819. * The max limit of the emission direction.
  16820. */
  16821. direction2?: Vector3);
  16822. /**
  16823. * Called by the particle System when the direction is computed for the created particle.
  16824. * @param worldMatrix is the world matrix of the particle system
  16825. * @param directionToUpdate is the direction vector to update with the result
  16826. * @param particle is the particle we are computed the direction for
  16827. */
  16828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16829. /**
  16830. * Clones the current emitter and returns a copy of it
  16831. * @returns the new emitter
  16832. */
  16833. clone(): SphereDirectedParticleEmitter;
  16834. /**
  16835. * Called by the GPUParticleSystem to setup the update shader
  16836. * @param effect defines the update shader
  16837. */
  16838. applyToShader(effect: Effect): void;
  16839. /**
  16840. * Returns a string to use to update the GPU particles update shader
  16841. * @returns a string containng the defines string
  16842. */
  16843. getEffectDefines(): string;
  16844. /**
  16845. * Returns the string "SphereDirectedParticleEmitter"
  16846. * @returns a string containing the class name
  16847. */
  16848. getClassName(): string;
  16849. /**
  16850. * Serializes the particle system to a JSON object.
  16851. * @returns the JSON object
  16852. */
  16853. serialize(): any;
  16854. /**
  16855. * Parse properties from a JSON object
  16856. * @param serializationObject defines the JSON object
  16857. */
  16858. parse(serializationObject: any): void;
  16859. }
  16860. }
  16861. declare module BABYLON {
  16862. /**
  16863. * Particle emitter emitting particles from a custom list of positions.
  16864. */
  16865. export class CustomParticleEmitter implements IParticleEmitterType {
  16866. /**
  16867. * Gets or sets the position generator that will create the inital position of each particle.
  16868. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16869. */
  16870. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  16871. /**
  16872. * Gets or sets the destination generator that will create the final destination of each particle.
  16873. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  16874. */
  16875. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  16876. /**
  16877. * Creates a new instance CustomParticleEmitter
  16878. */
  16879. constructor();
  16880. /**
  16881. * Called by the particle System when the direction is computed for the created particle.
  16882. * @param worldMatrix is the world matrix of the particle system
  16883. * @param directionToUpdate is the direction vector to update with the result
  16884. * @param particle is the particle we are computed the direction for
  16885. * @param isLocal defines if the direction should be set in local space
  16886. */
  16887. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16888. /**
  16889. * Called by the particle System when the position is computed for the created particle.
  16890. * @param worldMatrix is the world matrix of the particle system
  16891. * @param positionToUpdate is the position vector to update with the result
  16892. * @param particle is the particle we are computed the position for
  16893. * @param isLocal defines if the position should be set in local space
  16894. */
  16895. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16896. /**
  16897. * Clones the current emitter and returns a copy of it
  16898. * @returns the new emitter
  16899. */
  16900. clone(): CustomParticleEmitter;
  16901. /**
  16902. * Called by the GPUParticleSystem to setup the update shader
  16903. * @param effect defines the update shader
  16904. */
  16905. applyToShader(effect: Effect): void;
  16906. /**
  16907. * Returns a string to use to update the GPU particles update shader
  16908. * @returns a string containng the defines string
  16909. */
  16910. getEffectDefines(): string;
  16911. /**
  16912. * Returns the string "PointParticleEmitter"
  16913. * @returns a string containing the class name
  16914. */
  16915. getClassName(): string;
  16916. /**
  16917. * Serializes the particle system to a JSON object.
  16918. * @returns the JSON object
  16919. */
  16920. serialize(): any;
  16921. /**
  16922. * Parse properties from a JSON object
  16923. * @param serializationObject defines the JSON object
  16924. */
  16925. parse(serializationObject: any): void;
  16926. }
  16927. }
  16928. declare module BABYLON {
  16929. /**
  16930. * Particle emitter emitting particles from the inside of a box.
  16931. * It emits the particles randomly between 2 given directions.
  16932. */
  16933. export class MeshParticleEmitter implements IParticleEmitterType {
  16934. private _indices;
  16935. private _positions;
  16936. private _normals;
  16937. private _storedNormal;
  16938. private _mesh;
  16939. /**
  16940. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16941. */
  16942. direction1: Vector3;
  16943. /**
  16944. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16945. */
  16946. direction2: Vector3;
  16947. /**
  16948. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  16949. */
  16950. useMeshNormalsForDirection: boolean;
  16951. /** Defines the mesh to use as source */
  16952. get mesh(): Nullable<AbstractMesh>;
  16953. set mesh(value: Nullable<AbstractMesh>);
  16954. /**
  16955. * Creates a new instance MeshParticleEmitter
  16956. * @param mesh defines the mesh to use as source
  16957. */
  16958. constructor(mesh?: Nullable<AbstractMesh>);
  16959. /**
  16960. * Called by the particle System when the direction is computed for the created particle.
  16961. * @param worldMatrix is the world matrix of the particle system
  16962. * @param directionToUpdate is the direction vector to update with the result
  16963. * @param particle is the particle we are computed the direction for
  16964. * @param isLocal defines if the direction should be set in local space
  16965. */
  16966. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16967. /**
  16968. * Called by the particle System when the position is computed for the created particle.
  16969. * @param worldMatrix is the world matrix of the particle system
  16970. * @param positionToUpdate is the position vector to update with the result
  16971. * @param particle is the particle we are computed the position for
  16972. * @param isLocal defines if the position should be set in local space
  16973. */
  16974. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  16975. /**
  16976. * Clones the current emitter and returns a copy of it
  16977. * @returns the new emitter
  16978. */
  16979. clone(): MeshParticleEmitter;
  16980. /**
  16981. * Called by the GPUParticleSystem to setup the update shader
  16982. * @param effect defines the update shader
  16983. */
  16984. applyToShader(effect: Effect): void;
  16985. /**
  16986. * Returns a string to use to update the GPU particles update shader
  16987. * @returns a string containng the defines string
  16988. */
  16989. getEffectDefines(): string;
  16990. /**
  16991. * Returns the string "BoxParticleEmitter"
  16992. * @returns a string containing the class name
  16993. */
  16994. getClassName(): string;
  16995. /**
  16996. * Serializes the particle system to a JSON object.
  16997. * @returns the JSON object
  16998. */
  16999. serialize(): any;
  17000. /**
  17001. * Parse properties from a JSON object
  17002. * @param serializationObject defines the JSON object
  17003. * @param scene defines the hosting scene
  17004. */
  17005. parse(serializationObject: any, scene: Nullable<Scene>): void;
  17006. }
  17007. }
  17008. declare module BABYLON {
  17009. /**
  17010. * Interface representing a particle system in Babylon.js.
  17011. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17012. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17013. */
  17014. export interface IParticleSystem {
  17015. /**
  17016. * List of animations used by the particle system.
  17017. */
  17018. animations: Animation[];
  17019. /**
  17020. * The id of the Particle system.
  17021. */
  17022. id: string;
  17023. /**
  17024. * The name of the Particle system.
  17025. */
  17026. name: string;
  17027. /**
  17028. * The emitter represents the Mesh or position we are attaching the particle system to.
  17029. */
  17030. emitter: Nullable<AbstractMesh | Vector3>;
  17031. /**
  17032. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17033. */
  17034. isBillboardBased: boolean;
  17035. /**
  17036. * The rendering group used by the Particle system to chose when to render.
  17037. */
  17038. renderingGroupId: number;
  17039. /**
  17040. * The layer mask we are rendering the particles through.
  17041. */
  17042. layerMask: number;
  17043. /**
  17044. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17045. */
  17046. updateSpeed: number;
  17047. /**
  17048. * The amount of time the particle system is running (depends of the overall update speed).
  17049. */
  17050. targetStopDuration: number;
  17051. /**
  17052. * The texture used to render each particle. (this can be a spritesheet)
  17053. */
  17054. particleTexture: Nullable<BaseTexture>;
  17055. /**
  17056. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17057. */
  17058. blendMode: number;
  17059. /**
  17060. * Minimum life time of emitting particles.
  17061. */
  17062. minLifeTime: number;
  17063. /**
  17064. * Maximum life time of emitting particles.
  17065. */
  17066. maxLifeTime: number;
  17067. /**
  17068. * Minimum Size of emitting particles.
  17069. */
  17070. minSize: number;
  17071. /**
  17072. * Maximum Size of emitting particles.
  17073. */
  17074. maxSize: number;
  17075. /**
  17076. * Minimum scale of emitting particles on X axis.
  17077. */
  17078. minScaleX: number;
  17079. /**
  17080. * Maximum scale of emitting particles on X axis.
  17081. */
  17082. maxScaleX: number;
  17083. /**
  17084. * Minimum scale of emitting particles on Y axis.
  17085. */
  17086. minScaleY: number;
  17087. /**
  17088. * Maximum scale of emitting particles on Y axis.
  17089. */
  17090. maxScaleY: number;
  17091. /**
  17092. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17093. */
  17094. color1: Color4;
  17095. /**
  17096. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17097. */
  17098. color2: Color4;
  17099. /**
  17100. * Color the particle will have at the end of its lifetime.
  17101. */
  17102. colorDead: Color4;
  17103. /**
  17104. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17105. */
  17106. emitRate: number;
  17107. /**
  17108. * You can use gravity if you want to give an orientation to your particles.
  17109. */
  17110. gravity: Vector3;
  17111. /**
  17112. * Minimum power of emitting particles.
  17113. */
  17114. minEmitPower: number;
  17115. /**
  17116. * Maximum power of emitting particles.
  17117. */
  17118. maxEmitPower: number;
  17119. /**
  17120. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17121. */
  17122. minAngularSpeed: number;
  17123. /**
  17124. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17125. */
  17126. maxAngularSpeed: number;
  17127. /**
  17128. * Gets or sets the minimal initial rotation in radians.
  17129. */
  17130. minInitialRotation: number;
  17131. /**
  17132. * Gets or sets the maximal initial rotation in radians.
  17133. */
  17134. maxInitialRotation: number;
  17135. /**
  17136. * The particle emitter type defines the emitter used by the particle system.
  17137. * It can be for example box, sphere, or cone...
  17138. */
  17139. particleEmitterType: Nullable<IParticleEmitterType>;
  17140. /**
  17141. * Defines the delay in milliseconds before starting the system (0 by default)
  17142. */
  17143. startDelay: number;
  17144. /**
  17145. * 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
  17146. */
  17147. preWarmCycles: number;
  17148. /**
  17149. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17150. */
  17151. preWarmStepOffset: number;
  17152. /**
  17153. * 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)
  17154. */
  17155. spriteCellChangeSpeed: number;
  17156. /**
  17157. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17158. */
  17159. startSpriteCellID: number;
  17160. /**
  17161. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17162. */
  17163. endSpriteCellID: number;
  17164. /**
  17165. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17166. */
  17167. spriteCellWidth: number;
  17168. /**
  17169. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17170. */
  17171. spriteCellHeight: number;
  17172. /**
  17173. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17174. */
  17175. spriteRandomStartCell: boolean;
  17176. /**
  17177. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17178. */
  17179. isAnimationSheetEnabled: boolean;
  17180. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17181. translationPivot: Vector2;
  17182. /**
  17183. * Gets or sets a texture used to add random noise to particle positions
  17184. */
  17185. noiseTexture: Nullable<BaseTexture>;
  17186. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17187. noiseStrength: Vector3;
  17188. /**
  17189. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17190. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17191. */
  17192. billboardMode: number;
  17193. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17194. limitVelocityDamping: number;
  17195. /**
  17196. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17197. */
  17198. beginAnimationOnStart: boolean;
  17199. /**
  17200. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17201. */
  17202. beginAnimationFrom: number;
  17203. /**
  17204. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17205. */
  17206. beginAnimationTo: number;
  17207. /**
  17208. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17209. */
  17210. beginAnimationLoop: boolean;
  17211. /**
  17212. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17213. */
  17214. disposeOnStop: boolean;
  17215. /**
  17216. * Specifies if the particles are updated in emitter local space or world space
  17217. */
  17218. isLocal: boolean;
  17219. /** Snippet ID if the particle system was created from the snippet server */
  17220. snippetId: string;
  17221. /** Gets or sets a matrix to use to compute projection */
  17222. defaultProjectionMatrix: Matrix;
  17223. /**
  17224. * Gets the maximum number of particles active at the same time.
  17225. * @returns The max number of active particles.
  17226. */
  17227. getCapacity(): number;
  17228. /**
  17229. * Gets the number of particles active at the same time.
  17230. * @returns The number of active particles.
  17231. */
  17232. getActiveCount(): number;
  17233. /**
  17234. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17235. * @returns True if it has been started, otherwise false.
  17236. */
  17237. isStarted(): boolean;
  17238. /**
  17239. * Animates the particle system for this frame.
  17240. */
  17241. animate(): void;
  17242. /**
  17243. * Renders the particle system in its current state.
  17244. * @returns the current number of particles
  17245. */
  17246. render(): number;
  17247. /**
  17248. * Dispose the particle system and frees its associated resources.
  17249. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17250. */
  17251. dispose(disposeTexture?: boolean): void;
  17252. /**
  17253. * An event triggered when the system is disposed
  17254. */
  17255. onDisposeObservable: Observable<IParticleSystem>;
  17256. /**
  17257. * An event triggered when the system is stopped
  17258. */
  17259. onStoppedObservable: Observable<IParticleSystem>;
  17260. /**
  17261. * Clones the particle system.
  17262. * @param name The name of the cloned object
  17263. * @param newEmitter The new emitter to use
  17264. * @returns the cloned particle system
  17265. */
  17266. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17267. /**
  17268. * Serializes the particle system to a JSON object
  17269. * @param serializeTexture defines if the texture must be serialized as well
  17270. * @returns the JSON object
  17271. */
  17272. serialize(serializeTexture: boolean): any;
  17273. /**
  17274. * Rebuild the particle system
  17275. */
  17276. rebuild(): void;
  17277. /** Force the system to rebuild all gradients that need to be resync */
  17278. forceRefreshGradients(): void;
  17279. /**
  17280. * Starts the particle system and begins to emit
  17281. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17282. */
  17283. start(delay?: number): void;
  17284. /**
  17285. * Stops the particle system.
  17286. */
  17287. stop(): void;
  17288. /**
  17289. * Remove all active particles
  17290. */
  17291. reset(): void;
  17292. /**
  17293. * Gets a boolean indicating that the system is stopping
  17294. * @returns true if the system is currently stopping
  17295. */
  17296. isStopping(): boolean;
  17297. /**
  17298. * Is this system ready to be used/rendered
  17299. * @return true if the system is ready
  17300. */
  17301. isReady(): boolean;
  17302. /**
  17303. * Returns the string "ParticleSystem"
  17304. * @returns a string containing the class name
  17305. */
  17306. getClassName(): string;
  17307. /**
  17308. * Gets the custom effect used to render the particles
  17309. * @param blendMode Blend mode for which the effect should be retrieved
  17310. * @returns The effect
  17311. */
  17312. getCustomEffect(blendMode: number): Nullable<Effect>;
  17313. /**
  17314. * Sets the custom effect used to render the particles
  17315. * @param effect The effect to set
  17316. * @param blendMode Blend mode for which the effect should be set
  17317. */
  17318. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  17319. /**
  17320. * Fill the defines array according to the current settings of the particle system
  17321. * @param defines Array to be updated
  17322. * @param blendMode blend mode to take into account when updating the array
  17323. */
  17324. fillDefines(defines: Array<string>, blendMode: number): void;
  17325. /**
  17326. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  17327. * @param uniforms Uniforms array to fill
  17328. * @param attributes Attributes array to fill
  17329. * @param samplers Samplers array to fill
  17330. */
  17331. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  17332. /**
  17333. * Observable that will be called just before the particles are drawn
  17334. */
  17335. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  17336. /**
  17337. * Gets the name of the particle vertex shader
  17338. */
  17339. vertexShaderName: string;
  17340. /**
  17341. * Adds a new color gradient
  17342. * @param gradient defines the gradient to use (between 0 and 1)
  17343. * @param color1 defines the color to affect to the specified gradient
  17344. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17345. * @returns the current particle system
  17346. */
  17347. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17348. /**
  17349. * Remove a specific color gradient
  17350. * @param gradient defines the gradient to remove
  17351. * @returns the current particle system
  17352. */
  17353. removeColorGradient(gradient: number): IParticleSystem;
  17354. /**
  17355. * Adds a new size gradient
  17356. * @param gradient defines the gradient to use (between 0 and 1)
  17357. * @param factor defines the size factor to affect to the specified gradient
  17358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17359. * @returns the current particle system
  17360. */
  17361. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17362. /**
  17363. * Remove a specific size gradient
  17364. * @param gradient defines the gradient to remove
  17365. * @returns the current particle system
  17366. */
  17367. removeSizeGradient(gradient: number): IParticleSystem;
  17368. /**
  17369. * Gets the current list of color gradients.
  17370. * You must use addColorGradient and removeColorGradient to udpate this list
  17371. * @returns the list of color gradients
  17372. */
  17373. getColorGradients(): Nullable<Array<ColorGradient>>;
  17374. /**
  17375. * Gets the current list of size gradients.
  17376. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17377. * @returns the list of size gradients
  17378. */
  17379. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17380. /**
  17381. * Gets the current list of angular speed gradients.
  17382. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17383. * @returns the list of angular speed gradients
  17384. */
  17385. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17386. /**
  17387. * Adds a new angular speed gradient
  17388. * @param gradient defines the gradient to use (between 0 and 1)
  17389. * @param factor defines the angular speed to affect to the specified gradient
  17390. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17391. * @returns the current particle system
  17392. */
  17393. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17394. /**
  17395. * Remove a specific angular speed gradient
  17396. * @param gradient defines the gradient to remove
  17397. * @returns the current particle system
  17398. */
  17399. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17400. /**
  17401. * Gets the current list of velocity gradients.
  17402. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17403. * @returns the list of velocity gradients
  17404. */
  17405. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17406. /**
  17407. * Adds a new velocity gradient
  17408. * @param gradient defines the gradient to use (between 0 and 1)
  17409. * @param factor defines the velocity to affect to the specified gradient
  17410. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17411. * @returns the current particle system
  17412. */
  17413. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17414. /**
  17415. * Remove a specific velocity gradient
  17416. * @param gradient defines the gradient to remove
  17417. * @returns the current particle system
  17418. */
  17419. removeVelocityGradient(gradient: number): IParticleSystem;
  17420. /**
  17421. * Gets the current list of limit velocity gradients.
  17422. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17423. * @returns the list of limit velocity gradients
  17424. */
  17425. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17426. /**
  17427. * Adds a new limit velocity gradient
  17428. * @param gradient defines the gradient to use (between 0 and 1)
  17429. * @param factor defines the limit velocity to affect to the specified gradient
  17430. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17431. * @returns the current particle system
  17432. */
  17433. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17434. /**
  17435. * Remove a specific limit velocity gradient
  17436. * @param gradient defines the gradient to remove
  17437. * @returns the current particle system
  17438. */
  17439. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17440. /**
  17441. * Adds a new drag gradient
  17442. * @param gradient defines the gradient to use (between 0 and 1)
  17443. * @param factor defines the drag to affect to the specified gradient
  17444. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17445. * @returns the current particle system
  17446. */
  17447. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17448. /**
  17449. * Remove a specific drag gradient
  17450. * @param gradient defines the gradient to remove
  17451. * @returns the current particle system
  17452. */
  17453. removeDragGradient(gradient: number): IParticleSystem;
  17454. /**
  17455. * Gets the current list of drag gradients.
  17456. * You must use addDragGradient and removeDragGradient to udpate this list
  17457. * @returns the list of drag gradients
  17458. */
  17459. getDragGradients(): Nullable<Array<FactorGradient>>;
  17460. /**
  17461. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17462. * @param gradient defines the gradient to use (between 0 and 1)
  17463. * @param factor defines the emit rate to affect to the specified gradient
  17464. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17465. * @returns the current particle system
  17466. */
  17467. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17468. /**
  17469. * Remove a specific emit rate gradient
  17470. * @param gradient defines the gradient to remove
  17471. * @returns the current particle system
  17472. */
  17473. removeEmitRateGradient(gradient: number): IParticleSystem;
  17474. /**
  17475. * Gets the current list of emit rate gradients.
  17476. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17477. * @returns the list of emit rate gradients
  17478. */
  17479. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17480. /**
  17481. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17482. * @param gradient defines the gradient to use (between 0 and 1)
  17483. * @param factor defines the start size to affect to the specified gradient
  17484. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17485. * @returns the current particle system
  17486. */
  17487. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17488. /**
  17489. * Remove a specific start size gradient
  17490. * @param gradient defines the gradient to remove
  17491. * @returns the current particle system
  17492. */
  17493. removeStartSizeGradient(gradient: number): IParticleSystem;
  17494. /**
  17495. * Gets the current list of start size gradients.
  17496. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17497. * @returns the list of start size gradients
  17498. */
  17499. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17500. /**
  17501. * Adds a new life time gradient
  17502. * @param gradient defines the gradient to use (between 0 and 1)
  17503. * @param factor defines the life time factor to affect to the specified gradient
  17504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17505. * @returns the current particle system
  17506. */
  17507. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17508. /**
  17509. * Remove a specific life time gradient
  17510. * @param gradient defines the gradient to remove
  17511. * @returns the current particle system
  17512. */
  17513. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17514. /**
  17515. * Gets the current list of life time gradients.
  17516. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17517. * @returns the list of life time gradients
  17518. */
  17519. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17520. /**
  17521. * Gets the current list of color gradients.
  17522. * You must use addColorGradient and removeColorGradient to udpate this list
  17523. * @returns the list of color gradients
  17524. */
  17525. getColorGradients(): Nullable<Array<ColorGradient>>;
  17526. /**
  17527. * Adds a new ramp gradient used to remap particle colors
  17528. * @param gradient defines the gradient to use (between 0 and 1)
  17529. * @param color defines the color to affect to the specified gradient
  17530. * @returns the current particle system
  17531. */
  17532. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  17533. /**
  17534. * Gets the current list of ramp gradients.
  17535. * You must use addRampGradient and removeRampGradient to udpate this list
  17536. * @returns the list of ramp gradients
  17537. */
  17538. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17539. /** Gets or sets a boolean indicating that ramp gradients must be used
  17540. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17541. */
  17542. useRampGradients: boolean;
  17543. /**
  17544. * Adds a new color remap gradient
  17545. * @param gradient defines the gradient to use (between 0 and 1)
  17546. * @param min defines the color remap minimal range
  17547. * @param max defines the color remap maximal range
  17548. * @returns the current particle system
  17549. */
  17550. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17551. /**
  17552. * Gets the current list of color remap gradients.
  17553. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17554. * @returns the list of color remap gradients
  17555. */
  17556. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17557. /**
  17558. * Adds a new alpha remap gradient
  17559. * @param gradient defines the gradient to use (between 0 and 1)
  17560. * @param min defines the alpha remap minimal range
  17561. * @param max defines the alpha remap maximal range
  17562. * @returns the current particle system
  17563. */
  17564. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17565. /**
  17566. * Gets the current list of alpha remap gradients.
  17567. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17568. * @returns the list of alpha remap gradients
  17569. */
  17570. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17571. /**
  17572. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17573. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17574. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17575. * @returns the emitter
  17576. */
  17577. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17578. /**
  17579. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17580. * @param radius The radius of the hemisphere to emit from
  17581. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17582. * @returns the emitter
  17583. */
  17584. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  17585. /**
  17586. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17587. * @param radius The radius of the sphere to emit from
  17588. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17589. * @returns the emitter
  17590. */
  17591. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  17592. /**
  17593. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17594. * @param radius The radius of the sphere to emit from
  17595. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17596. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17597. * @returns the emitter
  17598. */
  17599. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17600. /**
  17601. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17602. * @param radius The radius of the emission cylinder
  17603. * @param height The height of the emission cylinder
  17604. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17605. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17606. * @returns the emitter
  17607. */
  17608. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17609. /**
  17610. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17611. * @param radius The radius of the cylinder to emit from
  17612. * @param height The height of the emission cylinder
  17613. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17616. * @returns the emitter
  17617. */
  17618. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17619. /**
  17620. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17621. * @param radius The radius of the cone to emit from
  17622. * @param angle The base angle of the cone
  17623. * @returns the emitter
  17624. */
  17625. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17626. /**
  17627. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17630. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17631. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17632. * @returns the emitter
  17633. */
  17634. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17635. /**
  17636. * Get hosting scene
  17637. * @returns the scene
  17638. */
  17639. getScene(): Nullable<Scene>;
  17640. }
  17641. }
  17642. declare module BABYLON {
  17643. /**
  17644. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  17645. */
  17646. export class ColorSplitterBlock extends NodeMaterialBlock {
  17647. /**
  17648. * Create a new ColorSplitterBlock
  17649. * @param name defines the block name
  17650. */
  17651. constructor(name: string);
  17652. /**
  17653. * Gets the current class name
  17654. * @returns the class name
  17655. */
  17656. getClassName(): string;
  17657. /**
  17658. * Gets the rgba component (input)
  17659. */
  17660. get rgba(): NodeMaterialConnectionPoint;
  17661. /**
  17662. * Gets the rgb component (input)
  17663. */
  17664. get rgbIn(): NodeMaterialConnectionPoint;
  17665. /**
  17666. * Gets the rgb component (output)
  17667. */
  17668. get rgbOut(): NodeMaterialConnectionPoint;
  17669. /**
  17670. * Gets the r component (output)
  17671. */
  17672. get r(): NodeMaterialConnectionPoint;
  17673. /**
  17674. * Gets the g component (output)
  17675. */
  17676. get g(): NodeMaterialConnectionPoint;
  17677. /**
  17678. * Gets the b component (output)
  17679. */
  17680. get b(): NodeMaterialConnectionPoint;
  17681. /**
  17682. * Gets the a component (output)
  17683. */
  17684. get a(): NodeMaterialConnectionPoint;
  17685. protected _inputRename(name: string): string;
  17686. protected _outputRename(name: string): string;
  17687. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  17688. }
  17689. }
  17690. declare module BABYLON {
  17691. /**
  17692. * Operations supported by the Trigonometry block
  17693. */
  17694. export enum TrigonometryBlockOperations {
  17695. /** Cos */
  17696. Cos = 0,
  17697. /** Sin */
  17698. Sin = 1,
  17699. /** Abs */
  17700. Abs = 2,
  17701. /** Exp */
  17702. Exp = 3,
  17703. /** Exp2 */
  17704. Exp2 = 4,
  17705. /** Round */
  17706. Round = 5,
  17707. /** Floor */
  17708. Floor = 6,
  17709. /** Ceiling */
  17710. Ceiling = 7,
  17711. /** Square root */
  17712. Sqrt = 8,
  17713. /** Log */
  17714. Log = 9,
  17715. /** Tangent */
  17716. Tan = 10,
  17717. /** Arc tangent */
  17718. ArcTan = 11,
  17719. /** Arc cosinus */
  17720. ArcCos = 12,
  17721. /** Arc sinus */
  17722. ArcSin = 13,
  17723. /** Fraction */
  17724. Fract = 14,
  17725. /** Sign */
  17726. Sign = 15,
  17727. /** To radians (from degrees) */
  17728. Radians = 16,
  17729. /** To degrees (from radians) */
  17730. Degrees = 17
  17731. }
  17732. /**
  17733. * Block used to apply trigonometry operation to floats
  17734. */
  17735. export class TrigonometryBlock extends NodeMaterialBlock {
  17736. /**
  17737. * Gets or sets the operation applied by the block
  17738. */
  17739. operation: TrigonometryBlockOperations;
  17740. /**
  17741. * Creates a new TrigonometryBlock
  17742. * @param name defines the block name
  17743. */
  17744. constructor(name: string);
  17745. /**
  17746. * Gets the current class name
  17747. * @returns the class name
  17748. */
  17749. getClassName(): string;
  17750. /**
  17751. * Gets the input component
  17752. */
  17753. get input(): NodeMaterialConnectionPoint;
  17754. /**
  17755. * Gets the output component
  17756. */
  17757. get output(): NodeMaterialConnectionPoint;
  17758. protected _buildBlock(state: NodeMaterialBuildState): this;
  17759. serialize(): any;
  17760. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  17761. protected _dumpPropertiesCode(): string;
  17762. }
  17763. }
  17764. declare module BABYLON {
  17765. /**
  17766. * Interface used to configure the node material editor
  17767. */
  17768. export interface INodeMaterialEditorOptions {
  17769. /** Define the URl to load node editor script */
  17770. editorURL?: string;
  17771. }
  17772. /** @hidden */
  17773. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  17774. NORMAL: boolean;
  17775. TANGENT: boolean;
  17776. UV1: boolean;
  17777. /** BONES */
  17778. NUM_BONE_INFLUENCERS: number;
  17779. BonesPerMesh: number;
  17780. BONETEXTURE: boolean;
  17781. /** MORPH TARGETS */
  17782. MORPHTARGETS: boolean;
  17783. MORPHTARGETS_NORMAL: boolean;
  17784. MORPHTARGETS_TANGENT: boolean;
  17785. MORPHTARGETS_UV: boolean;
  17786. NUM_MORPH_INFLUENCERS: number;
  17787. /** IMAGE PROCESSING */
  17788. IMAGEPROCESSING: boolean;
  17789. VIGNETTE: boolean;
  17790. VIGNETTEBLENDMODEMULTIPLY: boolean;
  17791. VIGNETTEBLENDMODEOPAQUE: boolean;
  17792. TONEMAPPING: boolean;
  17793. TONEMAPPING_ACES: boolean;
  17794. CONTRAST: boolean;
  17795. EXPOSURE: boolean;
  17796. COLORCURVES: boolean;
  17797. COLORGRADING: boolean;
  17798. COLORGRADING3D: boolean;
  17799. SAMPLER3DGREENDEPTH: boolean;
  17800. SAMPLER3DBGRMAP: boolean;
  17801. IMAGEPROCESSINGPOSTPROCESS: boolean;
  17802. /** MISC. */
  17803. BUMPDIRECTUV: number;
  17804. constructor();
  17805. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  17806. }
  17807. /**
  17808. * Class used to configure NodeMaterial
  17809. */
  17810. export interface INodeMaterialOptions {
  17811. /**
  17812. * Defines if blocks should emit comments
  17813. */
  17814. emitComments: boolean;
  17815. }
  17816. /**
  17817. * Class used to create a node based material built by assembling shader blocks
  17818. */
  17819. export class NodeMaterial extends PushMaterial {
  17820. private static _BuildIdGenerator;
  17821. private _options;
  17822. private _vertexCompilationState;
  17823. private _fragmentCompilationState;
  17824. private _sharedData;
  17825. private _buildId;
  17826. private _buildWasSuccessful;
  17827. private _cachedWorldViewMatrix;
  17828. private _cachedWorldViewProjectionMatrix;
  17829. private _optimizers;
  17830. private _animationFrame;
  17831. /** Define the Url to load node editor script */
  17832. static EditorURL: string;
  17833. /** Define the Url to load snippets */
  17834. static SnippetUrl: string;
  17835. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  17836. static IgnoreTexturesAtLoadTime: boolean;
  17837. private BJSNODEMATERIALEDITOR;
  17838. /** Get the inspector from bundle or global */
  17839. private _getGlobalNodeMaterialEditor;
  17840. /**
  17841. * Snippet ID if the material was created from the snippet server
  17842. */
  17843. snippetId: string;
  17844. /**
  17845. * Gets or sets data used by visual editor
  17846. * @see https://nme.babylonjs.com
  17847. */
  17848. editorData: any;
  17849. /**
  17850. * 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)
  17851. */
  17852. ignoreAlpha: boolean;
  17853. /**
  17854. * Defines the maximum number of lights that can be used in the material
  17855. */
  17856. maxSimultaneousLights: number;
  17857. /**
  17858. * Observable raised when the material is built
  17859. */
  17860. onBuildObservable: Observable<NodeMaterial>;
  17861. /**
  17862. * Gets or sets the root nodes of the material vertex shader
  17863. */
  17864. _vertexOutputNodes: NodeMaterialBlock[];
  17865. /**
  17866. * Gets or sets the root nodes of the material fragment (pixel) shader
  17867. */
  17868. _fragmentOutputNodes: NodeMaterialBlock[];
  17869. /** Gets or sets options to control the node material overall behavior */
  17870. get options(): INodeMaterialOptions;
  17871. set options(options: INodeMaterialOptions);
  17872. /**
  17873. * Default configuration related to image processing available in the standard Material.
  17874. */
  17875. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17876. /**
  17877. * Gets the image processing configuration used either in this material.
  17878. */
  17879. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  17880. /**
  17881. * Sets the Default image processing configuration used either in the this material.
  17882. *
  17883. * If sets to null, the scene one is in use.
  17884. */
  17885. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  17886. /**
  17887. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  17888. */
  17889. attachedBlocks: NodeMaterialBlock[];
  17890. /**
  17891. * Specifies the mode of the node material
  17892. * @hidden
  17893. */
  17894. _mode: NodeMaterialModes;
  17895. /**
  17896. * Gets the mode property
  17897. */
  17898. get mode(): NodeMaterialModes;
  17899. /**
  17900. * A free comment about the material
  17901. */
  17902. comment: string;
  17903. /**
  17904. * Create a new node based material
  17905. * @param name defines the material name
  17906. * @param scene defines the hosting scene
  17907. * @param options defines creation option
  17908. */
  17909. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  17910. /**
  17911. * Gets the current class name of the material e.g. "NodeMaterial"
  17912. * @returns the class name
  17913. */
  17914. getClassName(): string;
  17915. /**
  17916. * Keep track of the image processing observer to allow dispose and replace.
  17917. */
  17918. private _imageProcessingObserver;
  17919. /**
  17920. * Attaches a new image processing configuration to the Standard Material.
  17921. * @param configuration
  17922. */
  17923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17924. /**
  17925. * Get a block by its name
  17926. * @param name defines the name of the block to retrieve
  17927. * @returns the required block or null if not found
  17928. */
  17929. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  17930. /**
  17931. * Get a block by its name
  17932. * @param predicate defines the predicate used to find the good candidate
  17933. * @returns the required block or null if not found
  17934. */
  17935. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  17936. /**
  17937. * Get an input block by its name
  17938. * @param predicate defines the predicate used to find the good candidate
  17939. * @returns the required input block or null if not found
  17940. */
  17941. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  17942. /**
  17943. * Gets the list of input blocks attached to this material
  17944. * @returns an array of InputBlocks
  17945. */
  17946. getInputBlocks(): InputBlock[];
  17947. /**
  17948. * Adds a new optimizer to the list of optimizers
  17949. * @param optimizer defines the optimizers to add
  17950. * @returns the current material
  17951. */
  17952. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17953. /**
  17954. * Remove an optimizer from the list of optimizers
  17955. * @param optimizer defines the optimizers to remove
  17956. * @returns the current material
  17957. */
  17958. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  17959. /**
  17960. * Add a new block to the list of output nodes
  17961. * @param node defines the node to add
  17962. * @returns the current material
  17963. */
  17964. addOutputNode(node: NodeMaterialBlock): this;
  17965. /**
  17966. * Remove a block from the list of root nodes
  17967. * @param node defines the node to remove
  17968. * @returns the current material
  17969. */
  17970. removeOutputNode(node: NodeMaterialBlock): this;
  17971. private _addVertexOutputNode;
  17972. private _removeVertexOutputNode;
  17973. private _addFragmentOutputNode;
  17974. private _removeFragmentOutputNode;
  17975. /**
  17976. * Specifies if the material will require alpha blending
  17977. * @returns a boolean specifying if alpha blending is needed
  17978. */
  17979. needAlphaBlending(): boolean;
  17980. /**
  17981. * Specifies if this material should be rendered in alpha test mode
  17982. * @returns a boolean specifying if an alpha test is needed.
  17983. */
  17984. needAlphaTesting(): boolean;
  17985. private _initializeBlock;
  17986. private _resetDualBlocks;
  17987. /**
  17988. * Remove a block from the current node material
  17989. * @param block defines the block to remove
  17990. */
  17991. removeBlock(block: NodeMaterialBlock): void;
  17992. /**
  17993. * Build the material and generates the inner effect
  17994. * @param verbose defines if the build should log activity
  17995. */
  17996. build(verbose?: boolean): void;
  17997. /**
  17998. * Runs an otpimization phase to try to improve the shader code
  17999. */
  18000. optimize(): void;
  18001. private _prepareDefinesForAttributes;
  18002. /**
  18003. * Create a post process from the material
  18004. * @param camera The camera to apply the render pass to.
  18005. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  18006. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  18007. * @param engine The engine which the post process will be applied. (default: current engine)
  18008. * @param reusable If the post process can be reused on the same frame. (default: false)
  18009. * @param textureType Type of textures used when performing the post process. (default: 0)
  18010. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  18011. * @returns the post process created
  18012. */
  18013. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  18014. /**
  18015. * Create the post process effect from the material
  18016. * @param postProcess The post process to create the effect for
  18017. */
  18018. createEffectForPostProcess(postProcess: PostProcess): void;
  18019. private _createEffectForPostProcess;
  18020. /**
  18021. * Create a new procedural texture based on this node material
  18022. * @param size defines the size of the texture
  18023. * @param scene defines the hosting scene
  18024. * @returns the new procedural texture attached to this node material
  18025. */
  18026. createProceduralTexture(size: number | {
  18027. width: number;
  18028. height: number;
  18029. layers?: number;
  18030. }, scene: Scene): Nullable<ProceduralTexture>;
  18031. private _createEffectForParticles;
  18032. private _checkInternals;
  18033. /**
  18034. * Create the effect to be used as the custom effect for a particle system
  18035. * @param particleSystem Particle system to create the effect for
  18036. * @param onCompiled defines a function to call when the effect creation is successful
  18037. * @param onError defines a function to call when the effect creation has failed
  18038. */
  18039. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  18040. private _processDefines;
  18041. /**
  18042. * Get if the submesh is ready to be used and all its information available.
  18043. * Child classes can use it to update shaders
  18044. * @param mesh defines the mesh to check
  18045. * @param subMesh defines which submesh to check
  18046. * @param useInstances specifies that instances should be used
  18047. * @returns a boolean indicating that the submesh is ready or not
  18048. */
  18049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  18050. /**
  18051. * Get a string representing the shaders built by the current node graph
  18052. */
  18053. get compiledShaders(): string;
  18054. /**
  18055. * Binds the world matrix to the material
  18056. * @param world defines the world transformation matrix
  18057. */
  18058. bindOnlyWorldMatrix(world: Matrix): void;
  18059. /**
  18060. * Binds the submesh to this material by preparing the effect and shader to draw
  18061. * @param world defines the world transformation matrix
  18062. * @param mesh defines the mesh containing the submesh
  18063. * @param subMesh defines the submesh to bind the material to
  18064. */
  18065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  18066. /**
  18067. * Gets the active textures from the material
  18068. * @returns an array of textures
  18069. */
  18070. getActiveTextures(): BaseTexture[];
  18071. /**
  18072. * Gets the list of texture blocks
  18073. * @returns an array of texture blocks
  18074. */
  18075. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  18076. /**
  18077. * Specifies if the material uses a texture
  18078. * @param texture defines the texture to check against the material
  18079. * @returns a boolean specifying if the material uses the texture
  18080. */
  18081. hasTexture(texture: BaseTexture): boolean;
  18082. /**
  18083. * Disposes the material
  18084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18086. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18087. */
  18088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18089. /** Creates the node editor window. */
  18090. private _createNodeEditor;
  18091. /**
  18092. * Launch the node material editor
  18093. * @param config Define the configuration of the editor
  18094. * @return a promise fulfilled when the node editor is visible
  18095. */
  18096. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  18097. /**
  18098. * Clear the current material
  18099. */
  18100. clear(): void;
  18101. /**
  18102. * Clear the current material and set it to a default state
  18103. */
  18104. setToDefault(): void;
  18105. /**
  18106. * Clear the current material and set it to a default state for post process
  18107. */
  18108. setToDefaultPostProcess(): void;
  18109. /**
  18110. * Clear the current material and set it to a default state for procedural texture
  18111. */
  18112. setToDefaultProceduralTexture(): void;
  18113. /**
  18114. * Clear the current material and set it to a default state for particle
  18115. */
  18116. setToDefaultParticle(): void;
  18117. /**
  18118. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  18119. * @param url defines the url to load from
  18120. * @returns a promise that will fullfil when the material is fully loaded
  18121. */
  18122. loadAsync(url: string): Promise<void>;
  18123. private _gatherBlocks;
  18124. /**
  18125. * Generate a string containing the code declaration required to create an equivalent of this material
  18126. * @returns a string
  18127. */
  18128. generateCode(): string;
  18129. /**
  18130. * Serializes this material in a JSON representation
  18131. * @returns the serialized material object
  18132. */
  18133. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  18134. private _restoreConnections;
  18135. /**
  18136. * Clear the current graph and load a new one from a serialization object
  18137. * @param source defines the JSON representation of the material
  18138. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18139. * @param merge defines whether or not the source must be merged or replace the current content
  18140. */
  18141. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  18142. /**
  18143. * Makes a duplicate of the current material.
  18144. * @param name - name to use for the new material.
  18145. */
  18146. clone(name: string): NodeMaterial;
  18147. /**
  18148. * Creates a node material from parsed material data
  18149. * @param source defines the JSON representation of the material
  18150. * @param scene defines the hosting scene
  18151. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18152. * @returns a new node material
  18153. */
  18154. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  18155. /**
  18156. * Creates a node material from a snippet saved in a remote file
  18157. * @param name defines the name of the material to create
  18158. * @param url defines the url to load from
  18159. * @param scene defines the hosting scene
  18160. * @returns a promise that will resolve to the new node material
  18161. */
  18162. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  18163. /**
  18164. * Creates a node material from a snippet saved by the node material editor
  18165. * @param snippetId defines the snippet to load
  18166. * @param scene defines the hosting scene
  18167. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18168. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  18169. * @returns a promise that will resolve to the new node material
  18170. */
  18171. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  18172. /**
  18173. * Creates a new node material set to default basic configuration
  18174. * @param name defines the name of the material
  18175. * @param scene defines the hosting scene
  18176. * @returns a new NodeMaterial
  18177. */
  18178. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  18179. }
  18180. }
  18181. declare module BABYLON {
  18182. interface ThinEngine {
  18183. /**
  18184. * Unbind a list of render target textures from the webGL context
  18185. * This is used only when drawBuffer extension or webGL2 are active
  18186. * @param textures defines the render target textures to unbind
  18187. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  18188. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  18189. */
  18190. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  18191. /**
  18192. * Create a multi render target texture
  18193. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  18194. * @param size defines the size of the texture
  18195. * @param options defines the creation options
  18196. * @returns the cube texture as an InternalTexture
  18197. */
  18198. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  18199. /**
  18200. * Update the sample count for a given multiple render target texture
  18201. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  18202. * @param textures defines the textures to update
  18203. * @param samples defines the sample count to set
  18204. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  18205. */
  18206. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  18207. /**
  18208. * Select a subsets of attachments to draw to.
  18209. * @param attachments gl attachments
  18210. */
  18211. bindAttachments(attachments: number[]): void;
  18212. /**
  18213. * Creates a layout object to draw/clear on specific textures in a MRT
  18214. * @param textureStatus textureStatus[i] indicates if the i-th is active
  18215. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  18216. */
  18217. buildTextureLayout(textureStatus: boolean[]): number[];
  18218. /**
  18219. * Restores the webgl state to only draw on the main color attachment
  18220. */
  18221. restoreSingleAttachment(): void;
  18222. /**
  18223. * Clears a list of attachments
  18224. * @param attachments list of the attachments
  18225. * @param colorMain clear color for the main attachment (the first one)
  18226. * @param colorOthers clear color for the other attachments
  18227. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  18228. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  18229. */
  18230. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  18231. }
  18232. }
  18233. declare module BABYLON {
  18234. /**
  18235. * Creation options of the multi render target texture.
  18236. */
  18237. export interface IMultiRenderTargetOptions {
  18238. /**
  18239. * Define if the texture needs to create mip maps after render.
  18240. */
  18241. generateMipMaps?: boolean;
  18242. /**
  18243. * Define the types of all the draw buffers we want to create
  18244. */
  18245. types?: number[];
  18246. /**
  18247. * Define the sampling modes of all the draw buffers we want to create
  18248. */
  18249. samplingModes?: number[];
  18250. /**
  18251. * Define if a depth buffer is required
  18252. */
  18253. generateDepthBuffer?: boolean;
  18254. /**
  18255. * Define if a stencil buffer is required
  18256. */
  18257. generateStencilBuffer?: boolean;
  18258. /**
  18259. * Define if a depth texture is required instead of a depth buffer
  18260. */
  18261. generateDepthTexture?: boolean;
  18262. /**
  18263. * Define the number of desired draw buffers
  18264. */
  18265. textureCount?: number;
  18266. /**
  18267. * Define if aspect ratio should be adapted to the texture or stay the scene one
  18268. */
  18269. doNotChangeAspectRatio?: boolean;
  18270. /**
  18271. * Define the default type of the buffers we are creating
  18272. */
  18273. defaultType?: number;
  18274. }
  18275. /**
  18276. * A multi render target, like a render target provides the ability to render to a texture.
  18277. * Unlike the render target, it can render to several draw buffers in one draw.
  18278. * This is specially interesting in deferred rendering or for any effects requiring more than
  18279. * just one color from a single pass.
  18280. */
  18281. export class MultiRenderTarget extends RenderTargetTexture {
  18282. private _internalTextures;
  18283. private _textures;
  18284. private _multiRenderTargetOptions;
  18285. private _count;
  18286. /**
  18287. * Get if draw buffers are currently supported by the used hardware and browser.
  18288. */
  18289. get isSupported(): boolean;
  18290. /**
  18291. * Get the list of textures generated by the multi render target.
  18292. */
  18293. get textures(): Texture[];
  18294. /**
  18295. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  18296. */
  18297. get count(): number;
  18298. /**
  18299. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  18300. */
  18301. get depthTexture(): Texture;
  18302. /**
  18303. * Set the wrapping mode on U of all the textures we are rendering to.
  18304. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18305. */
  18306. set wrapU(wrap: number);
  18307. /**
  18308. * Set the wrapping mode on V of all the textures we are rendering to.
  18309. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  18310. */
  18311. set wrapV(wrap: number);
  18312. /**
  18313. * Instantiate a new multi render target texture.
  18314. * A multi render target, like a render target provides the ability to render to a texture.
  18315. * Unlike the render target, it can render to several draw buffers in one draw.
  18316. * This is specially interesting in deferred rendering or for any effects requiring more than
  18317. * just one color from a single pass.
  18318. * @param name Define the name of the texture
  18319. * @param size Define the size of the buffers to render to
  18320. * @param count Define the number of target we are rendering into
  18321. * @param scene Define the scene the texture belongs to
  18322. * @param options Define the options used to create the multi render target
  18323. */
  18324. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  18325. private _initTypes;
  18326. /** @hidden */
  18327. _rebuild(forceFullRebuild?: boolean): void;
  18328. private _createInternalTextures;
  18329. private _createTextures;
  18330. /**
  18331. * Replaces a texture within the MRT.
  18332. * @param texture The new texture to insert in the MRT
  18333. * @param index The index of the texture to replace
  18334. */
  18335. replaceTexture(texture: Texture, index: number): void;
  18336. /**
  18337. * Define the number of samples used if MSAA is enabled.
  18338. */
  18339. get samples(): number;
  18340. set samples(value: number);
  18341. /**
  18342. * Resize all the textures in the multi render target.
  18343. * Be careful as it will recreate all the data in the new texture.
  18344. * @param size Define the new size
  18345. */
  18346. resize(size: any): void;
  18347. /**
  18348. * Changes the number of render targets in this MRT
  18349. * Be careful as it will recreate all the data in the new texture.
  18350. * @param count new texture count
  18351. * @param options Specifies texture types and sampling modes for new textures
  18352. */
  18353. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  18354. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18355. /**
  18356. * Dispose the render targets and their associated resources
  18357. */
  18358. dispose(): void;
  18359. /**
  18360. * Release all the underlying texture used as draw buffers.
  18361. */
  18362. releaseInternalTextures(): void;
  18363. }
  18364. }
  18365. declare module BABYLON {
  18366. /** @hidden */
  18367. export var imageProcessingPixelShader: {
  18368. name: string;
  18369. shader: string;
  18370. };
  18371. }
  18372. declare module BABYLON {
  18373. /**
  18374. * ImageProcessingPostProcess
  18375. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  18376. */
  18377. export class ImageProcessingPostProcess extends PostProcess {
  18378. /**
  18379. * Default configuration related to image processing available in the PBR Material.
  18380. */
  18381. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  18382. /**
  18383. * Gets the image processing configuration used either in this material.
  18384. */
  18385. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  18386. /**
  18387. * Sets the Default image processing configuration used either in the this material.
  18388. *
  18389. * If sets to null, the scene one is in use.
  18390. */
  18391. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  18392. /**
  18393. * Keep track of the image processing observer to allow dispose and replace.
  18394. */
  18395. private _imageProcessingObserver;
  18396. /**
  18397. * Attaches a new image processing configuration to the PBR Material.
  18398. * @param configuration
  18399. */
  18400. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  18401. /**
  18402. * If the post process is supported.
  18403. */
  18404. get isSupported(): boolean;
  18405. /**
  18406. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18407. */
  18408. get colorCurves(): Nullable<ColorCurves>;
  18409. /**
  18410. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  18411. */
  18412. set colorCurves(value: Nullable<ColorCurves>);
  18413. /**
  18414. * Gets wether the color curves effect is enabled.
  18415. */
  18416. get colorCurvesEnabled(): boolean;
  18417. /**
  18418. * Sets wether the color curves effect is enabled.
  18419. */
  18420. set colorCurvesEnabled(value: boolean);
  18421. /**
  18422. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18423. */
  18424. get colorGradingTexture(): Nullable<BaseTexture>;
  18425. /**
  18426. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  18427. */
  18428. set colorGradingTexture(value: Nullable<BaseTexture>);
  18429. /**
  18430. * Gets wether the color grading effect is enabled.
  18431. */
  18432. get colorGradingEnabled(): boolean;
  18433. /**
  18434. * Gets wether the color grading effect is enabled.
  18435. */
  18436. set colorGradingEnabled(value: boolean);
  18437. /**
  18438. * Gets exposure used in the effect.
  18439. */
  18440. get exposure(): number;
  18441. /**
  18442. * Sets exposure used in the effect.
  18443. */
  18444. set exposure(value: number);
  18445. /**
  18446. * Gets wether tonemapping is enabled or not.
  18447. */
  18448. get toneMappingEnabled(): boolean;
  18449. /**
  18450. * Sets wether tonemapping is enabled or not
  18451. */
  18452. set toneMappingEnabled(value: boolean);
  18453. /**
  18454. * Gets the type of tone mapping effect.
  18455. */
  18456. get toneMappingType(): number;
  18457. /**
  18458. * Sets the type of tone mapping effect.
  18459. */
  18460. set toneMappingType(value: number);
  18461. /**
  18462. * Gets contrast used in the effect.
  18463. */
  18464. get contrast(): number;
  18465. /**
  18466. * Sets contrast used in the effect.
  18467. */
  18468. set contrast(value: number);
  18469. /**
  18470. * Gets Vignette stretch size.
  18471. */
  18472. get vignetteStretch(): number;
  18473. /**
  18474. * Sets Vignette stretch size.
  18475. */
  18476. set vignetteStretch(value: number);
  18477. /**
  18478. * Gets Vignette centre X Offset.
  18479. */
  18480. get vignetteCentreX(): number;
  18481. /**
  18482. * Sets Vignette centre X Offset.
  18483. */
  18484. set vignetteCentreX(value: number);
  18485. /**
  18486. * Gets Vignette centre Y Offset.
  18487. */
  18488. get vignetteCentreY(): number;
  18489. /**
  18490. * Sets Vignette centre Y Offset.
  18491. */
  18492. set vignetteCentreY(value: number);
  18493. /**
  18494. * Gets Vignette weight or intensity of the vignette effect.
  18495. */
  18496. get vignetteWeight(): number;
  18497. /**
  18498. * Sets Vignette weight or intensity of the vignette effect.
  18499. */
  18500. set vignetteWeight(value: number);
  18501. /**
  18502. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18503. * if vignetteEnabled is set to true.
  18504. */
  18505. get vignetteColor(): Color4;
  18506. /**
  18507. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  18508. * if vignetteEnabled is set to true.
  18509. */
  18510. set vignetteColor(value: Color4);
  18511. /**
  18512. * Gets Camera field of view used by the Vignette effect.
  18513. */
  18514. get vignetteCameraFov(): number;
  18515. /**
  18516. * Sets Camera field of view used by the Vignette effect.
  18517. */
  18518. set vignetteCameraFov(value: number);
  18519. /**
  18520. * Gets the vignette blend mode allowing different kind of effect.
  18521. */
  18522. get vignetteBlendMode(): number;
  18523. /**
  18524. * Sets the vignette blend mode allowing different kind of effect.
  18525. */
  18526. set vignetteBlendMode(value: number);
  18527. /**
  18528. * Gets wether the vignette effect is enabled.
  18529. */
  18530. get vignetteEnabled(): boolean;
  18531. /**
  18532. * Sets wether the vignette effect is enabled.
  18533. */
  18534. set vignetteEnabled(value: boolean);
  18535. private _fromLinearSpace;
  18536. /**
  18537. * Gets wether the input of the processing is in Gamma or Linear Space.
  18538. */
  18539. get fromLinearSpace(): boolean;
  18540. /**
  18541. * Sets wether the input of the processing is in Gamma or Linear Space.
  18542. */
  18543. set fromLinearSpace(value: boolean);
  18544. /**
  18545. * Defines cache preventing GC.
  18546. */
  18547. private _defines;
  18548. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  18549. /**
  18550. * "ImageProcessingPostProcess"
  18551. * @returns "ImageProcessingPostProcess"
  18552. */
  18553. getClassName(): string;
  18554. /**
  18555. * @hidden
  18556. */
  18557. _updateParameters(): void;
  18558. dispose(camera?: Camera): void;
  18559. }
  18560. }
  18561. declare module BABYLON {
  18562. /**
  18563. * Interface for defining prepass effects in the prepass post-process pipeline
  18564. */
  18565. export interface PrePassEffectConfiguration {
  18566. /**
  18567. * Name of the effect
  18568. */
  18569. name: string;
  18570. /**
  18571. * Post process to attach for this effect
  18572. */
  18573. postProcess?: PostProcess;
  18574. /**
  18575. * Textures required in the MRT
  18576. */
  18577. texturesRequired: number[];
  18578. /**
  18579. * Is the effect enabled
  18580. */
  18581. enabled: boolean;
  18582. /**
  18583. * Disposes the effect configuration
  18584. */
  18585. dispose?: () => void;
  18586. /**
  18587. * Creates the associated post process
  18588. */
  18589. createPostProcess?: () => PostProcess;
  18590. }
  18591. }
  18592. declare module BABYLON {
  18593. /**
  18594. * Options to be used when creating a FresnelParameters.
  18595. */
  18596. export type IFresnelParametersCreationOptions = {
  18597. /**
  18598. * Define the color used on edges (grazing angle)
  18599. */
  18600. leftColor?: Color3;
  18601. /**
  18602. * Define the color used on center
  18603. */
  18604. rightColor?: Color3;
  18605. /**
  18606. * Define bias applied to computed fresnel term
  18607. */
  18608. bias?: number;
  18609. /**
  18610. * Defined the power exponent applied to fresnel term
  18611. */
  18612. power?: number;
  18613. /**
  18614. * Define if the fresnel effect is enable or not.
  18615. */
  18616. isEnabled?: boolean;
  18617. };
  18618. /**
  18619. * Serialized format for FresnelParameters.
  18620. */
  18621. export type IFresnelParametersSerialized = {
  18622. /**
  18623. * Define the color used on edges (grazing angle) [as an array]
  18624. */
  18625. leftColor: number[];
  18626. /**
  18627. * Define the color used on center [as an array]
  18628. */
  18629. rightColor: number[];
  18630. /**
  18631. * Define bias applied to computed fresnel term
  18632. */
  18633. bias: number;
  18634. /**
  18635. * Defined the power exponent applied to fresnel term
  18636. */
  18637. power?: number;
  18638. /**
  18639. * Define if the fresnel effect is enable or not.
  18640. */
  18641. isEnabled: boolean;
  18642. };
  18643. /**
  18644. * This represents all the required information to add a fresnel effect on a material:
  18645. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  18646. */
  18647. export class FresnelParameters {
  18648. private _isEnabled;
  18649. /**
  18650. * Define if the fresnel effect is enable or not.
  18651. */
  18652. get isEnabled(): boolean;
  18653. set isEnabled(value: boolean);
  18654. /**
  18655. * Define the color used on edges (grazing angle)
  18656. */
  18657. leftColor: Color3;
  18658. /**
  18659. * Define the color used on center
  18660. */
  18661. rightColor: Color3;
  18662. /**
  18663. * Define bias applied to computed fresnel term
  18664. */
  18665. bias: number;
  18666. /**
  18667. * Defined the power exponent applied to fresnel term
  18668. */
  18669. power: number;
  18670. /**
  18671. * Creates a new FresnelParameters object.
  18672. *
  18673. * @param options provide your own settings to optionally to override defaults
  18674. */
  18675. constructor(options?: IFresnelParametersCreationOptions);
  18676. /**
  18677. * Clones the current fresnel and its valuues
  18678. * @returns a clone fresnel configuration
  18679. */
  18680. clone(): FresnelParameters;
  18681. /**
  18682. * Determines equality between FresnelParameters objects
  18683. * @param otherFresnelParameters defines the second operand
  18684. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  18685. */
  18686. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  18687. /**
  18688. * Serializes the current fresnel parameters to a JSON representation.
  18689. * @return the JSON serialization
  18690. */
  18691. serialize(): IFresnelParametersSerialized;
  18692. /**
  18693. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  18694. * @param parsedFresnelParameters Define the JSON representation
  18695. * @returns the parsed parameters
  18696. */
  18697. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  18698. }
  18699. }
  18700. declare module BABYLON {
  18701. /**
  18702. * This groups all the flags used to control the materials channel.
  18703. */
  18704. export class MaterialFlags {
  18705. private static _DiffuseTextureEnabled;
  18706. /**
  18707. * Are diffuse textures enabled in the application.
  18708. */
  18709. static get DiffuseTextureEnabled(): boolean;
  18710. static set DiffuseTextureEnabled(value: boolean);
  18711. private static _DetailTextureEnabled;
  18712. /**
  18713. * Are detail textures enabled in the application.
  18714. */
  18715. static get DetailTextureEnabled(): boolean;
  18716. static set DetailTextureEnabled(value: boolean);
  18717. private static _AmbientTextureEnabled;
  18718. /**
  18719. * Are ambient textures enabled in the application.
  18720. */
  18721. static get AmbientTextureEnabled(): boolean;
  18722. static set AmbientTextureEnabled(value: boolean);
  18723. private static _OpacityTextureEnabled;
  18724. /**
  18725. * Are opacity textures enabled in the application.
  18726. */
  18727. static get OpacityTextureEnabled(): boolean;
  18728. static set OpacityTextureEnabled(value: boolean);
  18729. private static _ReflectionTextureEnabled;
  18730. /**
  18731. * Are reflection textures enabled in the application.
  18732. */
  18733. static get ReflectionTextureEnabled(): boolean;
  18734. static set ReflectionTextureEnabled(value: boolean);
  18735. private static _EmissiveTextureEnabled;
  18736. /**
  18737. * Are emissive textures enabled in the application.
  18738. */
  18739. static get EmissiveTextureEnabled(): boolean;
  18740. static set EmissiveTextureEnabled(value: boolean);
  18741. private static _SpecularTextureEnabled;
  18742. /**
  18743. * Are specular textures enabled in the application.
  18744. */
  18745. static get SpecularTextureEnabled(): boolean;
  18746. static set SpecularTextureEnabled(value: boolean);
  18747. private static _BumpTextureEnabled;
  18748. /**
  18749. * Are bump textures enabled in the application.
  18750. */
  18751. static get BumpTextureEnabled(): boolean;
  18752. static set BumpTextureEnabled(value: boolean);
  18753. private static _LightmapTextureEnabled;
  18754. /**
  18755. * Are lightmap textures enabled in the application.
  18756. */
  18757. static get LightmapTextureEnabled(): boolean;
  18758. static set LightmapTextureEnabled(value: boolean);
  18759. private static _RefractionTextureEnabled;
  18760. /**
  18761. * Are refraction textures enabled in the application.
  18762. */
  18763. static get RefractionTextureEnabled(): boolean;
  18764. static set RefractionTextureEnabled(value: boolean);
  18765. private static _ColorGradingTextureEnabled;
  18766. /**
  18767. * Are color grading textures enabled in the application.
  18768. */
  18769. static get ColorGradingTextureEnabled(): boolean;
  18770. static set ColorGradingTextureEnabled(value: boolean);
  18771. private static _FresnelEnabled;
  18772. /**
  18773. * Are fresnels enabled in the application.
  18774. */
  18775. static get FresnelEnabled(): boolean;
  18776. static set FresnelEnabled(value: boolean);
  18777. private static _ClearCoatTextureEnabled;
  18778. /**
  18779. * Are clear coat textures enabled in the application.
  18780. */
  18781. static get ClearCoatTextureEnabled(): boolean;
  18782. static set ClearCoatTextureEnabled(value: boolean);
  18783. private static _ClearCoatBumpTextureEnabled;
  18784. /**
  18785. * Are clear coat bump textures enabled in the application.
  18786. */
  18787. static get ClearCoatBumpTextureEnabled(): boolean;
  18788. static set ClearCoatBumpTextureEnabled(value: boolean);
  18789. private static _ClearCoatTintTextureEnabled;
  18790. /**
  18791. * Are clear coat tint textures enabled in the application.
  18792. */
  18793. static get ClearCoatTintTextureEnabled(): boolean;
  18794. static set ClearCoatTintTextureEnabled(value: boolean);
  18795. private static _SheenTextureEnabled;
  18796. /**
  18797. * Are sheen textures enabled in the application.
  18798. */
  18799. static get SheenTextureEnabled(): boolean;
  18800. static set SheenTextureEnabled(value: boolean);
  18801. private static _AnisotropicTextureEnabled;
  18802. /**
  18803. * Are anisotropic textures enabled in the application.
  18804. */
  18805. static get AnisotropicTextureEnabled(): boolean;
  18806. static set AnisotropicTextureEnabled(value: boolean);
  18807. private static _ThicknessTextureEnabled;
  18808. /**
  18809. * Are thickness textures enabled in the application.
  18810. */
  18811. static get ThicknessTextureEnabled(): boolean;
  18812. static set ThicknessTextureEnabled(value: boolean);
  18813. }
  18814. }
  18815. declare module BABYLON {
  18816. /** @hidden */
  18817. export var defaultFragmentDeclaration: {
  18818. name: string;
  18819. shader: string;
  18820. };
  18821. }
  18822. declare module BABYLON {
  18823. /** @hidden */
  18824. export var sceneUboDeclaration: {
  18825. name: string;
  18826. shader: string;
  18827. };
  18828. }
  18829. declare module BABYLON {
  18830. /** @hidden */
  18831. export var meshUboDeclaration: {
  18832. name: string;
  18833. shader: string;
  18834. };
  18835. }
  18836. declare module BABYLON {
  18837. /** @hidden */
  18838. export var defaultUboDeclaration: {
  18839. name: string;
  18840. shader: string;
  18841. };
  18842. }
  18843. declare module BABYLON {
  18844. /** @hidden */
  18845. export var prePassDeclaration: {
  18846. name: string;
  18847. shader: string;
  18848. };
  18849. }
  18850. declare module BABYLON {
  18851. /** @hidden */
  18852. export var lightFragmentDeclaration: {
  18853. name: string;
  18854. shader: string;
  18855. };
  18856. }
  18857. declare module BABYLON {
  18858. /** @hidden */
  18859. export var lightUboDeclaration: {
  18860. name: string;
  18861. shader: string;
  18862. };
  18863. }
  18864. declare module BABYLON {
  18865. /** @hidden */
  18866. export var lightsFragmentFunctions: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module BABYLON {
  18872. /** @hidden */
  18873. export var shadowsFragmentFunctions: {
  18874. name: string;
  18875. shader: string;
  18876. };
  18877. }
  18878. declare module BABYLON {
  18879. /** @hidden */
  18880. export var fresnelFunction: {
  18881. name: string;
  18882. shader: string;
  18883. };
  18884. }
  18885. declare module BABYLON {
  18886. /** @hidden */
  18887. export var bumpFragmentMainFunctions: {
  18888. name: string;
  18889. shader: string;
  18890. };
  18891. }
  18892. declare module BABYLON {
  18893. /** @hidden */
  18894. export var bumpFragmentFunctions: {
  18895. name: string;
  18896. shader: string;
  18897. };
  18898. }
  18899. declare module BABYLON {
  18900. /** @hidden */
  18901. export var logDepthDeclaration: {
  18902. name: string;
  18903. shader: string;
  18904. };
  18905. }
  18906. declare module BABYLON {
  18907. /** @hidden */
  18908. export var fogFragmentDeclaration: {
  18909. name: string;
  18910. shader: string;
  18911. };
  18912. }
  18913. declare module BABYLON {
  18914. /** @hidden */
  18915. export var bumpFragment: {
  18916. name: string;
  18917. shader: string;
  18918. };
  18919. }
  18920. declare module BABYLON {
  18921. /** @hidden */
  18922. export var depthPrePass: {
  18923. name: string;
  18924. shader: string;
  18925. };
  18926. }
  18927. declare module BABYLON {
  18928. /** @hidden */
  18929. export var lightFragment: {
  18930. name: string;
  18931. shader: string;
  18932. };
  18933. }
  18934. declare module BABYLON {
  18935. /** @hidden */
  18936. export var logDepthFragment: {
  18937. name: string;
  18938. shader: string;
  18939. };
  18940. }
  18941. declare module BABYLON {
  18942. /** @hidden */
  18943. export var fogFragment: {
  18944. name: string;
  18945. shader: string;
  18946. };
  18947. }
  18948. declare module BABYLON {
  18949. /** @hidden */
  18950. export var defaultPixelShader: {
  18951. name: string;
  18952. shader: string;
  18953. };
  18954. }
  18955. declare module BABYLON {
  18956. /** @hidden */
  18957. export var defaultVertexDeclaration: {
  18958. name: string;
  18959. shader: string;
  18960. };
  18961. }
  18962. declare module BABYLON {
  18963. /** @hidden */
  18964. export var bonesDeclaration: {
  18965. name: string;
  18966. shader: string;
  18967. };
  18968. }
  18969. declare module BABYLON {
  18970. /** @hidden */
  18971. export var prePassVertexDeclaration: {
  18972. name: string;
  18973. shader: string;
  18974. };
  18975. }
  18976. declare module BABYLON {
  18977. /** @hidden */
  18978. export var bumpVertexDeclaration: {
  18979. name: string;
  18980. shader: string;
  18981. };
  18982. }
  18983. declare module BABYLON {
  18984. /** @hidden */
  18985. export var fogVertexDeclaration: {
  18986. name: string;
  18987. shader: string;
  18988. };
  18989. }
  18990. declare module BABYLON {
  18991. /** @hidden */
  18992. export var lightVxFragmentDeclaration: {
  18993. name: string;
  18994. shader: string;
  18995. };
  18996. }
  18997. declare module BABYLON {
  18998. /** @hidden */
  18999. export var lightVxUboDeclaration: {
  19000. name: string;
  19001. shader: string;
  19002. };
  19003. }
  19004. declare module BABYLON {
  19005. /** @hidden */
  19006. export var morphTargetsVertexGlobalDeclaration: {
  19007. name: string;
  19008. shader: string;
  19009. };
  19010. }
  19011. declare module BABYLON {
  19012. /** @hidden */
  19013. export var morphTargetsVertexDeclaration: {
  19014. name: string;
  19015. shader: string;
  19016. };
  19017. }
  19018. declare module BABYLON {
  19019. /** @hidden */
  19020. export var morphTargetsVertex: {
  19021. name: string;
  19022. shader: string;
  19023. };
  19024. }
  19025. declare module BABYLON {
  19026. /** @hidden */
  19027. export var instancesVertex: {
  19028. name: string;
  19029. shader: string;
  19030. };
  19031. }
  19032. declare module BABYLON {
  19033. /** @hidden */
  19034. export var bonesVertex: {
  19035. name: string;
  19036. shader: string;
  19037. };
  19038. }
  19039. declare module BABYLON {
  19040. /** @hidden */
  19041. export var prePassVertex: {
  19042. name: string;
  19043. shader: string;
  19044. };
  19045. }
  19046. declare module BABYLON {
  19047. /** @hidden */
  19048. export var bumpVertex: {
  19049. name: string;
  19050. shader: string;
  19051. };
  19052. }
  19053. declare module BABYLON {
  19054. /** @hidden */
  19055. export var fogVertex: {
  19056. name: string;
  19057. shader: string;
  19058. };
  19059. }
  19060. declare module BABYLON {
  19061. /** @hidden */
  19062. export var shadowsVertex: {
  19063. name: string;
  19064. shader: string;
  19065. };
  19066. }
  19067. declare module BABYLON {
  19068. /** @hidden */
  19069. export var pointCloudVertex: {
  19070. name: string;
  19071. shader: string;
  19072. };
  19073. }
  19074. declare module BABYLON {
  19075. /** @hidden */
  19076. export var logDepthVertex: {
  19077. name: string;
  19078. shader: string;
  19079. };
  19080. }
  19081. declare module BABYLON {
  19082. /** @hidden */
  19083. export var defaultVertexShader: {
  19084. name: string;
  19085. shader: string;
  19086. };
  19087. }
  19088. declare module BABYLON {
  19089. /**
  19090. * @hidden
  19091. */
  19092. export interface IMaterialDetailMapDefines {
  19093. DETAIL: boolean;
  19094. DETAILDIRECTUV: number;
  19095. DETAIL_NORMALBLENDMETHOD: number;
  19096. /** @hidden */
  19097. _areTexturesDirty: boolean;
  19098. }
  19099. /**
  19100. * Define the code related to the detail map parameters of a material
  19101. *
  19102. * Inspired from:
  19103. * 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
  19104. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  19105. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  19106. */
  19107. export class DetailMapConfiguration {
  19108. private _texture;
  19109. /**
  19110. * The detail texture of the material.
  19111. */
  19112. texture: Nullable<BaseTexture>;
  19113. /**
  19114. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  19115. * Bigger values mean stronger blending
  19116. */
  19117. diffuseBlendLevel: number;
  19118. /**
  19119. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  19120. * Bigger values mean stronger blending. Only used with PBR materials
  19121. */
  19122. roughnessBlendLevel: number;
  19123. /**
  19124. * Defines how strong the bump effect from the detail map is
  19125. * Bigger values mean stronger effect
  19126. */
  19127. bumpLevel: number;
  19128. private _normalBlendMethod;
  19129. /**
  19130. * The method used to blend the bump and detail normals together
  19131. */
  19132. normalBlendMethod: number;
  19133. private _isEnabled;
  19134. /**
  19135. * Enable or disable the detail map on this material
  19136. */
  19137. isEnabled: boolean;
  19138. /** @hidden */
  19139. private _internalMarkAllSubMeshesAsTexturesDirty;
  19140. /** @hidden */
  19141. _markAllSubMeshesAsTexturesDirty(): void;
  19142. /**
  19143. * Instantiate a new detail map
  19144. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  19145. */
  19146. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  19147. /**
  19148. * Gets whether the submesh is ready to be used or not.
  19149. * @param defines the list of "defines" to update.
  19150. * @param scene defines the scene the material belongs to.
  19151. * @returns - boolean indicating that the submesh is ready or not.
  19152. */
  19153. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  19154. /**
  19155. * Update the defines for detail map usage
  19156. * @param defines the list of "defines" to update.
  19157. * @param scene defines the scene the material belongs to.
  19158. */
  19159. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  19160. /**
  19161. * Binds the material data.
  19162. * @param uniformBuffer defines the Uniform buffer to fill in.
  19163. * @param scene defines the scene the material belongs to.
  19164. * @param isFrozen defines whether the material is frozen or not.
  19165. */
  19166. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  19167. /**
  19168. * Checks to see if a texture is used in the material.
  19169. * @param texture - Base texture to use.
  19170. * @returns - Boolean specifying if a texture is used in the material.
  19171. */
  19172. hasTexture(texture: BaseTexture): boolean;
  19173. /**
  19174. * Returns an array of the actively used textures.
  19175. * @param activeTextures Array of BaseTextures
  19176. */
  19177. getActiveTextures(activeTextures: BaseTexture[]): void;
  19178. /**
  19179. * Returns the animatable textures.
  19180. * @param animatables Array of animatable textures.
  19181. */
  19182. getAnimatables(animatables: IAnimatable[]): void;
  19183. /**
  19184. * Disposes the resources of the material.
  19185. * @param forceDisposeTextures - Forces the disposal of all textures.
  19186. */
  19187. dispose(forceDisposeTextures?: boolean): void;
  19188. /**
  19189. * Get the current class name useful for serialization or dynamic coding.
  19190. * @returns "DetailMap"
  19191. */
  19192. getClassName(): string;
  19193. /**
  19194. * Add the required uniforms to the current list.
  19195. * @param uniforms defines the current uniform list.
  19196. */
  19197. static AddUniforms(uniforms: string[]): void;
  19198. /**
  19199. * Add the required samplers to the current list.
  19200. * @param samplers defines the current sampler list.
  19201. */
  19202. static AddSamplers(samplers: string[]): void;
  19203. /**
  19204. * Add the required uniforms to the current buffer.
  19205. * @param uniformBuffer defines the current uniform buffer.
  19206. */
  19207. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  19208. /**
  19209. * Makes a duplicate of the current instance into another one.
  19210. * @param detailMap define the instance where to copy the info
  19211. */
  19212. copyTo(detailMap: DetailMapConfiguration): void;
  19213. /**
  19214. * Serializes this detail map instance
  19215. * @returns - An object with the serialized instance.
  19216. */
  19217. serialize(): any;
  19218. /**
  19219. * Parses a detail map setting from a serialized object.
  19220. * @param source - Serialized object.
  19221. * @param scene Defines the scene we are parsing for
  19222. * @param rootUrl Defines the rootUrl to load from
  19223. */
  19224. parse(source: any, scene: Scene, rootUrl: string): void;
  19225. }
  19226. }
  19227. declare module BABYLON {
  19228. /** @hidden */
  19229. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  19230. MAINUV1: boolean;
  19231. MAINUV2: boolean;
  19232. DIFFUSE: boolean;
  19233. DIFFUSEDIRECTUV: number;
  19234. DETAIL: boolean;
  19235. DETAILDIRECTUV: number;
  19236. DETAIL_NORMALBLENDMETHOD: number;
  19237. AMBIENT: boolean;
  19238. AMBIENTDIRECTUV: number;
  19239. OPACITY: boolean;
  19240. OPACITYDIRECTUV: number;
  19241. OPACITYRGB: boolean;
  19242. REFLECTION: boolean;
  19243. EMISSIVE: boolean;
  19244. EMISSIVEDIRECTUV: number;
  19245. SPECULAR: boolean;
  19246. SPECULARDIRECTUV: number;
  19247. BUMP: boolean;
  19248. BUMPDIRECTUV: number;
  19249. PARALLAX: boolean;
  19250. PARALLAXOCCLUSION: boolean;
  19251. SPECULAROVERALPHA: boolean;
  19252. CLIPPLANE: boolean;
  19253. CLIPPLANE2: boolean;
  19254. CLIPPLANE3: boolean;
  19255. CLIPPLANE4: boolean;
  19256. CLIPPLANE5: boolean;
  19257. CLIPPLANE6: boolean;
  19258. ALPHATEST: boolean;
  19259. DEPTHPREPASS: boolean;
  19260. ALPHAFROMDIFFUSE: boolean;
  19261. POINTSIZE: boolean;
  19262. FOG: boolean;
  19263. SPECULARTERM: boolean;
  19264. DIFFUSEFRESNEL: boolean;
  19265. OPACITYFRESNEL: boolean;
  19266. REFLECTIONFRESNEL: boolean;
  19267. REFRACTIONFRESNEL: boolean;
  19268. EMISSIVEFRESNEL: boolean;
  19269. FRESNEL: boolean;
  19270. NORMAL: boolean;
  19271. UV1: boolean;
  19272. UV2: boolean;
  19273. VERTEXCOLOR: boolean;
  19274. VERTEXALPHA: boolean;
  19275. NUM_BONE_INFLUENCERS: number;
  19276. BonesPerMesh: number;
  19277. BONETEXTURE: boolean;
  19278. BONES_VELOCITY_ENABLED: boolean;
  19279. INSTANCES: boolean;
  19280. THIN_INSTANCES: boolean;
  19281. GLOSSINESS: boolean;
  19282. ROUGHNESS: boolean;
  19283. EMISSIVEASILLUMINATION: boolean;
  19284. LINKEMISSIVEWITHDIFFUSE: boolean;
  19285. REFLECTIONFRESNELFROMSPECULAR: boolean;
  19286. LIGHTMAP: boolean;
  19287. LIGHTMAPDIRECTUV: number;
  19288. OBJECTSPACE_NORMALMAP: boolean;
  19289. USELIGHTMAPASSHADOWMAP: boolean;
  19290. REFLECTIONMAP_3D: boolean;
  19291. REFLECTIONMAP_SPHERICAL: boolean;
  19292. REFLECTIONMAP_PLANAR: boolean;
  19293. REFLECTIONMAP_CUBIC: boolean;
  19294. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  19295. REFLECTIONMAP_PROJECTION: boolean;
  19296. REFLECTIONMAP_SKYBOX: boolean;
  19297. REFLECTIONMAP_EXPLICIT: boolean;
  19298. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  19299. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  19300. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  19301. INVERTCUBICMAP: boolean;
  19302. LOGARITHMICDEPTH: boolean;
  19303. REFRACTION: boolean;
  19304. REFRACTIONMAP_3D: boolean;
  19305. REFLECTIONOVERALPHA: boolean;
  19306. TWOSIDEDLIGHTING: boolean;
  19307. SHADOWFLOAT: boolean;
  19308. MORPHTARGETS: boolean;
  19309. MORPHTARGETS_NORMAL: boolean;
  19310. MORPHTARGETS_TANGENT: boolean;
  19311. MORPHTARGETS_UV: boolean;
  19312. NUM_MORPH_INFLUENCERS: number;
  19313. NONUNIFORMSCALING: boolean;
  19314. PREMULTIPLYALPHA: boolean;
  19315. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  19316. ALPHABLEND: boolean;
  19317. PREPASS: boolean;
  19318. PREPASS_IRRADIANCE: boolean;
  19319. PREPASS_IRRADIANCE_INDEX: number;
  19320. PREPASS_ALBEDO: boolean;
  19321. PREPASS_ALBEDO_INDEX: number;
  19322. PREPASS_DEPTHNORMAL: boolean;
  19323. PREPASS_DEPTHNORMAL_INDEX: number;
  19324. PREPASS_POSITION: boolean;
  19325. PREPASS_POSITION_INDEX: number;
  19326. PREPASS_VELOCITY: boolean;
  19327. PREPASS_VELOCITY_INDEX: number;
  19328. PREPASS_REFLECTIVITY: boolean;
  19329. PREPASS_REFLECTIVITY_INDEX: number;
  19330. SCENE_MRT_COUNT: number;
  19331. RGBDLIGHTMAP: boolean;
  19332. RGBDREFLECTION: boolean;
  19333. RGBDREFRACTION: boolean;
  19334. IMAGEPROCESSING: boolean;
  19335. VIGNETTE: boolean;
  19336. VIGNETTEBLENDMODEMULTIPLY: boolean;
  19337. VIGNETTEBLENDMODEOPAQUE: boolean;
  19338. TONEMAPPING: boolean;
  19339. TONEMAPPING_ACES: boolean;
  19340. CONTRAST: boolean;
  19341. COLORCURVES: boolean;
  19342. COLORGRADING: boolean;
  19343. COLORGRADING3D: boolean;
  19344. SAMPLER3DGREENDEPTH: boolean;
  19345. SAMPLER3DBGRMAP: boolean;
  19346. IMAGEPROCESSINGPOSTPROCESS: boolean;
  19347. MULTIVIEW: boolean;
  19348. /**
  19349. * If the reflection texture on this material is in linear color space
  19350. * @hidden
  19351. */
  19352. IS_REFLECTION_LINEAR: boolean;
  19353. /**
  19354. * If the refraction texture on this material is in linear color space
  19355. * @hidden
  19356. */
  19357. IS_REFRACTION_LINEAR: boolean;
  19358. EXPOSURE: boolean;
  19359. constructor();
  19360. setReflectionMode(modeToEnable: string): void;
  19361. }
  19362. /**
  19363. * This is the default material used in Babylon. It is the best trade off between quality
  19364. * and performances.
  19365. * @see https://doc.babylonjs.com/babylon101/materials
  19366. */
  19367. export class StandardMaterial extends PushMaterial {
  19368. private _diffuseTexture;
  19369. /**
  19370. * The basic texture of the material as viewed under a light.
  19371. */
  19372. diffuseTexture: Nullable<BaseTexture>;
  19373. private _ambientTexture;
  19374. /**
  19375. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  19376. */
  19377. ambientTexture: Nullable<BaseTexture>;
  19378. private _opacityTexture;
  19379. /**
  19380. * Define the transparency of the material from a texture.
  19381. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  19382. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  19383. */
  19384. opacityTexture: Nullable<BaseTexture>;
  19385. private _reflectionTexture;
  19386. /**
  19387. * Define the texture used to display the reflection.
  19388. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19389. */
  19390. reflectionTexture: Nullable<BaseTexture>;
  19391. private _emissiveTexture;
  19392. /**
  19393. * Define texture of the material as if self lit.
  19394. * This will be mixed in the final result even in the absence of light.
  19395. */
  19396. emissiveTexture: Nullable<BaseTexture>;
  19397. private _specularTexture;
  19398. /**
  19399. * Define how the color and intensity of the highlight given by the light in the material.
  19400. */
  19401. specularTexture: Nullable<BaseTexture>;
  19402. private _bumpTexture;
  19403. /**
  19404. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  19405. * 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.
  19406. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  19407. */
  19408. bumpTexture: Nullable<BaseTexture>;
  19409. private _lightmapTexture;
  19410. /**
  19411. * Complex lighting can be computationally expensive to compute at runtime.
  19412. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  19413. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  19414. */
  19415. lightmapTexture: Nullable<BaseTexture>;
  19416. private _refractionTexture;
  19417. /**
  19418. * Define the texture used to display the refraction.
  19419. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19420. */
  19421. refractionTexture: Nullable<BaseTexture>;
  19422. /**
  19423. * The color of the material lit by the environmental background lighting.
  19424. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  19425. */
  19426. ambientColor: Color3;
  19427. /**
  19428. * The basic color of the material as viewed under a light.
  19429. */
  19430. diffuseColor: Color3;
  19431. /**
  19432. * Define how the color and intensity of the highlight given by the light in the material.
  19433. */
  19434. specularColor: Color3;
  19435. /**
  19436. * Define the color of the material as if self lit.
  19437. * This will be mixed in the final result even in the absence of light.
  19438. */
  19439. emissiveColor: Color3;
  19440. /**
  19441. * Defines how sharp are the highlights in the material.
  19442. * The bigger the value the sharper giving a more glossy feeling to the result.
  19443. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  19444. */
  19445. specularPower: number;
  19446. private _useAlphaFromDiffuseTexture;
  19447. /**
  19448. * Does the transparency come from the diffuse texture alpha channel.
  19449. */
  19450. useAlphaFromDiffuseTexture: boolean;
  19451. private _useEmissiveAsIllumination;
  19452. /**
  19453. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  19454. */
  19455. useEmissiveAsIllumination: boolean;
  19456. private _linkEmissiveWithDiffuse;
  19457. /**
  19458. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  19459. * the emissive level when the final color is close to one.
  19460. */
  19461. linkEmissiveWithDiffuse: boolean;
  19462. private _useSpecularOverAlpha;
  19463. /**
  19464. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  19465. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  19466. */
  19467. useSpecularOverAlpha: boolean;
  19468. private _useReflectionOverAlpha;
  19469. /**
  19470. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  19471. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  19472. */
  19473. useReflectionOverAlpha: boolean;
  19474. private _disableLighting;
  19475. /**
  19476. * Does lights from the scene impacts this material.
  19477. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  19478. */
  19479. disableLighting: boolean;
  19480. private _useObjectSpaceNormalMap;
  19481. /**
  19482. * Allows using an object space normal map (instead of tangent space).
  19483. */
  19484. useObjectSpaceNormalMap: boolean;
  19485. private _useParallax;
  19486. /**
  19487. * Is parallax enabled or not.
  19488. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19489. */
  19490. useParallax: boolean;
  19491. private _useParallaxOcclusion;
  19492. /**
  19493. * Is parallax occlusion enabled or not.
  19494. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  19495. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  19496. */
  19497. useParallaxOcclusion: boolean;
  19498. /**
  19499. * 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.
  19500. */
  19501. parallaxScaleBias: number;
  19502. private _roughness;
  19503. /**
  19504. * Helps to define how blurry the reflections should appears in the material.
  19505. */
  19506. roughness: number;
  19507. /**
  19508. * In case of refraction, define the value of the index of refraction.
  19509. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19510. */
  19511. indexOfRefraction: number;
  19512. /**
  19513. * Invert the refraction texture alongside the y axis.
  19514. * It can be useful with procedural textures or probe for instance.
  19515. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  19516. */
  19517. invertRefractionY: boolean;
  19518. /**
  19519. * Defines the alpha limits in alpha test mode.
  19520. */
  19521. alphaCutOff: number;
  19522. private _useLightmapAsShadowmap;
  19523. /**
  19524. * In case of light mapping, define whether the map contains light or shadow informations.
  19525. */
  19526. useLightmapAsShadowmap: boolean;
  19527. private _diffuseFresnelParameters;
  19528. /**
  19529. * Define the diffuse fresnel parameters of the material.
  19530. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19531. */
  19532. diffuseFresnelParameters: FresnelParameters;
  19533. private _opacityFresnelParameters;
  19534. /**
  19535. * Define the opacity fresnel parameters of the material.
  19536. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19537. */
  19538. opacityFresnelParameters: FresnelParameters;
  19539. private _reflectionFresnelParameters;
  19540. /**
  19541. * Define the reflection fresnel parameters of the material.
  19542. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19543. */
  19544. reflectionFresnelParameters: FresnelParameters;
  19545. private _refractionFresnelParameters;
  19546. /**
  19547. * Define the refraction fresnel parameters of the material.
  19548. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19549. */
  19550. refractionFresnelParameters: FresnelParameters;
  19551. private _emissiveFresnelParameters;
  19552. /**
  19553. * Define the emissive fresnel parameters of the material.
  19554. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19555. */
  19556. emissiveFresnelParameters: FresnelParameters;
  19557. private _useReflectionFresnelFromSpecular;
  19558. /**
  19559. * If true automatically deducts the fresnels values from the material specularity.
  19560. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  19561. */
  19562. useReflectionFresnelFromSpecular: boolean;
  19563. private _useGlossinessFromSpecularMapAlpha;
  19564. /**
  19565. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  19566. */
  19567. useGlossinessFromSpecularMapAlpha: boolean;
  19568. private _maxSimultaneousLights;
  19569. /**
  19570. * Defines the maximum number of lights that can be used in the material
  19571. */
  19572. maxSimultaneousLights: number;
  19573. private _invertNormalMapX;
  19574. /**
  19575. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  19576. */
  19577. invertNormalMapX: boolean;
  19578. private _invertNormalMapY;
  19579. /**
  19580. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  19581. */
  19582. invertNormalMapY: boolean;
  19583. private _twoSidedLighting;
  19584. /**
  19585. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  19586. */
  19587. twoSidedLighting: boolean;
  19588. /**
  19589. * Default configuration related to image processing available in the standard Material.
  19590. */
  19591. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  19592. /**
  19593. * Gets the image processing configuration used either in this material.
  19594. */
  19595. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  19596. /**
  19597. * Sets the Default image processing configuration used either in the this material.
  19598. *
  19599. * If sets to null, the scene one is in use.
  19600. */
  19601. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  19602. /**
  19603. * Keep track of the image processing observer to allow dispose and replace.
  19604. */
  19605. private _imageProcessingObserver;
  19606. /**
  19607. * Attaches a new image processing configuration to the Standard Material.
  19608. * @param configuration
  19609. */
  19610. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  19611. /**
  19612. * Defines additionnal PrePass parameters for the material.
  19613. */
  19614. readonly prePassConfiguration: PrePassConfiguration;
  19615. /**
  19616. * Gets wether the color curves effect is enabled.
  19617. */
  19618. get cameraColorCurvesEnabled(): boolean;
  19619. /**
  19620. * Sets wether the color curves effect is enabled.
  19621. */
  19622. set cameraColorCurvesEnabled(value: boolean);
  19623. /**
  19624. * Gets wether the color grading effect is enabled.
  19625. */
  19626. get cameraColorGradingEnabled(): boolean;
  19627. /**
  19628. * Gets wether the color grading effect is enabled.
  19629. */
  19630. set cameraColorGradingEnabled(value: boolean);
  19631. /**
  19632. * Gets wether tonemapping is enabled or not.
  19633. */
  19634. get cameraToneMappingEnabled(): boolean;
  19635. /**
  19636. * Sets wether tonemapping is enabled or not
  19637. */
  19638. set cameraToneMappingEnabled(value: boolean);
  19639. /**
  19640. * The camera exposure used on this material.
  19641. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19642. * This corresponds to a photographic exposure.
  19643. */
  19644. get cameraExposure(): number;
  19645. /**
  19646. * The camera exposure used on this material.
  19647. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  19648. * This corresponds to a photographic exposure.
  19649. */
  19650. set cameraExposure(value: number);
  19651. /**
  19652. * Gets The camera contrast used on this material.
  19653. */
  19654. get cameraContrast(): number;
  19655. /**
  19656. * Sets The camera contrast used on this material.
  19657. */
  19658. set cameraContrast(value: number);
  19659. /**
  19660. * Gets the Color Grading 2D Lookup Texture.
  19661. */
  19662. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  19663. /**
  19664. * Sets the Color Grading 2D Lookup Texture.
  19665. */
  19666. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  19667. /**
  19668. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19669. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19670. * 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;
  19671. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19672. */
  19673. get cameraColorCurves(): Nullable<ColorCurves>;
  19674. /**
  19675. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  19676. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  19677. * 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;
  19678. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  19679. */
  19680. set cameraColorCurves(value: Nullable<ColorCurves>);
  19681. /**
  19682. * Can this material render to several textures at once
  19683. */
  19684. get canRenderToMRT(): boolean;
  19685. /**
  19686. * Defines the detail map parameters for the material.
  19687. */
  19688. readonly detailMap: DetailMapConfiguration;
  19689. protected _renderTargets: SmartArray<RenderTargetTexture>;
  19690. protected _worldViewProjectionMatrix: Matrix;
  19691. protected _globalAmbientColor: Color3;
  19692. protected _useLogarithmicDepth: boolean;
  19693. protected _rebuildInParallel: boolean;
  19694. /**
  19695. * Instantiates a new standard material.
  19696. * This is the default material used in Babylon. It is the best trade off between quality
  19697. * and performances.
  19698. * @see https://doc.babylonjs.com/babylon101/materials
  19699. * @param name Define the name of the material in the scene
  19700. * @param scene Define the scene the material belong to
  19701. */
  19702. constructor(name: string, scene: Scene);
  19703. /**
  19704. * Gets a boolean indicating that current material needs to register RTT
  19705. */
  19706. get hasRenderTargetTextures(): boolean;
  19707. /**
  19708. * Gets the current class name of the material e.g. "StandardMaterial"
  19709. * Mainly use in serialization.
  19710. * @returns the class name
  19711. */
  19712. getClassName(): string;
  19713. /**
  19714. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  19715. * You can try switching to logarithmic depth.
  19716. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  19717. */
  19718. get useLogarithmicDepth(): boolean;
  19719. set useLogarithmicDepth(value: boolean);
  19720. /**
  19721. * Specifies if the material will require alpha blending
  19722. * @returns a boolean specifying if alpha blending is needed
  19723. */
  19724. needAlphaBlending(): boolean;
  19725. /**
  19726. * Specifies if this material should be rendered in alpha test mode
  19727. * @returns a boolean specifying if an alpha test is needed.
  19728. */
  19729. needAlphaTesting(): boolean;
  19730. /**
  19731. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  19732. */
  19733. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  19734. /**
  19735. * Specifies whether or not there is a usable alpha channel for transparency.
  19736. */
  19737. protected _hasAlphaChannel(): boolean;
  19738. /**
  19739. * Get the texture used for alpha test purpose.
  19740. * @returns the diffuse texture in case of the standard material.
  19741. */
  19742. getAlphaTestTexture(): Nullable<BaseTexture>;
  19743. /**
  19744. * Get if the submesh is ready to be used and all its information available.
  19745. * Child classes can use it to update shaders
  19746. * @param mesh defines the mesh to check
  19747. * @param subMesh defines which submesh to check
  19748. * @param useInstances specifies that instances should be used
  19749. * @returns a boolean indicating that the submesh is ready or not
  19750. */
  19751. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  19752. /**
  19753. * Builds the material UBO layouts.
  19754. * Used internally during the effect preparation.
  19755. */
  19756. buildUniformLayout(): void;
  19757. /**
  19758. * Unbinds the material from the mesh
  19759. */
  19760. unbind(): void;
  19761. /**
  19762. * Binds the submesh to this material by preparing the effect and shader to draw
  19763. * @param world defines the world transformation matrix
  19764. * @param mesh defines the mesh containing the submesh
  19765. * @param subMesh defines the submesh to bind the material to
  19766. */
  19767. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  19768. /**
  19769. * Get the list of animatables in the material.
  19770. * @returns the list of animatables object used in the material
  19771. */
  19772. getAnimatables(): IAnimatable[];
  19773. /**
  19774. * Gets the active textures from the material
  19775. * @returns an array of textures
  19776. */
  19777. getActiveTextures(): BaseTexture[];
  19778. /**
  19779. * Specifies if the material uses a texture
  19780. * @param texture defines the texture to check against the material
  19781. * @returns a boolean specifying if the material uses the texture
  19782. */
  19783. hasTexture(texture: BaseTexture): boolean;
  19784. /**
  19785. * Disposes the material
  19786. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19787. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19788. */
  19789. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  19790. /**
  19791. * Makes a duplicate of the material, and gives it a new name
  19792. * @param name defines the new name for the duplicated material
  19793. * @returns the cloned material
  19794. */
  19795. clone(name: string): StandardMaterial;
  19796. /**
  19797. * Serializes this material in a JSON representation
  19798. * @returns the serialized material object
  19799. */
  19800. serialize(): any;
  19801. /**
  19802. * Creates a standard material from parsed material data
  19803. * @param source defines the JSON representation of the material
  19804. * @param scene defines the hosting scene
  19805. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19806. * @returns a new standard material
  19807. */
  19808. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  19809. /**
  19810. * Are diffuse textures enabled in the application.
  19811. */
  19812. static get DiffuseTextureEnabled(): boolean;
  19813. static set DiffuseTextureEnabled(value: boolean);
  19814. /**
  19815. * Are detail textures enabled in the application.
  19816. */
  19817. static get DetailTextureEnabled(): boolean;
  19818. static set DetailTextureEnabled(value: boolean);
  19819. /**
  19820. * Are ambient textures enabled in the application.
  19821. */
  19822. static get AmbientTextureEnabled(): boolean;
  19823. static set AmbientTextureEnabled(value: boolean);
  19824. /**
  19825. * Are opacity textures enabled in the application.
  19826. */
  19827. static get OpacityTextureEnabled(): boolean;
  19828. static set OpacityTextureEnabled(value: boolean);
  19829. /**
  19830. * Are reflection textures enabled in the application.
  19831. */
  19832. static get ReflectionTextureEnabled(): boolean;
  19833. static set ReflectionTextureEnabled(value: boolean);
  19834. /**
  19835. * Are emissive textures enabled in the application.
  19836. */
  19837. static get EmissiveTextureEnabled(): boolean;
  19838. static set EmissiveTextureEnabled(value: boolean);
  19839. /**
  19840. * Are specular textures enabled in the application.
  19841. */
  19842. static get SpecularTextureEnabled(): boolean;
  19843. static set SpecularTextureEnabled(value: boolean);
  19844. /**
  19845. * Are bump textures enabled in the application.
  19846. */
  19847. static get BumpTextureEnabled(): boolean;
  19848. static set BumpTextureEnabled(value: boolean);
  19849. /**
  19850. * Are lightmap textures enabled in the application.
  19851. */
  19852. static get LightmapTextureEnabled(): boolean;
  19853. static set LightmapTextureEnabled(value: boolean);
  19854. /**
  19855. * Are refraction textures enabled in the application.
  19856. */
  19857. static get RefractionTextureEnabled(): boolean;
  19858. static set RefractionTextureEnabled(value: boolean);
  19859. /**
  19860. * Are color grading textures enabled in the application.
  19861. */
  19862. static get ColorGradingTextureEnabled(): boolean;
  19863. static set ColorGradingTextureEnabled(value: boolean);
  19864. /**
  19865. * Are fresnels enabled in the application.
  19866. */
  19867. static get FresnelEnabled(): boolean;
  19868. static set FresnelEnabled(value: boolean);
  19869. }
  19870. }
  19871. declare module BABYLON {
  19872. /** @hidden */
  19873. export var rgbdDecodePixelShader: {
  19874. name: string;
  19875. shader: string;
  19876. };
  19877. }
  19878. declare module BABYLON {
  19879. /** @hidden */
  19880. export var passPixelShader: {
  19881. name: string;
  19882. shader: string;
  19883. };
  19884. }
  19885. declare module BABYLON {
  19886. /** @hidden */
  19887. export var passCubePixelShader: {
  19888. name: string;
  19889. shader: string;
  19890. };
  19891. }
  19892. declare module BABYLON {
  19893. /**
  19894. * PassPostProcess which produces an output the same as it's input
  19895. */
  19896. export class PassPostProcess extends PostProcess {
  19897. /**
  19898. * Gets a string identifying the name of the class
  19899. * @returns "PassPostProcess" string
  19900. */
  19901. getClassName(): string;
  19902. /**
  19903. * Creates the PassPostProcess
  19904. * @param name The name of the effect.
  19905. * @param options The required width/height ratio to downsize to before computing the render pass.
  19906. * @param camera The camera to apply the render pass to.
  19907. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19908. * @param engine The engine which the post process will be applied. (default: current engine)
  19909. * @param reusable If the post process can be reused on the same frame. (default: false)
  19910. * @param textureType The type of texture to be used when performing the post processing.
  19911. * @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)
  19912. */
  19913. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19914. /** @hidden */
  19915. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  19916. }
  19917. /**
  19918. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  19919. */
  19920. export class PassCubePostProcess extends PostProcess {
  19921. private _face;
  19922. /**
  19923. * Gets or sets the cube face to display.
  19924. * * 0 is +X
  19925. * * 1 is -X
  19926. * * 2 is +Y
  19927. * * 3 is -Y
  19928. * * 4 is +Z
  19929. * * 5 is -Z
  19930. */
  19931. get face(): number;
  19932. set face(value: number);
  19933. /**
  19934. * Gets a string identifying the name of the class
  19935. * @returns "PassCubePostProcess" string
  19936. */
  19937. getClassName(): string;
  19938. /**
  19939. * Creates the PassCubePostProcess
  19940. * @param name The name of the effect.
  19941. * @param options The required width/height ratio to downsize to before computing the render pass.
  19942. * @param camera The camera to apply the render pass to.
  19943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  19944. * @param engine The engine which the post process will be applied. (default: current engine)
  19945. * @param reusable If the post process can be reused on the same frame. (default: false)
  19946. * @param textureType The type of texture to be used when performing the post processing.
  19947. * @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)
  19948. */
  19949. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  19950. /** @hidden */
  19951. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  19952. }
  19953. }
  19954. declare module BABYLON {
  19955. /**
  19956. * Class used to host texture specific utilities
  19957. */
  19958. export class TextureTools {
  19959. /**
  19960. * Uses the GPU to create a copy texture rescaled at a given size
  19961. * @param texture Texture to copy from
  19962. * @param width defines the desired width
  19963. * @param height defines the desired height
  19964. * @param useBilinearMode defines if bilinear mode has to be used
  19965. * @return the generated texture
  19966. */
  19967. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  19968. /**
  19969. * Apply a post process to a texture
  19970. * @param postProcessName name of the fragment post process
  19971. * @param internalTexture the texture to encode
  19972. * @param scene the scene hosting the texture
  19973. * @param type type of the output texture. If not provided, use the one from internalTexture
  19974. * @param samplingMode sampling moode to use to sample the source texture. If not provided, use the one from internalTexture
  19975. * @param format format of the output texture. If not provided, use the one from internalTexture
  19976. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19977. */
  19978. static ApplyPostProcess(postProcessName: string, internalTexture: InternalTexture, scene: Scene, type?: number, samplingMode?: number, format?: number): Promise<InternalTexture>;
  19979. }
  19980. }
  19981. declare module BABYLON {
  19982. /**
  19983. * Class used to host RGBD texture specific utilities
  19984. */
  19985. export class RGBDTextureTools {
  19986. /**
  19987. * Expand the RGBD Texture from RGBD to Half Float if possible.
  19988. * @param texture the texture to expand.
  19989. */
  19990. static ExpandRGBDTexture(texture: Texture): void;
  19991. /**
  19992. * Encode the texture to RGBD if possible.
  19993. * @param internalTexture the texture to encode
  19994. * @param scene the scene hosting the texture
  19995. * @param outputTextureType type of the texture in which the encoding is performed
  19996. * @return a promise with the internalTexture having its texture replaced by the result of the processing
  19997. */
  19998. static EncodeTextureToRGBD(internalTexture: InternalTexture, scene: Scene, outputTextureType?: number): Promise<InternalTexture>;
  19999. }
  20000. }
  20001. declare module BABYLON {
  20002. /**
  20003. * Class used to host texture specific utilities
  20004. */
  20005. export class BRDFTextureTools {
  20006. /**
  20007. * Prevents texture cache collision
  20008. */
  20009. private static _instanceNumber;
  20010. /**
  20011. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  20012. * @param scene defines the hosting scene
  20013. * @returns the environment BRDF texture
  20014. */
  20015. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  20016. private static _environmentBRDFBase64Texture;
  20017. }
  20018. }
  20019. declare module BABYLON {
  20020. /**
  20021. * @hidden
  20022. */
  20023. export interface IMaterialClearCoatDefines {
  20024. CLEARCOAT: boolean;
  20025. CLEARCOAT_DEFAULTIOR: boolean;
  20026. CLEARCOAT_TEXTURE: boolean;
  20027. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  20028. CLEARCOAT_TEXTUREDIRECTUV: number;
  20029. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  20030. CLEARCOAT_BUMP: boolean;
  20031. CLEARCOAT_BUMPDIRECTUV: number;
  20032. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20033. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20034. CLEARCOAT_REMAP_F0: boolean;
  20035. CLEARCOAT_TINT: boolean;
  20036. CLEARCOAT_TINT_TEXTURE: boolean;
  20037. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  20038. /** @hidden */
  20039. _areTexturesDirty: boolean;
  20040. }
  20041. /**
  20042. * Define the code related to the clear coat parameters of the pbr material.
  20043. */
  20044. export class PBRClearCoatConfiguration {
  20045. /**
  20046. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20047. * The default fits with a polyurethane material.
  20048. * @hidden
  20049. */
  20050. static readonly _DefaultIndexOfRefraction: number;
  20051. private _isEnabled;
  20052. /**
  20053. * Defines if the clear coat is enabled in the material.
  20054. */
  20055. isEnabled: boolean;
  20056. /**
  20057. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  20058. */
  20059. intensity: number;
  20060. /**
  20061. * Defines the clear coat layer roughness.
  20062. */
  20063. roughness: number;
  20064. private _indexOfRefraction;
  20065. /**
  20066. * Defines the index of refraction of the clear coat.
  20067. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  20068. * The default fits with a polyurethane material.
  20069. * Changing the default value is more performance intensive.
  20070. */
  20071. indexOfRefraction: number;
  20072. private _texture;
  20073. /**
  20074. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  20075. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  20076. * if textureRoughness is not empty, else no texture roughness is used
  20077. */
  20078. texture: Nullable<BaseTexture>;
  20079. private _useRoughnessFromMainTexture;
  20080. /**
  20081. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  20082. * If false, the green channel from textureRoughness is used for roughness
  20083. */
  20084. useRoughnessFromMainTexture: boolean;
  20085. private _textureRoughness;
  20086. /**
  20087. * Stores the clear coat roughness in a texture (green channel)
  20088. * Not used if useRoughnessFromMainTexture is true
  20089. */
  20090. textureRoughness: Nullable<BaseTexture>;
  20091. private _remapF0OnInterfaceChange;
  20092. /**
  20093. * Defines if the F0 value should be remapped to account for the interface change in the material.
  20094. */
  20095. remapF0OnInterfaceChange: boolean;
  20096. private _bumpTexture;
  20097. /**
  20098. * Define the clear coat specific bump texture.
  20099. */
  20100. bumpTexture: Nullable<BaseTexture>;
  20101. private _isTintEnabled;
  20102. /**
  20103. * Defines if the clear coat tint is enabled in the material.
  20104. */
  20105. isTintEnabled: boolean;
  20106. /**
  20107. * Defines the clear coat tint of the material.
  20108. * This is only use if tint is enabled
  20109. */
  20110. tintColor: Color3;
  20111. /**
  20112. * Defines the distance at which the tint color should be found in the
  20113. * clear coat media.
  20114. * This is only use if tint is enabled
  20115. */
  20116. tintColorAtDistance: number;
  20117. /**
  20118. * Defines the clear coat layer thickness.
  20119. * This is only use if tint is enabled
  20120. */
  20121. tintThickness: number;
  20122. private _tintTexture;
  20123. /**
  20124. * Stores the clear tint values in a texture.
  20125. * rgb is tint
  20126. * a is a thickness factor
  20127. */
  20128. tintTexture: Nullable<BaseTexture>;
  20129. /** @hidden */
  20130. private _internalMarkAllSubMeshesAsTexturesDirty;
  20131. /** @hidden */
  20132. _markAllSubMeshesAsTexturesDirty(): void;
  20133. /**
  20134. * Instantiate a new istance of clear coat configuration.
  20135. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20136. */
  20137. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20138. /**
  20139. * Gets wehter the submesh is ready to be used or not.
  20140. * @param defines the list of "defines" to update.
  20141. * @param scene defines the scene the material belongs to.
  20142. * @param engine defines the engine the material belongs to.
  20143. * @param disableBumpMap defines wether the material disables bump or not.
  20144. * @returns - boolean indicating that the submesh is ready or not.
  20145. */
  20146. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  20147. /**
  20148. * Checks to see if a texture is used in the material.
  20149. * @param defines the list of "defines" to update.
  20150. * @param scene defines the scene to the material belongs to.
  20151. */
  20152. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  20153. /**
  20154. * Binds the material data.
  20155. * @param uniformBuffer defines the Uniform buffer to fill in.
  20156. * @param scene defines the scene the material belongs to.
  20157. * @param engine defines the engine the material belongs to.
  20158. * @param disableBumpMap defines wether the material disables bump or not.
  20159. * @param isFrozen defines wether the material is frozen or not.
  20160. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20161. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20162. * @param subMesh the submesh to bind data for
  20163. */
  20164. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  20165. /**
  20166. * Checks to see if a texture is used in the material.
  20167. * @param texture - Base texture to use.
  20168. * @returns - Boolean specifying if a texture is used in the material.
  20169. */
  20170. hasTexture(texture: BaseTexture): boolean;
  20171. /**
  20172. * Returns an array of the actively used textures.
  20173. * @param activeTextures Array of BaseTextures
  20174. */
  20175. getActiveTextures(activeTextures: BaseTexture[]): void;
  20176. /**
  20177. * Returns the animatable textures.
  20178. * @param animatables Array of animatable textures.
  20179. */
  20180. getAnimatables(animatables: IAnimatable[]): void;
  20181. /**
  20182. * Disposes the resources of the material.
  20183. * @param forceDisposeTextures - Forces the disposal of all textures.
  20184. */
  20185. dispose(forceDisposeTextures?: boolean): void;
  20186. /**
  20187. * Get the current class name of the texture useful for serialization or dynamic coding.
  20188. * @returns "PBRClearCoatConfiguration"
  20189. */
  20190. getClassName(): string;
  20191. /**
  20192. * Add fallbacks to the effect fallbacks list.
  20193. * @param defines defines the Base texture to use.
  20194. * @param fallbacks defines the current fallback list.
  20195. * @param currentRank defines the current fallback rank.
  20196. * @returns the new fallback rank.
  20197. */
  20198. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20199. /**
  20200. * Add the required uniforms to the current list.
  20201. * @param uniforms defines the current uniform list.
  20202. */
  20203. static AddUniforms(uniforms: string[]): void;
  20204. /**
  20205. * Add the required samplers to the current list.
  20206. * @param samplers defines the current sampler list.
  20207. */
  20208. static AddSamplers(samplers: string[]): void;
  20209. /**
  20210. * Add the required uniforms to the current buffer.
  20211. * @param uniformBuffer defines the current uniform buffer.
  20212. */
  20213. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20214. /**
  20215. * Makes a duplicate of the current configuration into another one.
  20216. * @param clearCoatConfiguration define the config where to copy the info
  20217. */
  20218. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  20219. /**
  20220. * Serializes this clear coat configuration.
  20221. * @returns - An object with the serialized config.
  20222. */
  20223. serialize(): any;
  20224. /**
  20225. * Parses a anisotropy Configuration from a serialized object.
  20226. * @param source - Serialized object.
  20227. * @param scene Defines the scene we are parsing for
  20228. * @param rootUrl Defines the rootUrl to load from
  20229. */
  20230. parse(source: any, scene: Scene, rootUrl: string): void;
  20231. }
  20232. }
  20233. declare module BABYLON {
  20234. /**
  20235. * @hidden
  20236. */
  20237. export interface IMaterialAnisotropicDefines {
  20238. ANISOTROPIC: boolean;
  20239. ANISOTROPIC_TEXTURE: boolean;
  20240. ANISOTROPIC_TEXTUREDIRECTUV: number;
  20241. MAINUV1: boolean;
  20242. _areTexturesDirty: boolean;
  20243. _needUVs: boolean;
  20244. }
  20245. /**
  20246. * Define the code related to the anisotropic parameters of the pbr material.
  20247. */
  20248. export class PBRAnisotropicConfiguration {
  20249. private _isEnabled;
  20250. /**
  20251. * Defines if the anisotropy is enabled in the material.
  20252. */
  20253. isEnabled: boolean;
  20254. /**
  20255. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  20256. */
  20257. intensity: number;
  20258. /**
  20259. * Defines if the effect is along the tangents, bitangents or in between.
  20260. * By default, the effect is "strectching" the highlights along the tangents.
  20261. */
  20262. direction: Vector2;
  20263. private _texture;
  20264. /**
  20265. * Stores the anisotropy values in a texture.
  20266. * rg is direction (like normal from -1 to 1)
  20267. * b is a intensity
  20268. */
  20269. texture: Nullable<BaseTexture>;
  20270. /** @hidden */
  20271. private _internalMarkAllSubMeshesAsTexturesDirty;
  20272. /** @hidden */
  20273. _markAllSubMeshesAsTexturesDirty(): void;
  20274. /**
  20275. * Instantiate a new istance of anisotropy configuration.
  20276. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20277. */
  20278. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20279. /**
  20280. * Specifies that the submesh is ready to be used.
  20281. * @param defines the list of "defines" to update.
  20282. * @param scene defines the scene the material belongs to.
  20283. * @returns - boolean indicating that the submesh is ready or not.
  20284. */
  20285. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  20286. /**
  20287. * Checks to see if a texture is used in the material.
  20288. * @param defines the list of "defines" to update.
  20289. * @param mesh the mesh we are preparing the defines for.
  20290. * @param scene defines the scene the material belongs to.
  20291. */
  20292. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  20293. /**
  20294. * Binds the material data.
  20295. * @param uniformBuffer defines the Uniform buffer to fill in.
  20296. * @param scene defines the scene the material belongs to.
  20297. * @param isFrozen defines wether the material is frozen or not.
  20298. */
  20299. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  20300. /**
  20301. * Checks to see if a texture is used in the material.
  20302. * @param texture - Base texture to use.
  20303. * @returns - Boolean specifying if a texture is used in the material.
  20304. */
  20305. hasTexture(texture: BaseTexture): boolean;
  20306. /**
  20307. * Returns an array of the actively used textures.
  20308. * @param activeTextures Array of BaseTextures
  20309. */
  20310. getActiveTextures(activeTextures: BaseTexture[]): void;
  20311. /**
  20312. * Returns the animatable textures.
  20313. * @param animatables Array of animatable textures.
  20314. */
  20315. getAnimatables(animatables: IAnimatable[]): void;
  20316. /**
  20317. * Disposes the resources of the material.
  20318. * @param forceDisposeTextures - Forces the disposal of all textures.
  20319. */
  20320. dispose(forceDisposeTextures?: boolean): void;
  20321. /**
  20322. * Get the current class name of the texture useful for serialization or dynamic coding.
  20323. * @returns "PBRAnisotropicConfiguration"
  20324. */
  20325. getClassName(): string;
  20326. /**
  20327. * Add fallbacks to the effect fallbacks list.
  20328. * @param defines defines the Base texture to use.
  20329. * @param fallbacks defines the current fallback list.
  20330. * @param currentRank defines the current fallback rank.
  20331. * @returns the new fallback rank.
  20332. */
  20333. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20334. /**
  20335. * Add the required uniforms to the current list.
  20336. * @param uniforms defines the current uniform list.
  20337. */
  20338. static AddUniforms(uniforms: string[]): void;
  20339. /**
  20340. * Add the required uniforms to the current buffer.
  20341. * @param uniformBuffer defines the current uniform buffer.
  20342. */
  20343. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20344. /**
  20345. * Add the required samplers to the current list.
  20346. * @param samplers defines the current sampler list.
  20347. */
  20348. static AddSamplers(samplers: string[]): void;
  20349. /**
  20350. * Makes a duplicate of the current configuration into another one.
  20351. * @param anisotropicConfiguration define the config where to copy the info
  20352. */
  20353. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  20354. /**
  20355. * Serializes this anisotropy configuration.
  20356. * @returns - An object with the serialized config.
  20357. */
  20358. serialize(): any;
  20359. /**
  20360. * Parses a anisotropy Configuration from a serialized object.
  20361. * @param source - Serialized object.
  20362. * @param scene Defines the scene we are parsing for
  20363. * @param rootUrl Defines the rootUrl to load from
  20364. */
  20365. parse(source: any, scene: Scene, rootUrl: string): void;
  20366. }
  20367. }
  20368. declare module BABYLON {
  20369. /**
  20370. * @hidden
  20371. */
  20372. export interface IMaterialBRDFDefines {
  20373. BRDF_V_HEIGHT_CORRELATED: boolean;
  20374. MS_BRDF_ENERGY_CONSERVATION: boolean;
  20375. SPHERICAL_HARMONICS: boolean;
  20376. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  20377. /** @hidden */
  20378. _areMiscDirty: boolean;
  20379. }
  20380. /**
  20381. * Define the code related to the BRDF parameters of the pbr material.
  20382. */
  20383. export class PBRBRDFConfiguration {
  20384. /**
  20385. * Default value used for the energy conservation.
  20386. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20387. */
  20388. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  20389. /**
  20390. * Default value used for the Smith Visibility Height Correlated mode.
  20391. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  20392. */
  20393. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  20394. /**
  20395. * Default value used for the IBL diffuse part.
  20396. * This can help switching back to the polynomials mode globally which is a tiny bit
  20397. * less GPU intensive at the drawback of a lower quality.
  20398. */
  20399. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  20400. /**
  20401. * Default value used for activating energy conservation for the specular workflow.
  20402. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20403. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20404. */
  20405. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  20406. private _useEnergyConservation;
  20407. /**
  20408. * Defines if the material uses energy conservation.
  20409. */
  20410. useEnergyConservation: boolean;
  20411. private _useSmithVisibilityHeightCorrelated;
  20412. /**
  20413. * LEGACY Mode set to false
  20414. * Defines if the material uses height smith correlated visibility term.
  20415. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  20416. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  20417. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  20418. * Not relying on height correlated will also disable energy conservation.
  20419. */
  20420. useSmithVisibilityHeightCorrelated: boolean;
  20421. private _useSphericalHarmonics;
  20422. /**
  20423. * LEGACY Mode set to false
  20424. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  20425. * diffuse part of the IBL.
  20426. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  20427. * to the ground truth.
  20428. */
  20429. useSphericalHarmonics: boolean;
  20430. private _useSpecularGlossinessInputEnergyConservation;
  20431. /**
  20432. * Defines if the material uses energy conservation, when the specular workflow is active.
  20433. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  20434. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  20435. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  20436. */
  20437. useSpecularGlossinessInputEnergyConservation: boolean;
  20438. /** @hidden */
  20439. private _internalMarkAllSubMeshesAsMiscDirty;
  20440. /** @hidden */
  20441. _markAllSubMeshesAsMiscDirty(): void;
  20442. /**
  20443. * Instantiate a new istance of clear coat configuration.
  20444. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  20445. */
  20446. constructor(markAllSubMeshesAsMiscDirty: () => void);
  20447. /**
  20448. * Checks to see if a texture is used in the material.
  20449. * @param defines the list of "defines" to update.
  20450. */
  20451. prepareDefines(defines: IMaterialBRDFDefines): void;
  20452. /**
  20453. * Get the current class name of the texture useful for serialization or dynamic coding.
  20454. * @returns "PBRClearCoatConfiguration"
  20455. */
  20456. getClassName(): string;
  20457. /**
  20458. * Makes a duplicate of the current configuration into another one.
  20459. * @param brdfConfiguration define the config where to copy the info
  20460. */
  20461. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  20462. /**
  20463. * Serializes this BRDF configuration.
  20464. * @returns - An object with the serialized config.
  20465. */
  20466. serialize(): any;
  20467. /**
  20468. * Parses a anisotropy Configuration from a serialized object.
  20469. * @param source - Serialized object.
  20470. * @param scene Defines the scene we are parsing for
  20471. * @param rootUrl Defines the rootUrl to load from
  20472. */
  20473. parse(source: any, scene: Scene, rootUrl: string): void;
  20474. }
  20475. }
  20476. declare module BABYLON {
  20477. /**
  20478. * @hidden
  20479. */
  20480. export interface IMaterialSheenDefines {
  20481. SHEEN: boolean;
  20482. SHEEN_TEXTURE: boolean;
  20483. SHEEN_TEXTURE_ROUGHNESS: boolean;
  20484. SHEEN_TEXTUREDIRECTUV: number;
  20485. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  20486. SHEEN_LINKWITHALBEDO: boolean;
  20487. SHEEN_ROUGHNESS: boolean;
  20488. SHEEN_ALBEDOSCALING: boolean;
  20489. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  20490. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  20491. /** @hidden */
  20492. _areTexturesDirty: boolean;
  20493. }
  20494. /**
  20495. * Define the code related to the Sheen parameters of the pbr material.
  20496. */
  20497. export class PBRSheenConfiguration {
  20498. private _isEnabled;
  20499. /**
  20500. * Defines if the material uses sheen.
  20501. */
  20502. isEnabled: boolean;
  20503. private _linkSheenWithAlbedo;
  20504. /**
  20505. * Defines if the sheen is linked to the sheen color.
  20506. */
  20507. linkSheenWithAlbedo: boolean;
  20508. /**
  20509. * Defines the sheen intensity.
  20510. */
  20511. intensity: number;
  20512. /**
  20513. * Defines the sheen color.
  20514. */
  20515. color: Color3;
  20516. private _texture;
  20517. /**
  20518. * Stores the sheen tint values in a texture.
  20519. * rgb is tint
  20520. * 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)
  20521. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  20522. */
  20523. texture: Nullable<BaseTexture>;
  20524. private _useRoughnessFromMainTexture;
  20525. /**
  20526. * Indicates that the alpha channel of the texture property will be used for roughness.
  20527. * Has no effect if the roughness (and texture!) property is not defined
  20528. */
  20529. useRoughnessFromMainTexture: boolean;
  20530. private _roughness;
  20531. /**
  20532. * Defines the sheen roughness.
  20533. * It is not taken into account if linkSheenWithAlbedo is true.
  20534. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  20535. */
  20536. roughness: Nullable<number>;
  20537. private _textureRoughness;
  20538. /**
  20539. * Stores the sheen roughness in a texture.
  20540. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  20541. */
  20542. textureRoughness: Nullable<BaseTexture>;
  20543. private _albedoScaling;
  20544. /**
  20545. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  20546. * It allows the strength of the sheen effect to not depend on the base color of the material,
  20547. * making it easier to setup and tweak the effect
  20548. */
  20549. albedoScaling: boolean;
  20550. /** @hidden */
  20551. private _internalMarkAllSubMeshesAsTexturesDirty;
  20552. /** @hidden */
  20553. _markAllSubMeshesAsTexturesDirty(): void;
  20554. /**
  20555. * Instantiate a new istance of clear coat configuration.
  20556. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20557. */
  20558. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  20559. /**
  20560. * Specifies that the submesh is ready to be used.
  20561. * @param defines the list of "defines" to update.
  20562. * @param scene defines the scene the material belongs to.
  20563. * @returns - boolean indicating that the submesh is ready or not.
  20564. */
  20565. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  20566. /**
  20567. * Checks to see if a texture is used in the material.
  20568. * @param defines the list of "defines" to update.
  20569. * @param scene defines the scene the material belongs to.
  20570. */
  20571. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  20572. /**
  20573. * Binds the material data.
  20574. * @param uniformBuffer defines the Uniform buffer to fill in.
  20575. * @param scene defines the scene the material belongs to.
  20576. * @param isFrozen defines wether the material is frozen or not.
  20577. * @param subMesh the submesh to bind data for
  20578. */
  20579. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  20580. /**
  20581. * Checks to see if a texture is used in the material.
  20582. * @param texture - Base texture to use.
  20583. * @returns - Boolean specifying if a texture is used in the material.
  20584. */
  20585. hasTexture(texture: BaseTexture): boolean;
  20586. /**
  20587. * Returns an array of the actively used textures.
  20588. * @param activeTextures Array of BaseTextures
  20589. */
  20590. getActiveTextures(activeTextures: BaseTexture[]): void;
  20591. /**
  20592. * Returns the animatable textures.
  20593. * @param animatables Array of animatable textures.
  20594. */
  20595. getAnimatables(animatables: IAnimatable[]): void;
  20596. /**
  20597. * Disposes the resources of the material.
  20598. * @param forceDisposeTextures - Forces the disposal of all textures.
  20599. */
  20600. dispose(forceDisposeTextures?: boolean): void;
  20601. /**
  20602. * Get the current class name of the texture useful for serialization or dynamic coding.
  20603. * @returns "PBRSheenConfiguration"
  20604. */
  20605. getClassName(): string;
  20606. /**
  20607. * Add fallbacks to the effect fallbacks list.
  20608. * @param defines defines the Base texture to use.
  20609. * @param fallbacks defines the current fallback list.
  20610. * @param currentRank defines the current fallback rank.
  20611. * @returns the new fallback rank.
  20612. */
  20613. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20614. /**
  20615. * Add the required uniforms to the current list.
  20616. * @param uniforms defines the current uniform list.
  20617. */
  20618. static AddUniforms(uniforms: string[]): void;
  20619. /**
  20620. * Add the required uniforms to the current buffer.
  20621. * @param uniformBuffer defines the current uniform buffer.
  20622. */
  20623. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20624. /**
  20625. * Add the required samplers to the current list.
  20626. * @param samplers defines the current sampler list.
  20627. */
  20628. static AddSamplers(samplers: string[]): void;
  20629. /**
  20630. * Makes a duplicate of the current configuration into another one.
  20631. * @param sheenConfiguration define the config where to copy the info
  20632. */
  20633. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  20634. /**
  20635. * Serializes this BRDF configuration.
  20636. * @returns - An object with the serialized config.
  20637. */
  20638. serialize(): any;
  20639. /**
  20640. * Parses a anisotropy Configuration from a serialized object.
  20641. * @param source - Serialized object.
  20642. * @param scene Defines the scene we are parsing for
  20643. * @param rootUrl Defines the rootUrl to load from
  20644. */
  20645. parse(source: any, scene: Scene, rootUrl: string): void;
  20646. }
  20647. }
  20648. declare module BABYLON {
  20649. /**
  20650. * @hidden
  20651. */
  20652. export interface IMaterialSubSurfaceDefines {
  20653. SUBSURFACE: boolean;
  20654. SS_REFRACTION: boolean;
  20655. SS_TRANSLUCENCY: boolean;
  20656. SS_SCATTERING: boolean;
  20657. SS_THICKNESSANDMASK_TEXTURE: boolean;
  20658. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  20659. SS_REFRACTIONMAP_3D: boolean;
  20660. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  20661. SS_LODINREFRACTIONALPHA: boolean;
  20662. SS_GAMMAREFRACTION: boolean;
  20663. SS_RGBDREFRACTION: boolean;
  20664. SS_LINEARSPECULARREFRACTION: boolean;
  20665. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  20666. SS_ALBEDOFORREFRACTIONTINT: boolean;
  20667. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  20668. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  20669. /** @hidden */
  20670. _areTexturesDirty: boolean;
  20671. }
  20672. /**
  20673. * Define the code related to the sub surface parameters of the pbr material.
  20674. */
  20675. export class PBRSubSurfaceConfiguration {
  20676. private _isRefractionEnabled;
  20677. /**
  20678. * Defines if the refraction is enabled in the material.
  20679. */
  20680. isRefractionEnabled: boolean;
  20681. private _isTranslucencyEnabled;
  20682. /**
  20683. * Defines if the translucency is enabled in the material.
  20684. */
  20685. isTranslucencyEnabled: boolean;
  20686. private _isScatteringEnabled;
  20687. /**
  20688. * Defines if the sub surface scattering is enabled in the material.
  20689. */
  20690. isScatteringEnabled: boolean;
  20691. private _scatteringDiffusionProfileIndex;
  20692. /**
  20693. * Diffusion profile for subsurface scattering.
  20694. * Useful for better scattering in the skins or foliages.
  20695. */
  20696. get scatteringDiffusionProfile(): Nullable<Color3>;
  20697. set scatteringDiffusionProfile(c: Nullable<Color3>);
  20698. /**
  20699. * Defines the refraction intensity of the material.
  20700. * The refraction when enabled replaces the Diffuse part of the material.
  20701. * The intensity helps transitionning between diffuse and refraction.
  20702. */
  20703. refractionIntensity: number;
  20704. /**
  20705. * Defines the translucency intensity of the material.
  20706. * When translucency has been enabled, this defines how much of the "translucency"
  20707. * is addded to the diffuse part of the material.
  20708. */
  20709. translucencyIntensity: number;
  20710. /**
  20711. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  20712. */
  20713. useAlbedoToTintRefraction: boolean;
  20714. private _thicknessTexture;
  20715. /**
  20716. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  20717. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  20718. * 0 would mean minimumThickness
  20719. * 1 would mean maximumThickness
  20720. * The other channels might be use as a mask to vary the different effects intensity.
  20721. */
  20722. thicknessTexture: Nullable<BaseTexture>;
  20723. private _refractionTexture;
  20724. /**
  20725. * Defines the texture to use for refraction.
  20726. */
  20727. refractionTexture: Nullable<BaseTexture>;
  20728. private _indexOfRefraction;
  20729. /**
  20730. * Index of refraction of the material base layer.
  20731. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20732. *
  20733. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  20734. *
  20735. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  20736. */
  20737. indexOfRefraction: number;
  20738. private _volumeIndexOfRefraction;
  20739. /**
  20740. * Index of refraction of the material's volume.
  20741. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  20742. *
  20743. * This ONLY impacts refraction. If not provided or given a non-valid value,
  20744. * the volume will use the same IOR as the surface.
  20745. */
  20746. get volumeIndexOfRefraction(): number;
  20747. set volumeIndexOfRefraction(value: number);
  20748. private _invertRefractionY;
  20749. /**
  20750. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  20751. */
  20752. invertRefractionY: boolean;
  20753. private _linkRefractionWithTransparency;
  20754. /**
  20755. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20756. * Materials half opaque for instance using refraction could benefit from this control.
  20757. */
  20758. linkRefractionWithTransparency: boolean;
  20759. /**
  20760. * Defines the minimum thickness stored in the thickness map.
  20761. * If no thickness map is defined, this value will be used to simulate thickness.
  20762. */
  20763. minimumThickness: number;
  20764. /**
  20765. * Defines the maximum thickness stored in the thickness map.
  20766. */
  20767. maximumThickness: number;
  20768. /**
  20769. * Defines the volume tint of the material.
  20770. * This is used for both translucency and scattering.
  20771. */
  20772. tintColor: Color3;
  20773. /**
  20774. * Defines the distance at which the tint color should be found in the media.
  20775. * This is used for refraction only.
  20776. */
  20777. tintColorAtDistance: number;
  20778. /**
  20779. * Defines how far each channel transmit through the media.
  20780. * It is defined as a color to simplify it selection.
  20781. */
  20782. diffusionDistance: Color3;
  20783. private _useMaskFromThicknessTexture;
  20784. /**
  20785. * Stores the intensity of the different subsurface effects in the thickness texture.
  20786. * * the green channel is the translucency intensity.
  20787. * * the blue channel is the scattering intensity.
  20788. * * the alpha channel is the refraction intensity.
  20789. */
  20790. useMaskFromThicknessTexture: boolean;
  20791. private _scene;
  20792. private _useMaskFromThicknessTextureGltf;
  20793. /**
  20794. * Stores the intensity of the different subsurface effects in the thickness texture. This variation
  20795. * matches the channel-packing that is used by glTF.
  20796. * * the red channel is the transmission/translucency intensity.
  20797. * * the green channel is the thickness.
  20798. */
  20799. useMaskFromThicknessTextureGltf: boolean;
  20800. /** @hidden */
  20801. private _internalMarkAllSubMeshesAsTexturesDirty;
  20802. private _internalMarkScenePrePassDirty;
  20803. /** @hidden */
  20804. _markAllSubMeshesAsTexturesDirty(): void;
  20805. /** @hidden */
  20806. _markScenePrePassDirty(): void;
  20807. /**
  20808. * Instantiate a new istance of sub surface configuration.
  20809. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  20810. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  20811. * @param scene The scene
  20812. */
  20813. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  20814. /**
  20815. * Gets wehter the submesh is ready to be used or not.
  20816. * @param defines the list of "defines" to update.
  20817. * @param scene defines the scene the material belongs to.
  20818. * @returns - boolean indicating that the submesh is ready or not.
  20819. */
  20820. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  20821. /**
  20822. * Checks to see if a texture is used in the material.
  20823. * @param defines the list of "defines" to update.
  20824. * @param scene defines the scene to the material belongs to.
  20825. */
  20826. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  20827. /**
  20828. * Binds the material data.
  20829. * @param uniformBuffer defines the Uniform buffer to fill in.
  20830. * @param scene defines the scene the material belongs to.
  20831. * @param engine defines the engine the material belongs to.
  20832. * @param isFrozen defines whether the material is frozen or not.
  20833. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  20834. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  20835. */
  20836. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  20837. /**
  20838. * Unbinds the material from the mesh.
  20839. * @param activeEffect defines the effect that should be unbound from.
  20840. * @returns true if unbound, otherwise false
  20841. */
  20842. unbind(activeEffect: Effect): boolean;
  20843. /**
  20844. * Returns the texture used for refraction or null if none is used.
  20845. * @param scene defines the scene the material belongs to.
  20846. * @returns - Refraction texture if present. If no refraction texture and refraction
  20847. * is linked with transparency, returns environment texture. Otherwise, returns null.
  20848. */
  20849. private _getRefractionTexture;
  20850. /**
  20851. * Returns true if alpha blending should be disabled.
  20852. */
  20853. get disableAlphaBlending(): boolean;
  20854. /**
  20855. * Fills the list of render target textures.
  20856. * @param renderTargets the list of render targets to update
  20857. */
  20858. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  20859. /**
  20860. * Checks to see if a texture is used in the material.
  20861. * @param texture - Base texture to use.
  20862. * @returns - Boolean specifying if a texture is used in the material.
  20863. */
  20864. hasTexture(texture: BaseTexture): boolean;
  20865. /**
  20866. * Gets a boolean indicating that current material needs to register RTT
  20867. * @returns true if this uses a render target otherwise false.
  20868. */
  20869. hasRenderTargetTextures(): boolean;
  20870. /**
  20871. * Returns an array of the actively used textures.
  20872. * @param activeTextures Array of BaseTextures
  20873. */
  20874. getActiveTextures(activeTextures: BaseTexture[]): void;
  20875. /**
  20876. * Returns the animatable textures.
  20877. * @param animatables Array of animatable textures.
  20878. */
  20879. getAnimatables(animatables: IAnimatable[]): void;
  20880. /**
  20881. * Disposes the resources of the material.
  20882. * @param forceDisposeTextures - Forces the disposal of all textures.
  20883. */
  20884. dispose(forceDisposeTextures?: boolean): void;
  20885. /**
  20886. * Get the current class name of the texture useful for serialization or dynamic coding.
  20887. * @returns "PBRSubSurfaceConfiguration"
  20888. */
  20889. getClassName(): string;
  20890. /**
  20891. * Add fallbacks to the effect fallbacks list.
  20892. * @param defines defines the Base texture to use.
  20893. * @param fallbacks defines the current fallback list.
  20894. * @param currentRank defines the current fallback rank.
  20895. * @returns the new fallback rank.
  20896. */
  20897. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  20898. /**
  20899. * Add the required uniforms to the current list.
  20900. * @param uniforms defines the current uniform list.
  20901. */
  20902. static AddUniforms(uniforms: string[]): void;
  20903. /**
  20904. * Add the required samplers to the current list.
  20905. * @param samplers defines the current sampler list.
  20906. */
  20907. static AddSamplers(samplers: string[]): void;
  20908. /**
  20909. * Add the required uniforms to the current buffer.
  20910. * @param uniformBuffer defines the current uniform buffer.
  20911. */
  20912. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  20913. /**
  20914. * Makes a duplicate of the current configuration into another one.
  20915. * @param configuration define the config where to copy the info
  20916. */
  20917. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  20918. /**
  20919. * Serializes this Sub Surface configuration.
  20920. * @returns - An object with the serialized config.
  20921. */
  20922. serialize(): any;
  20923. /**
  20924. * Parses a anisotropy Configuration from a serialized object.
  20925. * @param source - Serialized object.
  20926. * @param scene Defines the scene we are parsing for
  20927. * @param rootUrl Defines the rootUrl to load from
  20928. */
  20929. parse(source: any, scene: Scene, rootUrl: string): void;
  20930. }
  20931. }
  20932. declare module BABYLON {
  20933. /**
  20934. * Class representing spherical harmonics coefficients to the 3rd degree
  20935. */
  20936. export class SphericalHarmonics {
  20937. /**
  20938. * Defines whether or not the harmonics have been prescaled for rendering.
  20939. */
  20940. preScaled: boolean;
  20941. /**
  20942. * The l0,0 coefficients of the spherical harmonics
  20943. */
  20944. l00: Vector3;
  20945. /**
  20946. * The l1,-1 coefficients of the spherical harmonics
  20947. */
  20948. l1_1: Vector3;
  20949. /**
  20950. * The l1,0 coefficients of the spherical harmonics
  20951. */
  20952. l10: Vector3;
  20953. /**
  20954. * The l1,1 coefficients of the spherical harmonics
  20955. */
  20956. l11: Vector3;
  20957. /**
  20958. * The l2,-2 coefficients of the spherical harmonics
  20959. */
  20960. l2_2: Vector3;
  20961. /**
  20962. * The l2,-1 coefficients of the spherical harmonics
  20963. */
  20964. l2_1: Vector3;
  20965. /**
  20966. * The l2,0 coefficients of the spherical harmonics
  20967. */
  20968. l20: Vector3;
  20969. /**
  20970. * The l2,1 coefficients of the spherical harmonics
  20971. */
  20972. l21: Vector3;
  20973. /**
  20974. * The l2,2 coefficients of the spherical harmonics
  20975. */
  20976. l22: Vector3;
  20977. /**
  20978. * Adds a light to the spherical harmonics
  20979. * @param direction the direction of the light
  20980. * @param color the color of the light
  20981. * @param deltaSolidAngle the delta solid angle of the light
  20982. */
  20983. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  20984. /**
  20985. * Scales the spherical harmonics by the given amount
  20986. * @param scale the amount to scale
  20987. */
  20988. scaleInPlace(scale: number): void;
  20989. /**
  20990. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  20991. *
  20992. * ```
  20993. * E_lm = A_l * L_lm
  20994. * ```
  20995. *
  20996. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  20997. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  20998. * the scaling factors are given in equation 9.
  20999. */
  21000. convertIncidentRadianceToIrradiance(): void;
  21001. /**
  21002. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  21003. *
  21004. * ```
  21005. * L = (1/pi) * E * rho
  21006. * ```
  21007. *
  21008. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  21009. */
  21010. convertIrradianceToLambertianRadiance(): void;
  21011. /**
  21012. * Integrates the reconstruction coefficients directly in to the SH preventing further
  21013. * required operations at run time.
  21014. *
  21015. * This is simply done by scaling back the SH with Ylm constants parameter.
  21016. * The trigonometric part being applied by the shader at run time.
  21017. */
  21018. preScaleForRendering(): void;
  21019. /**
  21020. * Constructs a spherical harmonics from an array.
  21021. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  21022. * @returns the spherical harmonics
  21023. */
  21024. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  21025. /**
  21026. * Gets the spherical harmonics from polynomial
  21027. * @param polynomial the spherical polynomial
  21028. * @returns the spherical harmonics
  21029. */
  21030. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  21031. }
  21032. /**
  21033. * Class representing spherical polynomial coefficients to the 3rd degree
  21034. */
  21035. export class SphericalPolynomial {
  21036. private _harmonics;
  21037. /**
  21038. * The spherical harmonics used to create the polynomials.
  21039. */
  21040. get preScaledHarmonics(): SphericalHarmonics;
  21041. /**
  21042. * The x coefficients of the spherical polynomial
  21043. */
  21044. x: Vector3;
  21045. /**
  21046. * The y coefficients of the spherical polynomial
  21047. */
  21048. y: Vector3;
  21049. /**
  21050. * The z coefficients of the spherical polynomial
  21051. */
  21052. z: Vector3;
  21053. /**
  21054. * The xx coefficients of the spherical polynomial
  21055. */
  21056. xx: Vector3;
  21057. /**
  21058. * The yy coefficients of the spherical polynomial
  21059. */
  21060. yy: Vector3;
  21061. /**
  21062. * The zz coefficients of the spherical polynomial
  21063. */
  21064. zz: Vector3;
  21065. /**
  21066. * The xy coefficients of the spherical polynomial
  21067. */
  21068. xy: Vector3;
  21069. /**
  21070. * The yz coefficients of the spherical polynomial
  21071. */
  21072. yz: Vector3;
  21073. /**
  21074. * The zx coefficients of the spherical polynomial
  21075. */
  21076. zx: Vector3;
  21077. /**
  21078. * Adds an ambient color to the spherical polynomial
  21079. * @param color the color to add
  21080. */
  21081. addAmbient(color: Color3): void;
  21082. /**
  21083. * Scales the spherical polynomial by the given amount
  21084. * @param scale the amount to scale
  21085. */
  21086. scaleInPlace(scale: number): void;
  21087. /**
  21088. * Gets the spherical polynomial from harmonics
  21089. * @param harmonics the spherical harmonics
  21090. * @returns the spherical polynomial
  21091. */
  21092. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  21093. /**
  21094. * Constructs a spherical polynomial from an array.
  21095. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  21096. * @returns the spherical polynomial
  21097. */
  21098. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  21099. }
  21100. }
  21101. declare module BABYLON {
  21102. /**
  21103. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  21104. */
  21105. export interface CubeMapInfo {
  21106. /**
  21107. * The pixel array for the front face.
  21108. * This is stored in format, left to right, up to down format.
  21109. */
  21110. front: Nullable<ArrayBufferView>;
  21111. /**
  21112. * The pixel array for the back face.
  21113. * This is stored in format, left to right, up to down format.
  21114. */
  21115. back: Nullable<ArrayBufferView>;
  21116. /**
  21117. * The pixel array for the left face.
  21118. * This is stored in format, left to right, up to down format.
  21119. */
  21120. left: Nullable<ArrayBufferView>;
  21121. /**
  21122. * The pixel array for the right face.
  21123. * This is stored in format, left to right, up to down format.
  21124. */
  21125. right: Nullable<ArrayBufferView>;
  21126. /**
  21127. * The pixel array for the up face.
  21128. * This is stored in format, left to right, up to down format.
  21129. */
  21130. up: Nullable<ArrayBufferView>;
  21131. /**
  21132. * The pixel array for the down face.
  21133. * This is stored in format, left to right, up to down format.
  21134. */
  21135. down: Nullable<ArrayBufferView>;
  21136. /**
  21137. * The size of the cubemap stored.
  21138. *
  21139. * Each faces will be size * size pixels.
  21140. */
  21141. size: number;
  21142. /**
  21143. * The format of the texture.
  21144. *
  21145. * RGBA, RGB.
  21146. */
  21147. format: number;
  21148. /**
  21149. * The type of the texture data.
  21150. *
  21151. * UNSIGNED_INT, FLOAT.
  21152. */
  21153. type: number;
  21154. /**
  21155. * Specifies whether the texture is in gamma space.
  21156. */
  21157. gammaSpace: boolean;
  21158. }
  21159. /**
  21160. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  21161. */
  21162. export class PanoramaToCubeMapTools {
  21163. private static FACE_LEFT;
  21164. private static FACE_RIGHT;
  21165. private static FACE_FRONT;
  21166. private static FACE_BACK;
  21167. private static FACE_DOWN;
  21168. private static FACE_UP;
  21169. /**
  21170. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  21171. *
  21172. * @param float32Array The source data.
  21173. * @param inputWidth The width of the input panorama.
  21174. * @param inputHeight The height of the input panorama.
  21175. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  21176. * @return The cubemap data
  21177. */
  21178. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  21179. private static CreateCubemapTexture;
  21180. private static CalcProjectionSpherical;
  21181. }
  21182. }
  21183. declare module BABYLON {
  21184. /**
  21185. * Helper class dealing with the extraction of spherical polynomial dataArray
  21186. * from a cube map.
  21187. */
  21188. export class CubeMapToSphericalPolynomialTools {
  21189. private static FileFaces;
  21190. /**
  21191. * Converts a texture to the according Spherical Polynomial data.
  21192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21193. *
  21194. * @param texture The texture to extract the information from.
  21195. * @return The Spherical Polynomial data.
  21196. */
  21197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<Promise<SphericalPolynomial>>;
  21198. /**
  21199. * Converts a cubemap to the according Spherical Polynomial data.
  21200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  21201. *
  21202. * @param cubeInfo The Cube map to extract the information from.
  21203. * @return The Spherical Polynomial data.
  21204. */
  21205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  21206. }
  21207. }
  21208. declare module BABYLON {
  21209. interface BaseTexture {
  21210. /**
  21211. * Get the polynomial representation of the texture data.
  21212. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  21213. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  21214. */
  21215. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21216. }
  21217. }
  21218. declare module BABYLON {
  21219. /** @hidden */
  21220. export var pbrFragmentDeclaration: {
  21221. name: string;
  21222. shader: string;
  21223. };
  21224. }
  21225. declare module BABYLON {
  21226. /** @hidden */
  21227. export var pbrUboDeclaration: {
  21228. name: string;
  21229. shader: string;
  21230. };
  21231. }
  21232. declare module BABYLON {
  21233. /** @hidden */
  21234. export var pbrFragmentExtraDeclaration: {
  21235. name: string;
  21236. shader: string;
  21237. };
  21238. }
  21239. declare module BABYLON {
  21240. /** @hidden */
  21241. export var pbrFragmentSamplersDeclaration: {
  21242. name: string;
  21243. shader: string;
  21244. };
  21245. }
  21246. declare module BABYLON {
  21247. /** @hidden */
  21248. export var subSurfaceScatteringFunctions: {
  21249. name: string;
  21250. shader: string;
  21251. };
  21252. }
  21253. declare module BABYLON {
  21254. /** @hidden */
  21255. export var importanceSampling: {
  21256. name: string;
  21257. shader: string;
  21258. };
  21259. }
  21260. declare module BABYLON {
  21261. /** @hidden */
  21262. export var pbrHelperFunctions: {
  21263. name: string;
  21264. shader: string;
  21265. };
  21266. }
  21267. declare module BABYLON {
  21268. /** @hidden */
  21269. export var harmonicsFunctions: {
  21270. name: string;
  21271. shader: string;
  21272. };
  21273. }
  21274. declare module BABYLON {
  21275. /** @hidden */
  21276. export var pbrDirectLightingSetupFunctions: {
  21277. name: string;
  21278. shader: string;
  21279. };
  21280. }
  21281. declare module BABYLON {
  21282. /** @hidden */
  21283. export var pbrDirectLightingFalloffFunctions: {
  21284. name: string;
  21285. shader: string;
  21286. };
  21287. }
  21288. declare module BABYLON {
  21289. /** @hidden */
  21290. export var pbrBRDFFunctions: {
  21291. name: string;
  21292. shader: string;
  21293. };
  21294. }
  21295. declare module BABYLON {
  21296. /** @hidden */
  21297. export var hdrFilteringFunctions: {
  21298. name: string;
  21299. shader: string;
  21300. };
  21301. }
  21302. declare module BABYLON {
  21303. /** @hidden */
  21304. export var pbrDirectLightingFunctions: {
  21305. name: string;
  21306. shader: string;
  21307. };
  21308. }
  21309. declare module BABYLON {
  21310. /** @hidden */
  21311. export var pbrIBLFunctions: {
  21312. name: string;
  21313. shader: string;
  21314. };
  21315. }
  21316. declare module BABYLON {
  21317. /** @hidden */
  21318. export var pbrBlockAlbedoOpacity: {
  21319. name: string;
  21320. shader: string;
  21321. };
  21322. }
  21323. declare module BABYLON {
  21324. /** @hidden */
  21325. export var pbrBlockReflectivity: {
  21326. name: string;
  21327. shader: string;
  21328. };
  21329. }
  21330. declare module BABYLON {
  21331. /** @hidden */
  21332. export var pbrBlockAmbientOcclusion: {
  21333. name: string;
  21334. shader: string;
  21335. };
  21336. }
  21337. declare module BABYLON {
  21338. /** @hidden */
  21339. export var pbrBlockAlphaFresnel: {
  21340. name: string;
  21341. shader: string;
  21342. };
  21343. }
  21344. declare module BABYLON {
  21345. /** @hidden */
  21346. export var pbrBlockAnisotropic: {
  21347. name: string;
  21348. shader: string;
  21349. };
  21350. }
  21351. declare module BABYLON {
  21352. /** @hidden */
  21353. export var pbrBlockReflection: {
  21354. name: string;
  21355. shader: string;
  21356. };
  21357. }
  21358. declare module BABYLON {
  21359. /** @hidden */
  21360. export var pbrBlockSheen: {
  21361. name: string;
  21362. shader: string;
  21363. };
  21364. }
  21365. declare module BABYLON {
  21366. /** @hidden */
  21367. export var pbrBlockClearcoat: {
  21368. name: string;
  21369. shader: string;
  21370. };
  21371. }
  21372. declare module BABYLON {
  21373. /** @hidden */
  21374. export var pbrBlockSubSurface: {
  21375. name: string;
  21376. shader: string;
  21377. };
  21378. }
  21379. declare module BABYLON {
  21380. /** @hidden */
  21381. export var pbrBlockNormalGeometric: {
  21382. name: string;
  21383. shader: string;
  21384. };
  21385. }
  21386. declare module BABYLON {
  21387. /** @hidden */
  21388. export var pbrBlockNormalFinal: {
  21389. name: string;
  21390. shader: string;
  21391. };
  21392. }
  21393. declare module BABYLON {
  21394. /** @hidden */
  21395. export var pbrBlockLightmapInit: {
  21396. name: string;
  21397. shader: string;
  21398. };
  21399. }
  21400. declare module BABYLON {
  21401. /** @hidden */
  21402. export var pbrBlockGeometryInfo: {
  21403. name: string;
  21404. shader: string;
  21405. };
  21406. }
  21407. declare module BABYLON {
  21408. /** @hidden */
  21409. export var pbrBlockReflectance0: {
  21410. name: string;
  21411. shader: string;
  21412. };
  21413. }
  21414. declare module BABYLON {
  21415. /** @hidden */
  21416. export var pbrBlockReflectance: {
  21417. name: string;
  21418. shader: string;
  21419. };
  21420. }
  21421. declare module BABYLON {
  21422. /** @hidden */
  21423. export var pbrBlockDirectLighting: {
  21424. name: string;
  21425. shader: string;
  21426. };
  21427. }
  21428. declare module BABYLON {
  21429. /** @hidden */
  21430. export var pbrBlockFinalLitComponents: {
  21431. name: string;
  21432. shader: string;
  21433. };
  21434. }
  21435. declare module BABYLON {
  21436. /** @hidden */
  21437. export var pbrBlockFinalUnlitComponents: {
  21438. name: string;
  21439. shader: string;
  21440. };
  21441. }
  21442. declare module BABYLON {
  21443. /** @hidden */
  21444. export var pbrBlockFinalColorComposition: {
  21445. name: string;
  21446. shader: string;
  21447. };
  21448. }
  21449. declare module BABYLON {
  21450. /** @hidden */
  21451. export var pbrBlockImageProcessing: {
  21452. name: string;
  21453. shader: string;
  21454. };
  21455. }
  21456. declare module BABYLON {
  21457. /** @hidden */
  21458. export var pbrDebug: {
  21459. name: string;
  21460. shader: string;
  21461. };
  21462. }
  21463. declare module BABYLON {
  21464. /** @hidden */
  21465. export var pbrPixelShader: {
  21466. name: string;
  21467. shader: string;
  21468. };
  21469. }
  21470. declare module BABYLON {
  21471. /** @hidden */
  21472. export var pbrVertexDeclaration: {
  21473. name: string;
  21474. shader: string;
  21475. };
  21476. }
  21477. declare module BABYLON {
  21478. /** @hidden */
  21479. export var pbrVertexShader: {
  21480. name: string;
  21481. shader: string;
  21482. };
  21483. }
  21484. declare module BABYLON {
  21485. /**
  21486. * Manages the defines for the PBR Material.
  21487. * @hidden
  21488. */
  21489. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  21490. PBR: boolean;
  21491. NUM_SAMPLES: string;
  21492. REALTIME_FILTERING: boolean;
  21493. MAINUV1: boolean;
  21494. MAINUV2: boolean;
  21495. UV1: boolean;
  21496. UV2: boolean;
  21497. ALBEDO: boolean;
  21498. GAMMAALBEDO: boolean;
  21499. ALBEDODIRECTUV: number;
  21500. VERTEXCOLOR: boolean;
  21501. DETAIL: boolean;
  21502. DETAILDIRECTUV: number;
  21503. DETAIL_NORMALBLENDMETHOD: number;
  21504. AMBIENT: boolean;
  21505. AMBIENTDIRECTUV: number;
  21506. AMBIENTINGRAYSCALE: boolean;
  21507. OPACITY: boolean;
  21508. VERTEXALPHA: boolean;
  21509. OPACITYDIRECTUV: number;
  21510. OPACITYRGB: boolean;
  21511. ALPHATEST: boolean;
  21512. DEPTHPREPASS: boolean;
  21513. ALPHABLEND: boolean;
  21514. ALPHAFROMALBEDO: boolean;
  21515. ALPHATESTVALUE: string;
  21516. SPECULAROVERALPHA: boolean;
  21517. RADIANCEOVERALPHA: boolean;
  21518. ALPHAFRESNEL: boolean;
  21519. LINEARALPHAFRESNEL: boolean;
  21520. PREMULTIPLYALPHA: boolean;
  21521. EMISSIVE: boolean;
  21522. EMISSIVEDIRECTUV: number;
  21523. REFLECTIVITY: boolean;
  21524. REFLECTIVITYDIRECTUV: number;
  21525. SPECULARTERM: boolean;
  21526. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  21527. MICROSURFACEAUTOMATIC: boolean;
  21528. LODBASEDMICROSFURACE: boolean;
  21529. MICROSURFACEMAP: boolean;
  21530. MICROSURFACEMAPDIRECTUV: number;
  21531. METALLICWORKFLOW: boolean;
  21532. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  21533. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  21534. METALLNESSSTOREINMETALMAPBLUE: boolean;
  21535. AOSTOREINMETALMAPRED: boolean;
  21536. METALLIC_REFLECTANCE: boolean;
  21537. METALLIC_REFLECTANCEDIRECTUV: number;
  21538. ENVIRONMENTBRDF: boolean;
  21539. ENVIRONMENTBRDF_RGBD: boolean;
  21540. NORMAL: boolean;
  21541. TANGENT: boolean;
  21542. BUMP: boolean;
  21543. BUMPDIRECTUV: number;
  21544. OBJECTSPACE_NORMALMAP: boolean;
  21545. PARALLAX: boolean;
  21546. PARALLAXOCCLUSION: boolean;
  21547. NORMALXYSCALE: boolean;
  21548. LIGHTMAP: boolean;
  21549. LIGHTMAPDIRECTUV: number;
  21550. USELIGHTMAPASSHADOWMAP: boolean;
  21551. GAMMALIGHTMAP: boolean;
  21552. RGBDLIGHTMAP: boolean;
  21553. REFLECTION: boolean;
  21554. REFLECTIONMAP_3D: boolean;
  21555. REFLECTIONMAP_SPHERICAL: boolean;
  21556. REFLECTIONMAP_PLANAR: boolean;
  21557. REFLECTIONMAP_CUBIC: boolean;
  21558. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  21559. REFLECTIONMAP_PROJECTION: boolean;
  21560. REFLECTIONMAP_SKYBOX: boolean;
  21561. REFLECTIONMAP_EXPLICIT: boolean;
  21562. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  21563. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  21564. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  21565. INVERTCUBICMAP: boolean;
  21566. USESPHERICALFROMREFLECTIONMAP: boolean;
  21567. USEIRRADIANCEMAP: boolean;
  21568. SPHERICAL_HARMONICS: boolean;
  21569. USESPHERICALINVERTEX: boolean;
  21570. REFLECTIONMAP_OPPOSITEZ: boolean;
  21571. LODINREFLECTIONALPHA: boolean;
  21572. GAMMAREFLECTION: boolean;
  21573. RGBDREFLECTION: boolean;
  21574. LINEARSPECULARREFLECTION: boolean;
  21575. RADIANCEOCCLUSION: boolean;
  21576. HORIZONOCCLUSION: boolean;
  21577. INSTANCES: boolean;
  21578. THIN_INSTANCES: boolean;
  21579. PREPASS: boolean;
  21580. PREPASS_IRRADIANCE: boolean;
  21581. PREPASS_IRRADIANCE_INDEX: number;
  21582. PREPASS_ALBEDO: boolean;
  21583. PREPASS_ALBEDO_INDEX: number;
  21584. PREPASS_DEPTHNORMAL: boolean;
  21585. PREPASS_DEPTHNORMAL_INDEX: number;
  21586. PREPASS_POSITION: boolean;
  21587. PREPASS_POSITION_INDEX: number;
  21588. PREPASS_VELOCITY: boolean;
  21589. PREPASS_VELOCITY_INDEX: number;
  21590. PREPASS_REFLECTIVITY: boolean;
  21591. PREPASS_REFLECTIVITY_INDEX: number;
  21592. SCENE_MRT_COUNT: number;
  21593. NUM_BONE_INFLUENCERS: number;
  21594. BonesPerMesh: number;
  21595. BONETEXTURE: boolean;
  21596. BONES_VELOCITY_ENABLED: boolean;
  21597. NONUNIFORMSCALING: boolean;
  21598. MORPHTARGETS: boolean;
  21599. MORPHTARGETS_NORMAL: boolean;
  21600. MORPHTARGETS_TANGENT: boolean;
  21601. MORPHTARGETS_UV: boolean;
  21602. NUM_MORPH_INFLUENCERS: number;
  21603. IMAGEPROCESSING: boolean;
  21604. VIGNETTE: boolean;
  21605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  21606. VIGNETTEBLENDMODEOPAQUE: boolean;
  21607. TONEMAPPING: boolean;
  21608. TONEMAPPING_ACES: boolean;
  21609. CONTRAST: boolean;
  21610. COLORCURVES: boolean;
  21611. COLORGRADING: boolean;
  21612. COLORGRADING3D: boolean;
  21613. SAMPLER3DGREENDEPTH: boolean;
  21614. SAMPLER3DBGRMAP: boolean;
  21615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  21616. EXPOSURE: boolean;
  21617. MULTIVIEW: boolean;
  21618. USEPHYSICALLIGHTFALLOFF: boolean;
  21619. USEGLTFLIGHTFALLOFF: boolean;
  21620. TWOSIDEDLIGHTING: boolean;
  21621. SHADOWFLOAT: boolean;
  21622. CLIPPLANE: boolean;
  21623. CLIPPLANE2: boolean;
  21624. CLIPPLANE3: boolean;
  21625. CLIPPLANE4: boolean;
  21626. CLIPPLANE5: boolean;
  21627. CLIPPLANE6: boolean;
  21628. POINTSIZE: boolean;
  21629. FOG: boolean;
  21630. LOGARITHMICDEPTH: boolean;
  21631. FORCENORMALFORWARD: boolean;
  21632. SPECULARAA: boolean;
  21633. CLEARCOAT: boolean;
  21634. CLEARCOAT_DEFAULTIOR: boolean;
  21635. CLEARCOAT_TEXTURE: boolean;
  21636. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  21637. CLEARCOAT_TEXTUREDIRECTUV: number;
  21638. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  21639. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21640. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21641. CLEARCOAT_BUMP: boolean;
  21642. CLEARCOAT_BUMPDIRECTUV: number;
  21643. CLEARCOAT_REMAP_F0: boolean;
  21644. CLEARCOAT_TINT: boolean;
  21645. CLEARCOAT_TINT_TEXTURE: boolean;
  21646. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  21647. ANISOTROPIC: boolean;
  21648. ANISOTROPIC_TEXTURE: boolean;
  21649. ANISOTROPIC_TEXTUREDIRECTUV: number;
  21650. BRDF_V_HEIGHT_CORRELATED: boolean;
  21651. MS_BRDF_ENERGY_CONSERVATION: boolean;
  21652. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  21653. SHEEN: boolean;
  21654. SHEEN_TEXTURE: boolean;
  21655. SHEEN_TEXTURE_ROUGHNESS: boolean;
  21656. SHEEN_TEXTUREDIRECTUV: number;
  21657. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  21658. SHEEN_LINKWITHALBEDO: boolean;
  21659. SHEEN_ROUGHNESS: boolean;
  21660. SHEEN_ALBEDOSCALING: boolean;
  21661. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  21662. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  21663. SUBSURFACE: boolean;
  21664. SS_REFRACTION: boolean;
  21665. SS_TRANSLUCENCY: boolean;
  21666. SS_SCATTERING: boolean;
  21667. SS_THICKNESSANDMASK_TEXTURE: boolean;
  21668. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  21669. SS_REFRACTIONMAP_3D: boolean;
  21670. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  21671. SS_LODINREFRACTIONALPHA: boolean;
  21672. SS_GAMMAREFRACTION: boolean;
  21673. SS_RGBDREFRACTION: boolean;
  21674. SS_LINEARSPECULARREFRACTION: boolean;
  21675. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  21676. SS_ALBEDOFORREFRACTIONTINT: boolean;
  21677. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  21678. SS_MASK_FROM_THICKNESS_TEXTURE_GLTF: boolean;
  21679. UNLIT: boolean;
  21680. DEBUGMODE: number;
  21681. /**
  21682. * Initializes the PBR Material defines.
  21683. */
  21684. constructor();
  21685. /**
  21686. * Resets the PBR Material defines.
  21687. */
  21688. reset(): void;
  21689. }
  21690. /**
  21691. * The Physically based material base class of BJS.
  21692. *
  21693. * This offers the main features of a standard PBR material.
  21694. * For more information, please refer to the documentation :
  21695. * https://doc.babylonjs.com/how_to/physically_based_rendering
  21696. */
  21697. export abstract class PBRBaseMaterial extends PushMaterial {
  21698. /**
  21699. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  21700. */
  21701. static readonly PBRMATERIAL_OPAQUE: number;
  21702. /**
  21703. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  21704. */
  21705. static readonly PBRMATERIAL_ALPHATEST: number;
  21706. /**
  21707. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21708. */
  21709. static readonly PBRMATERIAL_ALPHABLEND: number;
  21710. /**
  21711. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  21712. * They are also discarded below the alpha cutoff threshold to improve performances.
  21713. */
  21714. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  21715. /**
  21716. * Defines the default value of how much AO map is occluding the analytical lights
  21717. * (point spot...).
  21718. */
  21719. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  21720. /**
  21721. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  21722. */
  21723. static readonly LIGHTFALLOFF_PHYSICAL: number;
  21724. /**
  21725. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  21726. * to enhance interoperability with other engines.
  21727. */
  21728. static readonly LIGHTFALLOFF_GLTF: number;
  21729. /**
  21730. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  21731. * to enhance interoperability with other materials.
  21732. */
  21733. static readonly LIGHTFALLOFF_STANDARD: number;
  21734. /**
  21735. * Intensity of the direct lights e.g. the four lights available in your scene.
  21736. * This impacts both the direct diffuse and specular highlights.
  21737. */
  21738. protected _directIntensity: number;
  21739. /**
  21740. * Intensity of the emissive part of the material.
  21741. * This helps controlling the emissive effect without modifying the emissive color.
  21742. */
  21743. protected _emissiveIntensity: number;
  21744. /**
  21745. * Intensity of the environment e.g. how much the environment will light the object
  21746. * either through harmonics for rough material or through the refelction for shiny ones.
  21747. */
  21748. protected _environmentIntensity: number;
  21749. /**
  21750. * This is a special control allowing the reduction of the specular highlights coming from the
  21751. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  21752. */
  21753. protected _specularIntensity: number;
  21754. /**
  21755. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  21756. */
  21757. private _lightingInfos;
  21758. /**
  21759. * Debug Control allowing disabling the bump map on this material.
  21760. */
  21761. protected _disableBumpMap: boolean;
  21762. /**
  21763. * AKA Diffuse Texture in standard nomenclature.
  21764. */
  21765. protected _albedoTexture: Nullable<BaseTexture>;
  21766. /**
  21767. * AKA Occlusion Texture in other nomenclature.
  21768. */
  21769. protected _ambientTexture: Nullable<BaseTexture>;
  21770. /**
  21771. * AKA Occlusion Texture Intensity in other nomenclature.
  21772. */
  21773. protected _ambientTextureStrength: number;
  21774. /**
  21775. * Defines how much the AO map is occluding the analytical lights (point spot...).
  21776. * 1 means it completely occludes it
  21777. * 0 mean it has no impact
  21778. */
  21779. protected _ambientTextureImpactOnAnalyticalLights: number;
  21780. /**
  21781. * Stores the alpha values in a texture.
  21782. */
  21783. protected _opacityTexture: Nullable<BaseTexture>;
  21784. /**
  21785. * Stores the reflection values in a texture.
  21786. */
  21787. protected _reflectionTexture: Nullable<BaseTexture>;
  21788. /**
  21789. * Stores the emissive values in a texture.
  21790. */
  21791. protected _emissiveTexture: Nullable<BaseTexture>;
  21792. /**
  21793. * AKA Specular texture in other nomenclature.
  21794. */
  21795. protected _reflectivityTexture: Nullable<BaseTexture>;
  21796. /**
  21797. * Used to switch from specular/glossiness to metallic/roughness workflow.
  21798. */
  21799. protected _metallicTexture: Nullable<BaseTexture>;
  21800. /**
  21801. * Specifies the metallic scalar of the metallic/roughness workflow.
  21802. * Can also be used to scale the metalness values of the metallic texture.
  21803. */
  21804. protected _metallic: Nullable<number>;
  21805. /**
  21806. * Specifies the roughness scalar of the metallic/roughness workflow.
  21807. * Can also be used to scale the roughness values of the metallic texture.
  21808. */
  21809. protected _roughness: Nullable<number>;
  21810. /**
  21811. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  21812. * By default the indexOfrefraction is used to compute F0;
  21813. *
  21814. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  21815. *
  21816. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  21817. * F90 = metallicReflectanceColor;
  21818. */
  21819. protected _metallicF0Factor: number;
  21820. /**
  21821. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  21822. * By default the F90 is always 1;
  21823. *
  21824. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  21825. *
  21826. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  21827. * F90 = metallicReflectanceColor;
  21828. */
  21829. protected _metallicReflectanceColor: Color3;
  21830. /**
  21831. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  21832. * This is multiply against the scalar values defined in the material.
  21833. */
  21834. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  21835. /**
  21836. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  21837. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  21838. */
  21839. protected _microSurfaceTexture: Nullable<BaseTexture>;
  21840. /**
  21841. * Stores surface normal data used to displace a mesh in a texture.
  21842. */
  21843. protected _bumpTexture: Nullable<BaseTexture>;
  21844. /**
  21845. * Stores the pre-calculated light information of a mesh in a texture.
  21846. */
  21847. protected _lightmapTexture: Nullable<BaseTexture>;
  21848. /**
  21849. * The color of a material in ambient lighting.
  21850. */
  21851. protected _ambientColor: Color3;
  21852. /**
  21853. * AKA Diffuse Color in other nomenclature.
  21854. */
  21855. protected _albedoColor: Color3;
  21856. /**
  21857. * AKA Specular Color in other nomenclature.
  21858. */
  21859. protected _reflectivityColor: Color3;
  21860. /**
  21861. * The color applied when light is reflected from a material.
  21862. */
  21863. protected _reflectionColor: Color3;
  21864. /**
  21865. * The color applied when light is emitted from a material.
  21866. */
  21867. protected _emissiveColor: Color3;
  21868. /**
  21869. * AKA Glossiness in other nomenclature.
  21870. */
  21871. protected _microSurface: number;
  21872. /**
  21873. * Specifies that the material will use the light map as a show map.
  21874. */
  21875. protected _useLightmapAsShadowmap: boolean;
  21876. /**
  21877. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  21878. * makes the reflect vector face the model (under horizon).
  21879. */
  21880. protected _useHorizonOcclusion: boolean;
  21881. /**
  21882. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  21883. * too much the area relying on ambient texture to define their ambient occlusion.
  21884. */
  21885. protected _useRadianceOcclusion: boolean;
  21886. /**
  21887. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  21888. */
  21889. protected _useAlphaFromAlbedoTexture: boolean;
  21890. /**
  21891. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  21892. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  21893. */
  21894. protected _useSpecularOverAlpha: boolean;
  21895. /**
  21896. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  21897. */
  21898. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  21899. /**
  21900. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  21901. */
  21902. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  21903. /**
  21904. * Specifies if the metallic texture contains the roughness information in its green channel.
  21905. */
  21906. protected _useRoughnessFromMetallicTextureGreen: boolean;
  21907. /**
  21908. * Specifies if the metallic texture contains the metallness information in its blue channel.
  21909. */
  21910. protected _useMetallnessFromMetallicTextureBlue: boolean;
  21911. /**
  21912. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  21913. */
  21914. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  21915. /**
  21916. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  21917. */
  21918. protected _useAmbientInGrayScale: boolean;
  21919. /**
  21920. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  21921. * The material will try to infer what glossiness each pixel should be.
  21922. */
  21923. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  21924. /**
  21925. * Defines the falloff type used in this material.
  21926. * It by default is Physical.
  21927. */
  21928. protected _lightFalloff: number;
  21929. /**
  21930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  21931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  21932. */
  21933. protected _useRadianceOverAlpha: boolean;
  21934. /**
  21935. * Allows using an object space normal map (instead of tangent space).
  21936. */
  21937. protected _useObjectSpaceNormalMap: boolean;
  21938. /**
  21939. * Allows using the bump map in parallax mode.
  21940. */
  21941. protected _useParallax: boolean;
  21942. /**
  21943. * Allows using the bump map in parallax occlusion mode.
  21944. */
  21945. protected _useParallaxOcclusion: boolean;
  21946. /**
  21947. * Controls the scale bias of the parallax mode.
  21948. */
  21949. protected _parallaxScaleBias: number;
  21950. /**
  21951. * If sets to true, disables all the lights affecting the material.
  21952. */
  21953. protected _disableLighting: boolean;
  21954. /**
  21955. * Number of Simultaneous lights allowed on the material.
  21956. */
  21957. protected _maxSimultaneousLights: number;
  21958. /**
  21959. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  21960. */
  21961. protected _invertNormalMapX: boolean;
  21962. /**
  21963. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  21964. */
  21965. protected _invertNormalMapY: boolean;
  21966. /**
  21967. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  21968. */
  21969. protected _twoSidedLighting: boolean;
  21970. /**
  21971. * Defines the alpha limits in alpha test mode.
  21972. */
  21973. protected _alphaCutOff: number;
  21974. /**
  21975. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  21976. */
  21977. protected _forceAlphaTest: boolean;
  21978. /**
  21979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21980. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  21981. */
  21982. protected _useAlphaFresnel: boolean;
  21983. /**
  21984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  21985. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  21986. */
  21987. protected _useLinearAlphaFresnel: boolean;
  21988. /**
  21989. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  21990. * from cos thetav and roughness:
  21991. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  21992. */
  21993. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  21994. /**
  21995. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  21996. */
  21997. protected _forceIrradianceInFragment: boolean;
  21998. private _realTimeFiltering;
  21999. /**
  22000. * Enables realtime filtering on the texture.
  22001. */
  22002. get realTimeFiltering(): boolean;
  22003. set realTimeFiltering(b: boolean);
  22004. private _realTimeFilteringQuality;
  22005. /**
  22006. * Quality switch for realtime filtering
  22007. */
  22008. get realTimeFilteringQuality(): number;
  22009. set realTimeFilteringQuality(n: number);
  22010. /**
  22011. * Can this material render to several textures at once
  22012. */
  22013. get canRenderToMRT(): boolean;
  22014. /**
  22015. * Force normal to face away from face.
  22016. */
  22017. protected _forceNormalForward: boolean;
  22018. /**
  22019. * Enables specular anti aliasing in the PBR shader.
  22020. * It will both interacts on the Geometry for analytical and IBL lighting.
  22021. * It also prefilter the roughness map based on the bump values.
  22022. */
  22023. protected _enableSpecularAntiAliasing: boolean;
  22024. /**
  22025. * Default configuration related to image processing available in the PBR Material.
  22026. */
  22027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22028. /**
  22029. * Keep track of the image processing observer to allow dispose and replace.
  22030. */
  22031. private _imageProcessingObserver;
  22032. /**
  22033. * Attaches a new image processing configuration to the PBR Material.
  22034. * @param configuration
  22035. */
  22036. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22037. /**
  22038. * Stores the available render targets.
  22039. */
  22040. private _renderTargets;
  22041. /**
  22042. * Sets the global ambient color for the material used in lighting calculations.
  22043. */
  22044. private _globalAmbientColor;
  22045. /**
  22046. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  22047. */
  22048. private _useLogarithmicDepth;
  22049. /**
  22050. * If set to true, no lighting calculations will be applied.
  22051. */
  22052. private _unlit;
  22053. private _debugMode;
  22054. /**
  22055. * @hidden
  22056. * This is reserved for the inspector.
  22057. * Defines the material debug mode.
  22058. * It helps seeing only some components of the material while troubleshooting.
  22059. */
  22060. debugMode: number;
  22061. /**
  22062. * @hidden
  22063. * This is reserved for the inspector.
  22064. * Specify from where on screen the debug mode should start.
  22065. * The value goes from -1 (full screen) to 1 (not visible)
  22066. * It helps with side by side comparison against the final render
  22067. * This defaults to -1
  22068. */
  22069. private debugLimit;
  22070. /**
  22071. * @hidden
  22072. * This is reserved for the inspector.
  22073. * As the default viewing range might not be enough (if the ambient is really small for instance)
  22074. * You can use the factor to better multiply the final value.
  22075. */
  22076. private debugFactor;
  22077. /**
  22078. * Defines the clear coat layer parameters for the material.
  22079. */
  22080. readonly clearCoat: PBRClearCoatConfiguration;
  22081. /**
  22082. * Defines the anisotropic parameters for the material.
  22083. */
  22084. readonly anisotropy: PBRAnisotropicConfiguration;
  22085. /**
  22086. * Defines the BRDF parameters for the material.
  22087. */
  22088. readonly brdf: PBRBRDFConfiguration;
  22089. /**
  22090. * Defines the Sheen parameters for the material.
  22091. */
  22092. readonly sheen: PBRSheenConfiguration;
  22093. /**
  22094. * Defines the SubSurface parameters for the material.
  22095. */
  22096. readonly subSurface: PBRSubSurfaceConfiguration;
  22097. /**
  22098. * Defines additionnal PrePass parameters for the material.
  22099. */
  22100. readonly prePassConfiguration: PrePassConfiguration;
  22101. /**
  22102. * Defines the detail map parameters for the material.
  22103. */
  22104. readonly detailMap: DetailMapConfiguration;
  22105. protected _rebuildInParallel: boolean;
  22106. /**
  22107. * Instantiates a new PBRMaterial instance.
  22108. *
  22109. * @param name The material name
  22110. * @param scene The scene the material will be use in.
  22111. */
  22112. constructor(name: string, scene: Scene);
  22113. /**
  22114. * Gets a boolean indicating that current material needs to register RTT
  22115. */
  22116. get hasRenderTargetTextures(): boolean;
  22117. /**
  22118. * Gets the name of the material class.
  22119. */
  22120. getClassName(): string;
  22121. /**
  22122. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22123. */
  22124. get useLogarithmicDepth(): boolean;
  22125. /**
  22126. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  22127. */
  22128. set useLogarithmicDepth(value: boolean);
  22129. /**
  22130. * Returns true if alpha blending should be disabled.
  22131. */
  22132. protected get _disableAlphaBlending(): boolean;
  22133. /**
  22134. * Specifies whether or not this material should be rendered in alpha blend mode.
  22135. */
  22136. needAlphaBlending(): boolean;
  22137. /**
  22138. * Specifies whether or not this material should be rendered in alpha test mode.
  22139. */
  22140. needAlphaTesting(): boolean;
  22141. /**
  22142. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  22143. */
  22144. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  22145. /**
  22146. * Specifies whether or not there is a usable alpha channel for transparency.
  22147. */
  22148. protected _hasAlphaChannel(): boolean;
  22149. /**
  22150. * Gets the texture used for the alpha test.
  22151. */
  22152. getAlphaTestTexture(): Nullable<BaseTexture>;
  22153. /**
  22154. * Specifies that the submesh is ready to be used.
  22155. * @param mesh - BJS mesh.
  22156. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  22157. * @param useInstances - Specifies that instances should be used.
  22158. * @returns - boolean indicating that the submesh is ready or not.
  22159. */
  22160. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22161. /**
  22162. * Specifies if the material uses metallic roughness workflow.
  22163. * @returns boolean specifiying if the material uses metallic roughness workflow.
  22164. */
  22165. isMetallicWorkflow(): boolean;
  22166. private _prepareEffect;
  22167. private _prepareDefines;
  22168. /**
  22169. * Force shader compilation
  22170. */
  22171. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  22172. /**
  22173. * Initializes the uniform buffer layout for the shader.
  22174. */
  22175. buildUniformLayout(): void;
  22176. /**
  22177. * Unbinds the material from the mesh
  22178. */
  22179. unbind(): void;
  22180. /**
  22181. * Binds the submesh data.
  22182. * @param world - The world matrix.
  22183. * @param mesh - The BJS mesh.
  22184. * @param subMesh - A submesh of the BJS mesh.
  22185. */
  22186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22187. /**
  22188. * Returns the animatable textures.
  22189. * @returns - Array of animatable textures.
  22190. */
  22191. getAnimatables(): IAnimatable[];
  22192. /**
  22193. * Returns the texture used for reflections.
  22194. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  22195. */
  22196. private _getReflectionTexture;
  22197. /**
  22198. * Returns an array of the actively used textures.
  22199. * @returns - Array of BaseTextures
  22200. */
  22201. getActiveTextures(): BaseTexture[];
  22202. /**
  22203. * Checks to see if a texture is used in the material.
  22204. * @param texture - Base texture to use.
  22205. * @returns - Boolean specifying if a texture is used in the material.
  22206. */
  22207. hasTexture(texture: BaseTexture): boolean;
  22208. /**
  22209. * Sets the required values to the prepass renderer.
  22210. * @param prePassRenderer defines the prepass renderer to setup
  22211. */
  22212. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  22213. /**
  22214. * Disposes the resources of the material.
  22215. * @param forceDisposeEffect - Forces the disposal of effects.
  22216. * @param forceDisposeTextures - Forces the disposal of all textures.
  22217. */
  22218. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  22219. }
  22220. }
  22221. declare module BABYLON {
  22222. /**
  22223. * The Physically based material of BJS.
  22224. *
  22225. * This offers the main features of a standard PBR material.
  22226. * For more information, please refer to the documentation :
  22227. * https://doc.babylonjs.com/how_to/physically_based_rendering
  22228. */
  22229. export class PBRMaterial extends PBRBaseMaterial {
  22230. /**
  22231. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  22232. */
  22233. static readonly PBRMATERIAL_OPAQUE: number;
  22234. /**
  22235. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  22236. */
  22237. static readonly PBRMATERIAL_ALPHATEST: number;
  22238. /**
  22239. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22240. */
  22241. static readonly PBRMATERIAL_ALPHABLEND: number;
  22242. /**
  22243. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  22244. * They are also discarded below the alpha cutoff threshold to improve performances.
  22245. */
  22246. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  22247. /**
  22248. * Defines the default value of how much AO map is occluding the analytical lights
  22249. * (point spot...).
  22250. */
  22251. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  22252. /**
  22253. * Intensity of the direct lights e.g. the four lights available in your scene.
  22254. * This impacts both the direct diffuse and specular highlights.
  22255. */
  22256. directIntensity: number;
  22257. /**
  22258. * Intensity of the emissive part of the material.
  22259. * This helps controlling the emissive effect without modifying the emissive color.
  22260. */
  22261. emissiveIntensity: number;
  22262. /**
  22263. * Intensity of the environment e.g. how much the environment will light the object
  22264. * either through harmonics for rough material or through the refelction for shiny ones.
  22265. */
  22266. environmentIntensity: number;
  22267. /**
  22268. * This is a special control allowing the reduction of the specular highlights coming from the
  22269. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  22270. */
  22271. specularIntensity: number;
  22272. /**
  22273. * Debug Control allowing disabling the bump map on this material.
  22274. */
  22275. disableBumpMap: boolean;
  22276. /**
  22277. * AKA Diffuse Texture in standard nomenclature.
  22278. */
  22279. albedoTexture: BaseTexture;
  22280. /**
  22281. * AKA Occlusion Texture in other nomenclature.
  22282. */
  22283. ambientTexture: BaseTexture;
  22284. /**
  22285. * AKA Occlusion Texture Intensity in other nomenclature.
  22286. */
  22287. ambientTextureStrength: number;
  22288. /**
  22289. * Defines how much the AO map is occluding the analytical lights (point spot...).
  22290. * 1 means it completely occludes it
  22291. * 0 mean it has no impact
  22292. */
  22293. ambientTextureImpactOnAnalyticalLights: number;
  22294. /**
  22295. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  22296. */
  22297. opacityTexture: BaseTexture;
  22298. /**
  22299. * Stores the reflection values in a texture.
  22300. */
  22301. reflectionTexture: Nullable<BaseTexture>;
  22302. /**
  22303. * Stores the emissive values in a texture.
  22304. */
  22305. emissiveTexture: BaseTexture;
  22306. /**
  22307. * AKA Specular texture in other nomenclature.
  22308. */
  22309. reflectivityTexture: BaseTexture;
  22310. /**
  22311. * Used to switch from specular/glossiness to metallic/roughness workflow.
  22312. */
  22313. metallicTexture: BaseTexture;
  22314. /**
  22315. * Specifies the metallic scalar of the metallic/roughness workflow.
  22316. * Can also be used to scale the metalness values of the metallic texture.
  22317. */
  22318. metallic: Nullable<number>;
  22319. /**
  22320. * Specifies the roughness scalar of the metallic/roughness workflow.
  22321. * Can also be used to scale the roughness values of the metallic texture.
  22322. */
  22323. roughness: Nullable<number>;
  22324. /**
  22325. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  22326. * By default the indexOfrefraction is used to compute F0;
  22327. *
  22328. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  22329. *
  22330. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  22331. * F90 = metallicReflectanceColor;
  22332. */
  22333. metallicF0Factor: number;
  22334. /**
  22335. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  22336. * By default the F90 is always 1;
  22337. *
  22338. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  22339. *
  22340. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  22341. * F90 = metallicReflectanceColor;
  22342. */
  22343. metallicReflectanceColor: Color3;
  22344. /**
  22345. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  22346. * This is multiply against the scalar values defined in the material.
  22347. */
  22348. metallicReflectanceTexture: Nullable<BaseTexture>;
  22349. /**
  22350. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  22351. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  22352. */
  22353. microSurfaceTexture: BaseTexture;
  22354. /**
  22355. * Stores surface normal data used to displace a mesh in a texture.
  22356. */
  22357. bumpTexture: BaseTexture;
  22358. /**
  22359. * Stores the pre-calculated light information of a mesh in a texture.
  22360. */
  22361. lightmapTexture: BaseTexture;
  22362. /**
  22363. * Stores the refracted light information in a texture.
  22364. */
  22365. get refractionTexture(): Nullable<BaseTexture>;
  22366. set refractionTexture(value: Nullable<BaseTexture>);
  22367. /**
  22368. * The color of a material in ambient lighting.
  22369. */
  22370. ambientColor: Color3;
  22371. /**
  22372. * AKA Diffuse Color in other nomenclature.
  22373. */
  22374. albedoColor: Color3;
  22375. /**
  22376. * AKA Specular Color in other nomenclature.
  22377. */
  22378. reflectivityColor: Color3;
  22379. /**
  22380. * The color reflected from the material.
  22381. */
  22382. reflectionColor: Color3;
  22383. /**
  22384. * The color emitted from the material.
  22385. */
  22386. emissiveColor: Color3;
  22387. /**
  22388. * AKA Glossiness in other nomenclature.
  22389. */
  22390. microSurface: number;
  22391. /**
  22392. * Index of refraction of the material base layer.
  22393. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  22394. *
  22395. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  22396. *
  22397. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  22398. */
  22399. get indexOfRefraction(): number;
  22400. set indexOfRefraction(value: number);
  22401. /**
  22402. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22403. */
  22404. get invertRefractionY(): boolean;
  22405. set invertRefractionY(value: boolean);
  22406. /**
  22407. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22408. * Materials half opaque for instance using refraction could benefit from this control.
  22409. */
  22410. get linkRefractionWithTransparency(): boolean;
  22411. set linkRefractionWithTransparency(value: boolean);
  22412. /**
  22413. * If true, the light map contains occlusion information instead of lighting info.
  22414. */
  22415. useLightmapAsShadowmap: boolean;
  22416. /**
  22417. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  22418. */
  22419. useAlphaFromAlbedoTexture: boolean;
  22420. /**
  22421. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  22422. */
  22423. forceAlphaTest: boolean;
  22424. /**
  22425. * Defines the alpha limits in alpha test mode.
  22426. */
  22427. alphaCutOff: number;
  22428. /**
  22429. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  22430. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  22431. */
  22432. useSpecularOverAlpha: boolean;
  22433. /**
  22434. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  22435. */
  22436. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  22437. /**
  22438. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  22439. */
  22440. useRoughnessFromMetallicTextureAlpha: boolean;
  22441. /**
  22442. * Specifies if the metallic texture contains the roughness information in its green channel.
  22443. */
  22444. useRoughnessFromMetallicTextureGreen: boolean;
  22445. /**
  22446. * Specifies if the metallic texture contains the metallness information in its blue channel.
  22447. */
  22448. useMetallnessFromMetallicTextureBlue: boolean;
  22449. /**
  22450. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  22451. */
  22452. useAmbientOcclusionFromMetallicTextureRed: boolean;
  22453. /**
  22454. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  22455. */
  22456. useAmbientInGrayScale: boolean;
  22457. /**
  22458. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  22459. * The material will try to infer what glossiness each pixel should be.
  22460. */
  22461. useAutoMicroSurfaceFromReflectivityMap: boolean;
  22462. /**
  22463. * BJS is using an harcoded light falloff based on a manually sets up range.
  22464. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22465. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22466. */
  22467. get usePhysicalLightFalloff(): boolean;
  22468. /**
  22469. * BJS is using an harcoded light falloff based on a manually sets up range.
  22470. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  22471. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  22472. */
  22473. set usePhysicalLightFalloff(value: boolean);
  22474. /**
  22475. * In order to support the falloff compatibility with gltf, a special mode has been added
  22476. * to reproduce the gltf light falloff.
  22477. */
  22478. get useGLTFLightFalloff(): boolean;
  22479. /**
  22480. * In order to support the falloff compatibility with gltf, a special mode has been added
  22481. * to reproduce the gltf light falloff.
  22482. */
  22483. set useGLTFLightFalloff(value: boolean);
  22484. /**
  22485. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  22486. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  22487. */
  22488. useRadianceOverAlpha: boolean;
  22489. /**
  22490. * Allows using an object space normal map (instead of tangent space).
  22491. */
  22492. useObjectSpaceNormalMap: boolean;
  22493. /**
  22494. * Allows using the bump map in parallax mode.
  22495. */
  22496. useParallax: boolean;
  22497. /**
  22498. * Allows using the bump map in parallax occlusion mode.
  22499. */
  22500. useParallaxOcclusion: boolean;
  22501. /**
  22502. * Controls the scale bias of the parallax mode.
  22503. */
  22504. parallaxScaleBias: number;
  22505. /**
  22506. * If sets to true, disables all the lights affecting the material.
  22507. */
  22508. disableLighting: boolean;
  22509. /**
  22510. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  22511. */
  22512. forceIrradianceInFragment: boolean;
  22513. /**
  22514. * Number of Simultaneous lights allowed on the material.
  22515. */
  22516. maxSimultaneousLights: number;
  22517. /**
  22518. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  22519. */
  22520. invertNormalMapX: boolean;
  22521. /**
  22522. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  22523. */
  22524. invertNormalMapY: boolean;
  22525. /**
  22526. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  22527. */
  22528. twoSidedLighting: boolean;
  22529. /**
  22530. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22531. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  22532. */
  22533. useAlphaFresnel: boolean;
  22534. /**
  22535. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  22536. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  22537. */
  22538. useLinearAlphaFresnel: boolean;
  22539. /**
  22540. * Let user defines the brdf lookup texture used for IBL.
  22541. * A default 8bit version is embedded but you could point at :
  22542. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  22543. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  22544. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  22545. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  22546. */
  22547. environmentBRDFTexture: Nullable<BaseTexture>;
  22548. /**
  22549. * Force normal to face away from face.
  22550. */
  22551. forceNormalForward: boolean;
  22552. /**
  22553. * Enables specular anti aliasing in the PBR shader.
  22554. * It will both interacts on the Geometry for analytical and IBL lighting.
  22555. * It also prefilter the roughness map based on the bump values.
  22556. */
  22557. enableSpecularAntiAliasing: boolean;
  22558. /**
  22559. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  22560. * makes the reflect vector face the model (under horizon).
  22561. */
  22562. useHorizonOcclusion: boolean;
  22563. /**
  22564. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  22565. * too much the area relying on ambient texture to define their ambient occlusion.
  22566. */
  22567. useRadianceOcclusion: boolean;
  22568. /**
  22569. * If set to true, no lighting calculations will be applied.
  22570. */
  22571. unlit: boolean;
  22572. /**
  22573. * Gets the image processing configuration used either in this material.
  22574. */
  22575. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22576. /**
  22577. * Sets the Default image processing configuration used either in the this material.
  22578. *
  22579. * If sets to null, the scene one is in use.
  22580. */
  22581. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22582. /**
  22583. * Gets wether the color curves effect is enabled.
  22584. */
  22585. get cameraColorCurvesEnabled(): boolean;
  22586. /**
  22587. * Sets wether the color curves effect is enabled.
  22588. */
  22589. set cameraColorCurvesEnabled(value: boolean);
  22590. /**
  22591. * Gets wether the color grading effect is enabled.
  22592. */
  22593. get cameraColorGradingEnabled(): boolean;
  22594. /**
  22595. * Gets wether the color grading effect is enabled.
  22596. */
  22597. set cameraColorGradingEnabled(value: boolean);
  22598. /**
  22599. * Gets wether tonemapping is enabled or not.
  22600. */
  22601. get cameraToneMappingEnabled(): boolean;
  22602. /**
  22603. * Sets wether tonemapping is enabled or not
  22604. */
  22605. set cameraToneMappingEnabled(value: boolean);
  22606. /**
  22607. * The camera exposure used on this material.
  22608. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22609. * This corresponds to a photographic exposure.
  22610. */
  22611. get cameraExposure(): number;
  22612. /**
  22613. * The camera exposure used on this material.
  22614. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  22615. * This corresponds to a photographic exposure.
  22616. */
  22617. set cameraExposure(value: number);
  22618. /**
  22619. * Gets The camera contrast used on this material.
  22620. */
  22621. get cameraContrast(): number;
  22622. /**
  22623. * Sets The camera contrast used on this material.
  22624. */
  22625. set cameraContrast(value: number);
  22626. /**
  22627. * Gets the Color Grading 2D Lookup Texture.
  22628. */
  22629. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  22630. /**
  22631. * Sets the Color Grading 2D Lookup Texture.
  22632. */
  22633. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  22634. /**
  22635. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22636. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22637. * 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;
  22638. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22639. */
  22640. get cameraColorCurves(): Nullable<ColorCurves>;
  22641. /**
  22642. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  22643. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  22644. * 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;
  22645. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  22646. */
  22647. set cameraColorCurves(value: Nullable<ColorCurves>);
  22648. /**
  22649. * Instantiates a new PBRMaterial instance.
  22650. *
  22651. * @param name The material name
  22652. * @param scene The scene the material will be use in.
  22653. */
  22654. constructor(name: string, scene: Scene);
  22655. /**
  22656. * Returns the name of this material class.
  22657. */
  22658. getClassName(): string;
  22659. /**
  22660. * Makes a duplicate of the current material.
  22661. * @param name - name to use for the new material.
  22662. */
  22663. clone(name: string): PBRMaterial;
  22664. /**
  22665. * Serializes this PBR Material.
  22666. * @returns - An object with the serialized material.
  22667. */
  22668. serialize(): any;
  22669. /**
  22670. * Parses a PBR Material from a serialized object.
  22671. * @param source - Serialized object.
  22672. * @param scene - BJS scene instance.
  22673. * @param rootUrl - url for the scene object
  22674. * @returns - PBRMaterial
  22675. */
  22676. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  22677. }
  22678. }
  22679. declare module BABYLON {
  22680. /** @hidden */
  22681. export var mrtFragmentDeclaration: {
  22682. name: string;
  22683. shader: string;
  22684. };
  22685. }
  22686. declare module BABYLON {
  22687. /** @hidden */
  22688. export var geometryPixelShader: {
  22689. name: string;
  22690. shader: string;
  22691. };
  22692. }
  22693. declare module BABYLON {
  22694. /** @hidden */
  22695. export var instancesDeclaration: {
  22696. name: string;
  22697. shader: string;
  22698. };
  22699. }
  22700. declare module BABYLON {
  22701. /** @hidden */
  22702. export var geometryVertexShader: {
  22703. name: string;
  22704. shader: string;
  22705. };
  22706. }
  22707. declare module BABYLON {
  22708. /** @hidden */
  22709. interface ISavedTransformationMatrix {
  22710. world: Matrix;
  22711. viewProjection: Matrix;
  22712. }
  22713. /**
  22714. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  22715. */
  22716. export class GeometryBufferRenderer {
  22717. /**
  22718. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  22719. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  22720. */
  22721. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  22722. /**
  22723. * Constant used to retrieve the position texture index in the G-Buffer textures array
  22724. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  22725. */
  22726. static readonly POSITION_TEXTURE_TYPE: number;
  22727. /**
  22728. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  22729. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  22730. */
  22731. static readonly VELOCITY_TEXTURE_TYPE: number;
  22732. /**
  22733. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  22734. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  22735. */
  22736. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  22737. /**
  22738. * Dictionary used to store the previous transformation matrices of each rendered mesh
  22739. * in order to compute objects velocities when enableVelocity is set to "true"
  22740. * @hidden
  22741. */
  22742. _previousTransformationMatrices: {
  22743. [index: number]: ISavedTransformationMatrix;
  22744. };
  22745. /**
  22746. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  22747. * in order to compute objects velocities when enableVelocity is set to "true"
  22748. * @hidden
  22749. */
  22750. _previousBonesTransformationMatrices: {
  22751. [index: number]: Float32Array;
  22752. };
  22753. /**
  22754. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  22755. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  22756. */
  22757. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  22758. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  22759. renderTransparentMeshes: boolean;
  22760. private _scene;
  22761. private _resizeObserver;
  22762. private _multiRenderTarget;
  22763. private _ratio;
  22764. private _enablePosition;
  22765. private _enableVelocity;
  22766. private _enableReflectivity;
  22767. private _positionIndex;
  22768. private _velocityIndex;
  22769. private _reflectivityIndex;
  22770. private _depthNormalIndex;
  22771. private _linkedWithPrePass;
  22772. private _prePassRenderer;
  22773. private _attachments;
  22774. protected _effect: Effect;
  22775. protected _cachedDefines: string;
  22776. /**
  22777. * @hidden
  22778. * Sets up internal structures to share outputs with PrePassRenderer
  22779. * This method should only be called by the PrePassRenderer itself
  22780. */
  22781. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  22782. /**
  22783. * @hidden
  22784. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  22785. * This method should only be called by the PrePassRenderer itself
  22786. */
  22787. _unlinkPrePassRenderer(): void;
  22788. /**
  22789. * @hidden
  22790. * Resets the geometry buffer layout
  22791. */
  22792. _resetLayout(): void;
  22793. /**
  22794. * @hidden
  22795. * Replaces a texture in the geometry buffer renderer
  22796. * Useful when linking textures of the prepass renderer
  22797. */
  22798. _forceTextureType(geometryBufferType: number, index: number): void;
  22799. /**
  22800. * @hidden
  22801. * Sets texture attachments
  22802. * Useful when linking textures of the prepass renderer
  22803. */
  22804. _setAttachments(attachments: number[]): void;
  22805. /**
  22806. * @hidden
  22807. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  22808. * Useful when linking textures of the prepass renderer
  22809. */
  22810. _linkInternalTexture(internalTexture: InternalTexture): void;
  22811. /**
  22812. * Gets the render list (meshes to be rendered) used in the G buffer.
  22813. */
  22814. get renderList(): Nullable<AbstractMesh[]>;
  22815. /**
  22816. * Set the render list (meshes to be rendered) used in the G buffer.
  22817. */
  22818. set renderList(meshes: Nullable<AbstractMesh[]>);
  22819. /**
  22820. * Gets wether or not G buffer are supported by the running hardware.
  22821. * This requires draw buffer supports
  22822. */
  22823. get isSupported(): boolean;
  22824. /**
  22825. * Returns the index of the given texture type in the G-Buffer textures array
  22826. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  22827. * @returns the index of the given texture type in the G-Buffer textures array
  22828. */
  22829. getTextureIndex(textureType: number): number;
  22830. /**
  22831. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  22832. */
  22833. get enablePosition(): boolean;
  22834. /**
  22835. * Sets whether or not objects positions are enabled for the G buffer.
  22836. */
  22837. set enablePosition(enable: boolean);
  22838. /**
  22839. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  22840. */
  22841. get enableVelocity(): boolean;
  22842. /**
  22843. * Sets wether or not objects velocities are enabled for the G buffer.
  22844. */
  22845. set enableVelocity(enable: boolean);
  22846. /**
  22847. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  22848. */
  22849. get enableReflectivity(): boolean;
  22850. /**
  22851. * Sets wether or not objects roughness are enabled for the G buffer.
  22852. */
  22853. set enableReflectivity(enable: boolean);
  22854. /**
  22855. * Gets the scene associated with the buffer.
  22856. */
  22857. get scene(): Scene;
  22858. /**
  22859. * Gets the ratio used by the buffer during its creation.
  22860. * How big is the buffer related to the main canvas.
  22861. */
  22862. get ratio(): number;
  22863. /** @hidden */
  22864. static _SceneComponentInitialization: (scene: Scene) => void;
  22865. /**
  22866. * Creates a new G Buffer for the scene
  22867. * @param scene The scene the buffer belongs to
  22868. * @param ratio How big is the buffer related to the main canvas.
  22869. */
  22870. constructor(scene: Scene, ratio?: number);
  22871. /**
  22872. * Checks wether everything is ready to render a submesh to the G buffer.
  22873. * @param subMesh the submesh to check readiness for
  22874. * @param useInstances is the mesh drawn using instance or not
  22875. * @returns true if ready otherwise false
  22876. */
  22877. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  22878. /**
  22879. * Gets the current underlying G Buffer.
  22880. * @returns the buffer
  22881. */
  22882. getGBuffer(): MultiRenderTarget;
  22883. /**
  22884. * Gets the number of samples used to render the buffer (anti aliasing).
  22885. */
  22886. get samples(): number;
  22887. /**
  22888. * Sets the number of samples used to render the buffer (anti aliasing).
  22889. */
  22890. set samples(value: number);
  22891. /**
  22892. * Disposes the renderer and frees up associated resources.
  22893. */
  22894. dispose(): void;
  22895. private _assignRenderTargetIndices;
  22896. protected _createRenderTargets(): void;
  22897. private _copyBonesTransformationMatrices;
  22898. }
  22899. }
  22900. declare module BABYLON {
  22901. /**
  22902. * Renders a pre pass of the scene
  22903. * This means every mesh in the scene will be rendered to a render target texture
  22904. * And then this texture will be composited to the rendering canvas with post processes
  22905. * It is necessary for effects like subsurface scattering or deferred shading
  22906. */
  22907. export class PrePassRenderer {
  22908. /** @hidden */
  22909. static _SceneComponentInitialization: (scene: Scene) => void;
  22910. private _textureFormats;
  22911. /**
  22912. * To save performance, we can excluded skinned meshes from the prepass
  22913. */
  22914. excludedSkinnedMesh: AbstractMesh[];
  22915. /**
  22916. * Force material to be excluded from the prepass
  22917. * Can be useful when `useGeometryBufferFallback` is set to `true`
  22918. * and you don't want a material to show in the effect.
  22919. */
  22920. excludedMaterials: Material[];
  22921. private _textureIndices;
  22922. private _scene;
  22923. private _engine;
  22924. private _isDirty;
  22925. /**
  22926. * Number of textures in the multi render target texture where the scene is directly rendered
  22927. */
  22928. mrtCount: number;
  22929. /**
  22930. * The render target where the scene is directly rendered
  22931. */
  22932. prePassRT: MultiRenderTarget;
  22933. private _multiRenderAttachments;
  22934. private _defaultAttachments;
  22935. private _postProcesses;
  22936. private readonly _clearColor;
  22937. /**
  22938. * Image processing post process for composition
  22939. */
  22940. imageProcessingPostProcess: ImageProcessingPostProcess;
  22941. /**
  22942. * Configuration for prepass effects
  22943. */
  22944. private _effectConfigurations;
  22945. private _mrtFormats;
  22946. private _mrtLayout;
  22947. private _enabled;
  22948. /**
  22949. * Indicates if the prepass is enabled
  22950. */
  22951. get enabled(): boolean;
  22952. /**
  22953. * How many samples are used for MSAA of the scene render target
  22954. */
  22955. get samples(): number;
  22956. set samples(n: number);
  22957. private _geometryBuffer;
  22958. private _useGeometryBufferFallback;
  22959. /**
  22960. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  22961. */
  22962. get useGeometryBufferFallback(): boolean;
  22963. set useGeometryBufferFallback(value: boolean);
  22964. /**
  22965. * Set to true to disable gamma transform in PrePass.
  22966. * Can be useful in case you already proceed to gamma transform on a material level
  22967. * and your post processes don't need to be in linear color space.
  22968. */
  22969. disableGammaTransform: boolean;
  22970. /**
  22971. * Instanciates a prepass renderer
  22972. * @param scene The scene
  22973. */
  22974. constructor(scene: Scene);
  22975. private _initializeAttachments;
  22976. private _createCompositionEffect;
  22977. /**
  22978. * Indicates if rendering a prepass is supported
  22979. */
  22980. get isSupported(): boolean;
  22981. /**
  22982. * Sets the proper output textures to draw in the engine.
  22983. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  22984. * @param subMesh Submesh on which the effect is applied
  22985. */
  22986. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  22987. /**
  22988. * Restores attachments for single texture draw.
  22989. */
  22990. restoreAttachments(): void;
  22991. /**
  22992. * @hidden
  22993. */
  22994. _beforeCameraDraw(): void;
  22995. /**
  22996. * @hidden
  22997. */
  22998. _afterCameraDraw(): void;
  22999. private _checkRTSize;
  23000. private _bindFrameBuffer;
  23001. /**
  23002. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23003. */
  23004. clear(): void;
  23005. private _setState;
  23006. private _updateGeometryBufferLayout;
  23007. /**
  23008. * Adds an effect configuration to the prepass.
  23009. * If an effect has already been added, it won't add it twice and will return the configuration
  23010. * already present.
  23011. * @param cfg the effect configuration
  23012. * @return the effect configuration now used by the prepass
  23013. */
  23014. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23015. /**
  23016. * Returns the index of a texture in the multi render target texture array.
  23017. * @param type Texture type
  23018. * @return The index
  23019. */
  23020. getIndex(type: number): number;
  23021. private _enable;
  23022. private _disable;
  23023. private _resetLayout;
  23024. private _resetPostProcessChain;
  23025. private _bindPostProcessChain;
  23026. /**
  23027. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23028. */
  23029. markAsDirty(): void;
  23030. /**
  23031. * Enables a texture on the MultiRenderTarget for prepass
  23032. */
  23033. private _enableTextures;
  23034. private _update;
  23035. private _markAllMaterialsAsPrePassDirty;
  23036. /**
  23037. * Disposes the prepass renderer.
  23038. */
  23039. dispose(): void;
  23040. }
  23041. }
  23042. declare module BABYLON {
  23043. /**
  23044. * Size options for a post process
  23045. */
  23046. export type PostProcessOptions = {
  23047. width: number;
  23048. height: number;
  23049. };
  23050. /**
  23051. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23052. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23053. */
  23054. export class PostProcess {
  23055. /**
  23056. * Gets or sets the unique id of the post process
  23057. */
  23058. uniqueId: number;
  23059. /** Name of the PostProcess. */
  23060. name: string;
  23061. /**
  23062. * Width of the texture to apply the post process on
  23063. */
  23064. width: number;
  23065. /**
  23066. * Height of the texture to apply the post process on
  23067. */
  23068. height: number;
  23069. /**
  23070. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23071. */
  23072. nodeMaterialSource: Nullable<NodeMaterial>;
  23073. /**
  23074. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23075. * @hidden
  23076. */
  23077. _outputTexture: Nullable<InternalTexture>;
  23078. /**
  23079. * Sampling mode used by the shader
  23080. * See https://doc.babylonjs.com/classes/3.1/texture
  23081. */
  23082. renderTargetSamplingMode: number;
  23083. /**
  23084. * Clear color to use when screen clearing
  23085. */
  23086. clearColor: Color4;
  23087. /**
  23088. * If the buffer needs to be cleared before applying the post process. (default: true)
  23089. * Should be set to false if shader will overwrite all previous pixels.
  23090. */
  23091. autoClear: boolean;
  23092. /**
  23093. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23094. */
  23095. alphaMode: number;
  23096. /**
  23097. * Sets the setAlphaBlendConstants of the babylon engine
  23098. */
  23099. alphaConstants: Color4;
  23100. /**
  23101. * Animations to be used for the post processing
  23102. */
  23103. animations: Animation[];
  23104. /**
  23105. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23106. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23107. */
  23108. enablePixelPerfectMode: boolean;
  23109. /**
  23110. * Force the postprocess to be applied without taking in account viewport
  23111. */
  23112. forceFullscreenViewport: boolean;
  23113. /**
  23114. * List of inspectable custom properties (used by the Inspector)
  23115. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23116. */
  23117. inspectableCustomProperties: IInspectable[];
  23118. /**
  23119. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23120. *
  23121. * | Value | Type | Description |
  23122. * | ----- | ----------------------------------- | ----------- |
  23123. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23124. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23125. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23126. *
  23127. */
  23128. scaleMode: number;
  23129. /**
  23130. * Force textures to be a power of two (default: false)
  23131. */
  23132. alwaysForcePOT: boolean;
  23133. private _samples;
  23134. /**
  23135. * Number of sample textures (default: 1)
  23136. */
  23137. get samples(): number;
  23138. set samples(n: number);
  23139. /**
  23140. * Modify the scale of the post process to be the same as the viewport (default: false)
  23141. */
  23142. adaptScaleToCurrentViewport: boolean;
  23143. private _camera;
  23144. protected _scene: Scene;
  23145. private _engine;
  23146. private _options;
  23147. private _reusable;
  23148. private _textureType;
  23149. private _textureFormat;
  23150. /**
  23151. * Smart array of input and output textures for the post process.
  23152. * @hidden
  23153. */
  23154. _textures: SmartArray<InternalTexture>;
  23155. /**
  23156. * The index in _textures that corresponds to the output texture.
  23157. * @hidden
  23158. */
  23159. _currentRenderTextureInd: number;
  23160. private _effect;
  23161. private _samplers;
  23162. private _fragmentUrl;
  23163. private _vertexUrl;
  23164. private _parameters;
  23165. private _scaleRatio;
  23166. protected _indexParameters: any;
  23167. private _shareOutputWithPostProcess;
  23168. private _texelSize;
  23169. private _forcedOutputTexture;
  23170. /**
  23171. * Prepass configuration in case this post process needs a texture from prepass
  23172. * @hidden
  23173. */
  23174. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23175. /**
  23176. * Returns the fragment url or shader name used in the post process.
  23177. * @returns the fragment url or name in the shader store.
  23178. */
  23179. getEffectName(): string;
  23180. /**
  23181. * An event triggered when the postprocess is activated.
  23182. */
  23183. onActivateObservable: Observable<Camera>;
  23184. private _onActivateObserver;
  23185. /**
  23186. * A function that is added to the onActivateObservable
  23187. */
  23188. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23189. /**
  23190. * An event triggered when the postprocess changes its size.
  23191. */
  23192. onSizeChangedObservable: Observable<PostProcess>;
  23193. private _onSizeChangedObserver;
  23194. /**
  23195. * A function that is added to the onSizeChangedObservable
  23196. */
  23197. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23198. /**
  23199. * An event triggered when the postprocess applies its effect.
  23200. */
  23201. onApplyObservable: Observable<Effect>;
  23202. private _onApplyObserver;
  23203. /**
  23204. * A function that is added to the onApplyObservable
  23205. */
  23206. set onApply(callback: (effect: Effect) => void);
  23207. /**
  23208. * An event triggered before rendering the postprocess
  23209. */
  23210. onBeforeRenderObservable: Observable<Effect>;
  23211. private _onBeforeRenderObserver;
  23212. /**
  23213. * A function that is added to the onBeforeRenderObservable
  23214. */
  23215. set onBeforeRender(callback: (effect: Effect) => void);
  23216. /**
  23217. * An event triggered after rendering the postprocess
  23218. */
  23219. onAfterRenderObservable: Observable<Effect>;
  23220. private _onAfterRenderObserver;
  23221. /**
  23222. * A function that is added to the onAfterRenderObservable
  23223. */
  23224. set onAfterRender(callback: (efect: Effect) => void);
  23225. /**
  23226. * 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
  23227. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23228. */
  23229. get inputTexture(): InternalTexture;
  23230. set inputTexture(value: InternalTexture);
  23231. /**
  23232. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23233. * the only way to unset it is to use this function to restore its internal state
  23234. */
  23235. restoreDefaultInputTexture(): void;
  23236. /**
  23237. * Gets the camera which post process is applied to.
  23238. * @returns The camera the post process is applied to.
  23239. */
  23240. getCamera(): Camera;
  23241. /**
  23242. * Gets the texel size of the postprocess.
  23243. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23244. */
  23245. get texelSize(): Vector2;
  23246. /**
  23247. * Creates a new instance PostProcess
  23248. * @param name The name of the PostProcess.
  23249. * @param fragmentUrl The url of the fragment shader to be used.
  23250. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23251. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23252. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23253. * @param camera The camera to apply the render pass to.
  23254. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23255. * @param engine The engine which the post process will be applied. (default: current engine)
  23256. * @param reusable If the post process can be reused on the same frame. (default: false)
  23257. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23258. * @param textureType Type of textures used when performing the post process. (default: 0)
  23259. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23260. * @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
  23261. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23262. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23263. */
  23264. 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);
  23265. /**
  23266. * Gets a string identifying the name of the class
  23267. * @returns "PostProcess" string
  23268. */
  23269. getClassName(): string;
  23270. /**
  23271. * Gets the engine which this post process belongs to.
  23272. * @returns The engine the post process was enabled with.
  23273. */
  23274. getEngine(): Engine;
  23275. /**
  23276. * The effect that is created when initializing the post process.
  23277. * @returns The created effect corresponding the the postprocess.
  23278. */
  23279. getEffect(): Effect;
  23280. /**
  23281. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23282. * @param postProcess The post process to share the output with.
  23283. * @returns This post process.
  23284. */
  23285. shareOutputWith(postProcess: PostProcess): PostProcess;
  23286. /**
  23287. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23288. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23289. */
  23290. useOwnOutput(): void;
  23291. /**
  23292. * Updates the effect with the current post process compile time values and recompiles the shader.
  23293. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23294. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23295. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23296. * @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
  23297. * @param onCompiled Called when the shader has been compiled.
  23298. * @param onError Called if there is an error when compiling a shader.
  23299. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23300. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23301. */
  23302. 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;
  23303. /**
  23304. * The post process is reusable if it can be used multiple times within one frame.
  23305. * @returns If the post process is reusable
  23306. */
  23307. isReusable(): boolean;
  23308. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23309. markTextureDirty(): void;
  23310. /**
  23311. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23312. * 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.
  23313. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23314. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23315. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23316. * @returns The target texture that was bound to be written to.
  23317. */
  23318. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23319. /**
  23320. * If the post process is supported.
  23321. */
  23322. get isSupported(): boolean;
  23323. /**
  23324. * The aspect ratio of the output texture.
  23325. */
  23326. get aspectRatio(): number;
  23327. /**
  23328. * Get a value indicating if the post-process is ready to be used
  23329. * @returns true if the post-process is ready (shader is compiled)
  23330. */
  23331. isReady(): boolean;
  23332. /**
  23333. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23334. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23335. */
  23336. apply(): Nullable<Effect>;
  23337. private _disposeTextures;
  23338. /**
  23339. * Sets the required values to the prepass renderer.
  23340. * @param prePassRenderer defines the prepass renderer to setup.
  23341. * @returns true if the pre pass is needed.
  23342. */
  23343. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23344. /**
  23345. * Disposes the post process.
  23346. * @param camera The camera to dispose the post process on.
  23347. */
  23348. dispose(camera?: Camera): void;
  23349. /**
  23350. * Serializes the particle system to a JSON object
  23351. * @returns the JSON object
  23352. */
  23353. serialize(): any;
  23354. /**
  23355. * Creates a material from parsed material data
  23356. * @param parsedPostProcess defines parsed post process data
  23357. * @param scene defines the hosting scene
  23358. * @param rootUrl defines the root URL to use to load textures
  23359. * @returns a new post process
  23360. */
  23361. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23362. }
  23363. }
  23364. declare module BABYLON {
  23365. /** @hidden */
  23366. export var kernelBlurVaryingDeclaration: {
  23367. name: string;
  23368. shader: string;
  23369. };
  23370. }
  23371. declare module BABYLON {
  23372. /** @hidden */
  23373. export var packingFunctions: {
  23374. name: string;
  23375. shader: string;
  23376. };
  23377. }
  23378. declare module BABYLON {
  23379. /** @hidden */
  23380. export var kernelBlurFragment: {
  23381. name: string;
  23382. shader: string;
  23383. };
  23384. }
  23385. declare module BABYLON {
  23386. /** @hidden */
  23387. export var kernelBlurFragment2: {
  23388. name: string;
  23389. shader: string;
  23390. };
  23391. }
  23392. declare module BABYLON {
  23393. /** @hidden */
  23394. export var kernelBlurPixelShader: {
  23395. name: string;
  23396. shader: string;
  23397. };
  23398. }
  23399. declare module BABYLON {
  23400. /** @hidden */
  23401. export var kernelBlurVertex: {
  23402. name: string;
  23403. shader: string;
  23404. };
  23405. }
  23406. declare module BABYLON {
  23407. /** @hidden */
  23408. export var kernelBlurVertexShader: {
  23409. name: string;
  23410. shader: string;
  23411. };
  23412. }
  23413. declare module BABYLON {
  23414. /**
  23415. * The Blur Post Process which blurs an image based on a kernel and direction.
  23416. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23417. */
  23418. export class BlurPostProcess extends PostProcess {
  23419. private blockCompilation;
  23420. protected _kernel: number;
  23421. protected _idealKernel: number;
  23422. protected _packedFloat: boolean;
  23423. private _staticDefines;
  23424. /** The direction in which to blur the image. */
  23425. direction: Vector2;
  23426. /**
  23427. * Sets the length in pixels of the blur sample region
  23428. */
  23429. set kernel(v: number);
  23430. /**
  23431. * Gets the length in pixels of the blur sample region
  23432. */
  23433. get kernel(): number;
  23434. /**
  23435. * Sets wether or not the blur needs to unpack/repack floats
  23436. */
  23437. set packedFloat(v: boolean);
  23438. /**
  23439. * Gets wether or not the blur is unpacking/repacking floats
  23440. */
  23441. get packedFloat(): boolean;
  23442. /**
  23443. * Gets a string identifying the name of the class
  23444. * @returns "BlurPostProcess" string
  23445. */
  23446. getClassName(): string;
  23447. /**
  23448. * Creates a new instance BlurPostProcess
  23449. * @param name The name of the effect.
  23450. * @param direction The direction in which to blur the image.
  23451. * @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.
  23452. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23453. * @param camera The camera to apply the render pass to.
  23454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23455. * @param engine The engine which the post process will be applied. (default: current engine)
  23456. * @param reusable If the post process can be reused on the same frame. (default: false)
  23457. * @param textureType Type of textures used when performing the post process. (default: 0)
  23458. * @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)
  23459. */
  23460. 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);
  23461. /**
  23462. * Updates the effect with the current post process compile time values and recompiles the shader.
  23463. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23464. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23465. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23466. * @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
  23467. * @param onCompiled Called when the shader has been compiled.
  23468. * @param onError Called if there is an error when compiling a shader.
  23469. */
  23470. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23471. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23472. /**
  23473. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23474. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23475. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23476. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23477. * The gaps between physical kernels are compensated for in the weighting of the samples
  23478. * @param idealKernel Ideal blur kernel.
  23479. * @return Nearest best kernel.
  23480. */
  23481. protected _nearestBestKernel(idealKernel: number): number;
  23482. /**
  23483. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23484. * @param x The point on the Gaussian distribution to sample.
  23485. * @return the value of the Gaussian function at x.
  23486. */
  23487. protected _gaussianWeight(x: number): number;
  23488. /**
  23489. * Generates a string that can be used as a floating point number in GLSL.
  23490. * @param x Value to print.
  23491. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23492. * @return GLSL float string.
  23493. */
  23494. protected _glslFloat(x: number, decimalFigures?: number): string;
  23495. /** @hidden */
  23496. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23497. }
  23498. }
  23499. declare module BABYLON {
  23500. /**
  23501. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23502. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23503. * You can then easily use it as a reflectionTexture on a flat surface.
  23504. * In case the surface is not a plane, please consider relying on reflection probes.
  23505. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23506. */
  23507. export class MirrorTexture extends RenderTargetTexture {
  23508. private scene;
  23509. /**
  23510. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23511. * 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.
  23512. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23513. */
  23514. mirrorPlane: Plane;
  23515. /**
  23516. * Define the blur ratio used to blur the reflection if needed.
  23517. */
  23518. set blurRatio(value: number);
  23519. get blurRatio(): number;
  23520. /**
  23521. * Define the adaptive blur kernel used to blur the reflection if needed.
  23522. * This will autocompute the closest best match for the `blurKernel`
  23523. */
  23524. set adaptiveBlurKernel(value: number);
  23525. /**
  23526. * Define the blur kernel used to blur the reflection if needed.
  23527. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23528. */
  23529. set blurKernel(value: number);
  23530. /**
  23531. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23532. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23533. */
  23534. set blurKernelX(value: number);
  23535. get blurKernelX(): number;
  23536. /**
  23537. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23538. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23539. */
  23540. set blurKernelY(value: number);
  23541. get blurKernelY(): number;
  23542. private _autoComputeBlurKernel;
  23543. protected _onRatioRescale(): void;
  23544. private _updateGammaSpace;
  23545. private _imageProcessingConfigChangeObserver;
  23546. private _transformMatrix;
  23547. private _mirrorMatrix;
  23548. private _savedViewMatrix;
  23549. private _blurX;
  23550. private _blurY;
  23551. private _adaptiveBlurKernel;
  23552. private _blurKernelX;
  23553. private _blurKernelY;
  23554. private _blurRatio;
  23555. /**
  23556. * Instantiates a Mirror Texture.
  23557. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23558. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23559. * You can then easily use it as a reflectionTexture on a flat surface.
  23560. * In case the surface is not a plane, please consider relying on reflection probes.
  23561. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23562. * @param name
  23563. * @param size
  23564. * @param scene
  23565. * @param generateMipMaps
  23566. * @param type
  23567. * @param samplingMode
  23568. * @param generateDepthBuffer
  23569. */
  23570. constructor(name: string, size: number | {
  23571. width: number;
  23572. height: number;
  23573. } | {
  23574. ratio: number;
  23575. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23576. private _preparePostProcesses;
  23577. /**
  23578. * Clone the mirror texture.
  23579. * @returns the cloned texture
  23580. */
  23581. clone(): MirrorTexture;
  23582. /**
  23583. * Serialize the texture to a JSON representation you could use in Parse later on
  23584. * @returns the serialized JSON representation
  23585. */
  23586. serialize(): any;
  23587. /**
  23588. * Dispose the texture and release its associated resources.
  23589. */
  23590. dispose(): void;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23596. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23597. */
  23598. export class Texture extends BaseTexture {
  23599. /**
  23600. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23601. */
  23602. static SerializeBuffers: boolean;
  23603. /**
  23604. * Gets or sets a general boolean used to indicate that texture buffers must be saved as part of the serialization process.
  23605. * If no buffer exists, one will be created as base64 string from the internal webgl data.
  23606. */
  23607. static ForceSerializeBuffers: boolean;
  23608. /** @hidden */
  23609. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23610. /** @hidden */
  23611. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23612. /** @hidden */
  23613. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23614. /** nearest is mag = nearest and min = nearest and mip = linear */
  23615. static readonly NEAREST_SAMPLINGMODE: number;
  23616. /** nearest is mag = nearest and min = nearest and mip = linear */
  23617. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23618. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23619. static readonly BILINEAR_SAMPLINGMODE: number;
  23620. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23621. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23622. /** Trilinear is mag = linear and min = linear and mip = linear */
  23623. static readonly TRILINEAR_SAMPLINGMODE: number;
  23624. /** Trilinear is mag = linear and min = linear and mip = linear */
  23625. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23626. /** mag = nearest and min = nearest and mip = nearest */
  23627. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23628. /** mag = nearest and min = linear and mip = nearest */
  23629. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23630. /** mag = nearest and min = linear and mip = linear */
  23631. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23632. /** mag = nearest and min = linear and mip = none */
  23633. static readonly NEAREST_LINEAR: number;
  23634. /** mag = nearest and min = nearest and mip = none */
  23635. static readonly NEAREST_NEAREST: number;
  23636. /** mag = linear and min = nearest and mip = nearest */
  23637. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23638. /** mag = linear and min = nearest and mip = linear */
  23639. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23640. /** mag = linear and min = linear and mip = none */
  23641. static readonly LINEAR_LINEAR: number;
  23642. /** mag = linear and min = nearest and mip = none */
  23643. static readonly LINEAR_NEAREST: number;
  23644. /** Explicit coordinates mode */
  23645. static readonly EXPLICIT_MODE: number;
  23646. /** Spherical coordinates mode */
  23647. static readonly SPHERICAL_MODE: number;
  23648. /** Planar coordinates mode */
  23649. static readonly PLANAR_MODE: number;
  23650. /** Cubic coordinates mode */
  23651. static readonly CUBIC_MODE: number;
  23652. /** Projection coordinates mode */
  23653. static readonly PROJECTION_MODE: number;
  23654. /** Inverse Cubic coordinates mode */
  23655. static readonly SKYBOX_MODE: number;
  23656. /** Inverse Cubic coordinates mode */
  23657. static readonly INVCUBIC_MODE: number;
  23658. /** Equirectangular coordinates mode */
  23659. static readonly EQUIRECTANGULAR_MODE: number;
  23660. /** Equirectangular Fixed coordinates mode */
  23661. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23662. /** Equirectangular Fixed Mirrored coordinates mode */
  23663. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23664. /** Texture is not repeating outside of 0..1 UVs */
  23665. static readonly CLAMP_ADDRESSMODE: number;
  23666. /** Texture is repeating outside of 0..1 UVs */
  23667. static readonly WRAP_ADDRESSMODE: number;
  23668. /** Texture is repeating and mirrored */
  23669. static readonly MIRROR_ADDRESSMODE: number;
  23670. /**
  23671. * 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
  23672. */
  23673. static UseSerializedUrlIfAny: boolean;
  23674. /**
  23675. * Define the url of the texture.
  23676. */
  23677. url: Nullable<string>;
  23678. /**
  23679. * Define an offset on the texture to offset the u coordinates of the UVs
  23680. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23681. */
  23682. uOffset: number;
  23683. /**
  23684. * Define an offset on the texture to offset the v coordinates of the UVs
  23685. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23686. */
  23687. vOffset: number;
  23688. /**
  23689. * Define an offset on the texture to scale the u coordinates of the UVs
  23690. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23691. */
  23692. uScale: number;
  23693. /**
  23694. * Define an offset on the texture to scale the v coordinates of the UVs
  23695. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23696. */
  23697. vScale: number;
  23698. /**
  23699. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23700. * @see https://doc.babylonjs.com/how_to/more_materials
  23701. */
  23702. uAng: number;
  23703. /**
  23704. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23705. * @see https://doc.babylonjs.com/how_to/more_materials
  23706. */
  23707. vAng: number;
  23708. /**
  23709. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23710. * @see https://doc.babylonjs.com/how_to/more_materials
  23711. */
  23712. wAng: number;
  23713. /**
  23714. * Defines the center of rotation (U)
  23715. */
  23716. uRotationCenter: number;
  23717. /**
  23718. * Defines the center of rotation (V)
  23719. */
  23720. vRotationCenter: number;
  23721. /**
  23722. * Defines the center of rotation (W)
  23723. */
  23724. wRotationCenter: number;
  23725. /**
  23726. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  23727. */
  23728. homogeneousRotationInUVTransform: boolean;
  23729. /**
  23730. * Are mip maps generated for this texture or not.
  23731. */
  23732. get noMipmap(): boolean;
  23733. /**
  23734. * List of inspectable custom properties (used by the Inspector)
  23735. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23736. */
  23737. inspectableCustomProperties: Nullable<IInspectable[]>;
  23738. private _noMipmap;
  23739. /** @hidden */
  23740. _invertY: boolean;
  23741. private _rowGenerationMatrix;
  23742. private _cachedTextureMatrix;
  23743. private _projectionModeMatrix;
  23744. private _t0;
  23745. private _t1;
  23746. private _t2;
  23747. private _cachedUOffset;
  23748. private _cachedVOffset;
  23749. private _cachedUScale;
  23750. private _cachedVScale;
  23751. private _cachedUAng;
  23752. private _cachedVAng;
  23753. private _cachedWAng;
  23754. private _cachedProjectionMatrixId;
  23755. private _cachedURotationCenter;
  23756. private _cachedVRotationCenter;
  23757. private _cachedWRotationCenter;
  23758. private _cachedHomogeneousRotationInUVTransform;
  23759. private _cachedCoordinatesMode;
  23760. /** @hidden */
  23761. protected _initialSamplingMode: number;
  23762. /** @hidden */
  23763. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23764. private _deleteBuffer;
  23765. protected _format: Nullable<number>;
  23766. private _delayedOnLoad;
  23767. private _delayedOnError;
  23768. private _mimeType?;
  23769. private _loaderOptions?;
  23770. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  23771. get mimeType(): string | undefined;
  23772. /**
  23773. * Observable triggered once the texture has been loaded.
  23774. */
  23775. onLoadObservable: Observable<Texture>;
  23776. protected _isBlocking: boolean;
  23777. /**
  23778. * Is the texture preventing material to render while loading.
  23779. * If false, a default texture will be used instead of the loading one during the preparation step.
  23780. */
  23781. set isBlocking(value: boolean);
  23782. get isBlocking(): boolean;
  23783. /**
  23784. * Get the current sampling mode associated with the texture.
  23785. */
  23786. get samplingMode(): number;
  23787. /**
  23788. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23789. */
  23790. get invertY(): boolean;
  23791. /**
  23792. * Instantiates a new texture.
  23793. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23794. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23795. * @param url defines the url of the picture to load as a texture
  23796. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23797. * @param noMipmap defines if the texture will require mip maps or not
  23798. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23799. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23800. * @param onLoad defines a callback triggered when the texture has been loaded
  23801. * @param onError defines a callback triggered when an error occurred during the loading session
  23802. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23803. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23804. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23805. * @param mimeType defines an optional mime type information
  23806. * @param loaderOptions options to be passed to the loader
  23807. */
  23808. 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);
  23809. /**
  23810. * Update the url (and optional buffer) of this texture if url was null during construction.
  23811. * @param url the url of the texture
  23812. * @param buffer the buffer of the texture (defaults to null)
  23813. * @param onLoad callback called when the texture is loaded (defaults to null)
  23814. */
  23815. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23816. /**
  23817. * Finish the loading sequence of a texture flagged as delayed load.
  23818. * @hidden
  23819. */
  23820. delayLoad(): void;
  23821. private _prepareRowForTextureGeneration;
  23822. /**
  23823. * Checks if the texture has the same transform matrix than another texture
  23824. * @param texture texture to check against
  23825. * @returns true if the transforms are the same, else false
  23826. */
  23827. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  23828. /**
  23829. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23830. * @returns the transform matrix of the texture.
  23831. */
  23832. getTextureMatrix(uBase?: number): Matrix;
  23833. /**
  23834. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23835. * @returns The reflection texture transform
  23836. */
  23837. getReflectionTextureMatrix(): Matrix;
  23838. /**
  23839. * Clones the texture.
  23840. * @returns the cloned texture
  23841. */
  23842. clone(): Texture;
  23843. /**
  23844. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23845. * @returns The JSON representation of the texture
  23846. */
  23847. serialize(): any;
  23848. /**
  23849. * Get the current class name of the texture useful for serialization or dynamic coding.
  23850. * @returns "Texture"
  23851. */
  23852. getClassName(): string;
  23853. /**
  23854. * Dispose the texture and release its associated resources.
  23855. */
  23856. dispose(): void;
  23857. /**
  23858. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23859. * @param parsedTexture Define the JSON representation of the texture
  23860. * @param scene Define the scene the parsed texture should be instantiated in
  23861. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23862. * @returns The parsed texture if successful
  23863. */
  23864. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23865. /**
  23866. * Creates a texture from its base 64 representation.
  23867. * @param data Define the base64 payload without the data: prefix
  23868. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23869. * @param scene Define the scene the texture should belong to
  23870. * @param noMipmap Forces the texture to not create mip map information if true
  23871. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23872. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23873. * @param onLoad define a callback triggered when the texture has been loaded
  23874. * @param onError define a callback triggered when an error occurred during the loading session
  23875. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23876. * @returns the created texture
  23877. */
  23878. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23879. /**
  23880. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23881. * @param data Define the base64 payload without the data: prefix
  23882. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23883. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23884. * @param scene Define the scene the texture should belong to
  23885. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23886. * @param noMipmap Forces the texture to not create mip map information if true
  23887. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23888. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23889. * @param onLoad define a callback triggered when the texture has been loaded
  23890. * @param onError define a callback triggered when an error occurred during the loading session
  23891. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23892. * @returns the created texture
  23893. */
  23894. 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;
  23895. }
  23896. }
  23897. declare module BABYLON {
  23898. /**
  23899. * ThinSprite Class used to represent a thin sprite
  23900. * This is the base class for sprites but can also directly be used with ThinEngine
  23901. * @see https://doc.babylonjs.com/babylon101/sprites
  23902. */
  23903. export class ThinSprite {
  23904. /** Gets or sets the cell index in the sprite sheet */
  23905. cellIndex: number;
  23906. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  23907. cellRef: string;
  23908. /** Gets or sets the current world position */
  23909. position: IVector3Like;
  23910. /** Gets or sets the main color */
  23911. color: IColor4Like;
  23912. /** Gets or sets the width */
  23913. width: number;
  23914. /** Gets or sets the height */
  23915. height: number;
  23916. /** Gets or sets rotation angle */
  23917. angle: number;
  23918. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  23919. invertU: boolean;
  23920. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  23921. invertV: boolean;
  23922. /** Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true */
  23923. isVisible: boolean;
  23924. /**
  23925. * Returns a boolean indicating if the animation is started
  23926. */
  23927. get animationStarted(): boolean;
  23928. /** Gets the initial key for the animation (setting it will restart the animation) */
  23929. get fromIndex(): number;
  23930. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  23931. get toIndex(): number;
  23932. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  23933. get loopAnimation(): boolean;
  23934. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  23935. get delay(): number;
  23936. /** @hidden */
  23937. _xOffset: number;
  23938. /** @hidden */
  23939. _yOffset: number;
  23940. /** @hidden */
  23941. _xSize: number;
  23942. /** @hidden */
  23943. _ySize: number;
  23944. private _animationStarted;
  23945. protected _loopAnimation: boolean;
  23946. protected _fromIndex: number;
  23947. protected _toIndex: number;
  23948. protected _delay: number;
  23949. private _direction;
  23950. private _time;
  23951. private _onBaseAnimationEnd;
  23952. /**
  23953. * Creates a new Thin Sprite
  23954. */
  23955. constructor();
  23956. /**
  23957. * Starts an animation
  23958. * @param from defines the initial key
  23959. * @param to defines the end key
  23960. * @param loop defines if the animation must loop
  23961. * @param delay defines the start delay (in ms)
  23962. * @param onAnimationEnd defines a callback for when the animation ends
  23963. */
  23964. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: Nullable<() => void>): void;
  23965. /** Stops current animation (if any) */
  23966. stopAnimation(): void;
  23967. /** @hidden */
  23968. _animate(deltaTime: number): void;
  23969. }
  23970. }
  23971. declare module BABYLON {
  23972. /** @hidden */
  23973. export var imageProcessingCompatibility: {
  23974. name: string;
  23975. shader: string;
  23976. };
  23977. }
  23978. declare module BABYLON {
  23979. /** @hidden */
  23980. export var spritesPixelShader: {
  23981. name: string;
  23982. shader: string;
  23983. };
  23984. }
  23985. declare module BABYLON {
  23986. /** @hidden */
  23987. export var spritesVertexShader: {
  23988. name: string;
  23989. shader: string;
  23990. };
  23991. }
  23992. declare module BABYLON {
  23993. /**
  23994. * Class used to render sprites.
  23995. *
  23996. * It can be used either to render Sprites or ThinSriptes with ThinEngine only.
  23997. */
  23998. export class SpriteRenderer {
  23999. /**
  24000. * Defines the texture of the spritesheet
  24001. */
  24002. texture: Nullable<ThinTexture>;
  24003. /**
  24004. * Defines the default width of a cell in the spritesheet
  24005. */
  24006. cellWidth: number;
  24007. /**
  24008. * Defines the default height of a cell in the spritesheet
  24009. */
  24010. cellHeight: number;
  24011. /**
  24012. * Blend mode use to render the particle, it can be any of
  24013. * the static Constants.ALPHA_x properties provided in this class.
  24014. * Default value is Constants.ALPHA_COMBINE
  24015. */
  24016. blendMode: number;
  24017. /**
  24018. * Gets or sets a boolean indicating if alpha mode is automatically
  24019. * reset.
  24020. */
  24021. autoResetAlpha: boolean;
  24022. /**
  24023. * Disables writing to the depth buffer when rendering the sprites.
  24024. * It can be handy to disable depth writing when using textures without alpha channel
  24025. * and setting some specific blend modes.
  24026. */
  24027. disableDepthWrite: boolean;
  24028. /**
  24029. * Gets or sets a boolean indicating if the manager must consider scene fog when rendering
  24030. */
  24031. fogEnabled: boolean;
  24032. /**
  24033. * Gets the capacity of the manager
  24034. */
  24035. get capacity(): number;
  24036. private readonly _engine;
  24037. private readonly _useVAO;
  24038. private readonly _useInstancing;
  24039. private readonly _scene;
  24040. private readonly _capacity;
  24041. private readonly _epsilon;
  24042. private _vertexBufferSize;
  24043. private _vertexData;
  24044. private _buffer;
  24045. private _vertexBuffers;
  24046. private _spriteBuffer;
  24047. private _indexBuffer;
  24048. private _effectBase;
  24049. private _effectFog;
  24050. private _vertexArrayObject;
  24051. /**
  24052. * Creates a new sprite Renderer
  24053. * @param engine defines the engine the renderer works with
  24054. * @param capacity defines the maximum allowed number of sprites
  24055. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24056. * @param scene defines the hosting scene
  24057. */
  24058. constructor(engine: ThinEngine, capacity: number, epsilon?: number, scene?: Nullable<Scene>);
  24059. /**
  24060. * Render all child sprites
  24061. * @param sprites defines the list of sprites to render
  24062. * @param deltaTime defines the time since last frame
  24063. * @param viewMatrix defines the viewMatrix to use to render the sprites
  24064. * @param projectionMatrix defines the projectionMatrix to use to render the sprites
  24065. * @param customSpriteUpdate defines a custom function to update the sprites data before they render
  24066. */
  24067. render(sprites: ThinSprite[], deltaTime: number, viewMatrix: IMatrixLike, projectionMatrix: IMatrixLike, customSpriteUpdate?: Nullable<(sprite: ThinSprite, baseSize: ISize) => void>): void;
  24068. private _appendSpriteVertex;
  24069. /**
  24070. * Release associated resources
  24071. */
  24072. dispose(): void;
  24073. }
  24074. }
  24075. declare module BABYLON {
  24076. /**
  24077. * Defines the minimum interface to fullfil in order to be a sprite manager.
  24078. */
  24079. export interface ISpriteManager extends IDisposable {
  24080. /**
  24081. * Gets manager's name
  24082. */
  24083. name: string;
  24084. /**
  24085. * Restricts the camera to viewing objects with the same layerMask.
  24086. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  24087. */
  24088. layerMask: number;
  24089. /**
  24090. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24091. */
  24092. isPickable: boolean;
  24093. /**
  24094. * Gets the hosting scene
  24095. */
  24096. scene: Scene;
  24097. /**
  24098. * Specifies the rendering group id for this mesh (0 by default)
  24099. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24100. */
  24101. renderingGroupId: number;
  24102. /**
  24103. * Defines the list of sprites managed by the manager.
  24104. */
  24105. sprites: Array<Sprite>;
  24106. /**
  24107. * Gets or sets the spritesheet texture
  24108. */
  24109. texture: Texture;
  24110. /** Defines the default width of a cell in the spritesheet */
  24111. cellWidth: number;
  24112. /** Defines the default height of a cell in the spritesheet */
  24113. cellHeight: number;
  24114. /**
  24115. * Tests the intersection of a sprite with a specific ray.
  24116. * @param ray The ray we are sending to test the collision
  24117. * @param camera The camera space we are sending rays in
  24118. * @param predicate A predicate allowing excluding sprites from the list of object to test
  24119. * @param fastCheck defines if the first intersection will be used (and not the closest)
  24120. * @returns picking info or null.
  24121. */
  24122. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24123. /**
  24124. * Intersects the sprites with a ray
  24125. * @param ray defines the ray to intersect with
  24126. * @param camera defines the current active camera
  24127. * @param predicate defines a predicate used to select candidate sprites
  24128. * @returns null if no hit or a PickingInfo array
  24129. */
  24130. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24131. /**
  24132. * Renders the list of sprites on screen.
  24133. */
  24134. render(): void;
  24135. }
  24136. /**
  24137. * Class used to manage multiple sprites on the same spritesheet
  24138. * @see https://doc.babylonjs.com/babylon101/sprites
  24139. */
  24140. export class SpriteManager implements ISpriteManager {
  24141. /** defines the manager's name */
  24142. name: string;
  24143. /** Define the Url to load snippets */
  24144. static SnippetUrl: string;
  24145. /** Snippet ID if the manager was created from the snippet server */
  24146. snippetId: string;
  24147. /** Gets the list of sprites */
  24148. sprites: Sprite[];
  24149. /** Gets or sets the rendering group id (0 by default) */
  24150. renderingGroupId: number;
  24151. /** Gets or sets camera layer mask */
  24152. layerMask: number;
  24153. /** Gets or sets a boolean indicating if the sprites are pickable */
  24154. isPickable: boolean;
  24155. /**
  24156. * An event triggered when the manager is disposed.
  24157. */
  24158. onDisposeObservable: Observable<SpriteManager>;
  24159. /**
  24160. * Callback called when the manager is disposed
  24161. */
  24162. set onDispose(callback: () => void);
  24163. /**
  24164. * Gets or sets the unique id of the sprite
  24165. */
  24166. uniqueId: number;
  24167. /**
  24168. * Gets the array of sprites
  24169. */
  24170. get children(): Sprite[];
  24171. /**
  24172. * Gets the hosting scene
  24173. */
  24174. get scene(): Scene;
  24175. /**
  24176. * Gets the capacity of the manager
  24177. */
  24178. get capacity(): number;
  24179. /**
  24180. * Gets or sets the spritesheet texture
  24181. */
  24182. get texture(): Texture;
  24183. set texture(value: Texture);
  24184. /** Defines the default width of a cell in the spritesheet */
  24185. get cellWidth(): number;
  24186. set cellWidth(value: number);
  24187. /** Defines the default height of a cell in the spritesheet */
  24188. get cellHeight(): number;
  24189. set cellHeight(value: number);
  24190. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  24191. get fogEnabled(): boolean;
  24192. set fogEnabled(value: boolean);
  24193. /**
  24194. * Blend mode use to render the particle, it can be any of
  24195. * the static Constants.ALPHA_x properties provided in this class.
  24196. * Default value is Constants.ALPHA_COMBINE
  24197. */
  24198. get blendMode(): number;
  24199. set blendMode(blendMode: number);
  24200. /** Disables writing to the depth buffer when rendering the sprites.
  24201. * It can be handy to disable depth writing when using textures without alpha channel
  24202. * and setting some specific blend modes.
  24203. */
  24204. disableDepthWrite: boolean;
  24205. private _spriteRenderer;
  24206. /** Associative array from JSON sprite data file */
  24207. private _cellData;
  24208. /** Array of sprite names from JSON sprite data file */
  24209. private _spriteMap;
  24210. /** True when packed cell data from JSON file is ready*/
  24211. private _packedAndReady;
  24212. private _textureContent;
  24213. private _onDisposeObserver;
  24214. private _fromPacked;
  24215. private _scene;
  24216. /**
  24217. * Creates a new sprite manager
  24218. * @param name defines the manager's name
  24219. * @param imgUrl defines the sprite sheet url
  24220. * @param capacity defines the maximum allowed number of sprites
  24221. * @param cellSize defines the size of a sprite cell
  24222. * @param scene defines the hosting scene
  24223. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  24224. * @param samplingMode defines the smapling mode to use with spritesheet
  24225. * @param fromPacked set to false; do not alter
  24226. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  24227. */
  24228. constructor(
  24229. /** defines the manager's name */
  24230. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  24231. /**
  24232. * Returns the string "SpriteManager"
  24233. * @returns "SpriteManager"
  24234. */
  24235. getClassName(): string;
  24236. private _makePacked;
  24237. private _checkTextureAlpha;
  24238. /**
  24239. * Intersects the sprites with a ray
  24240. * @param ray defines the ray to intersect with
  24241. * @param camera defines the current active camera
  24242. * @param predicate defines a predicate used to select candidate sprites
  24243. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  24244. * @returns null if no hit or a PickingInfo
  24245. */
  24246. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  24247. /**
  24248. * Intersects the sprites with a ray
  24249. * @param ray defines the ray to intersect with
  24250. * @param camera defines the current active camera
  24251. * @param predicate defines a predicate used to select candidate sprites
  24252. * @returns null if no hit or a PickingInfo array
  24253. */
  24254. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  24255. /**
  24256. * Render all child sprites
  24257. */
  24258. render(): void;
  24259. private _customUpdate;
  24260. /**
  24261. * Release associated resources
  24262. */
  24263. dispose(): void;
  24264. /**
  24265. * Serializes the sprite manager to a JSON object
  24266. * @param serializeTexture defines if the texture must be serialized as well
  24267. * @returns the JSON object
  24268. */
  24269. serialize(serializeTexture?: boolean): any;
  24270. /**
  24271. * Parses a JSON object to create a new sprite manager.
  24272. * @param parsedManager The JSON object to parse
  24273. * @param scene The scene to create the sprite managerin
  24274. * @param rootUrl The root url to use to load external dependencies like texture
  24275. * @returns the new sprite manager
  24276. */
  24277. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  24278. /**
  24279. * Creates a sprite manager from a snippet saved in a remote file
  24280. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  24281. * @param url defines the url to load from
  24282. * @param scene defines the hosting scene
  24283. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24284. * @returns a promise that will resolve to the new sprite manager
  24285. */
  24286. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24287. /**
  24288. * Creates a sprite manager from a snippet saved by the sprite editor
  24289. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  24290. * @param scene defines the hosting scene
  24291. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24292. * @returns a promise that will resolve to the new sprite manager
  24293. */
  24294. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  24295. }
  24296. }
  24297. declare module BABYLON {
  24298. /**
  24299. * Class used to represent a sprite
  24300. * @see https://doc.babylonjs.com/babylon101/sprites
  24301. */
  24302. export class Sprite extends ThinSprite implements IAnimatable {
  24303. /** defines the name */
  24304. name: string;
  24305. /** Gets or sets the current world position */
  24306. position: Vector3;
  24307. /** Gets or sets the main color */
  24308. color: Color4;
  24309. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  24310. disposeWhenFinishedAnimating: boolean;
  24311. /** Gets the list of attached animations */
  24312. animations: Nullable<Array<Animation>>;
  24313. /** Gets or sets a boolean indicating if the sprite can be picked */
  24314. isPickable: boolean;
  24315. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  24316. useAlphaForPicking: boolean;
  24317. /**
  24318. * Gets or sets the associated action manager
  24319. */
  24320. actionManager: Nullable<ActionManager>;
  24321. /**
  24322. * An event triggered when the control has been disposed
  24323. */
  24324. onDisposeObservable: Observable<Sprite>;
  24325. private _manager;
  24326. private _onAnimationEnd;
  24327. /**
  24328. * Gets or sets the sprite size
  24329. */
  24330. get size(): number;
  24331. set size(value: number);
  24332. /**
  24333. * Gets or sets the unique id of the sprite
  24334. */
  24335. uniqueId: number;
  24336. /**
  24337. * Gets the manager of this sprite
  24338. */
  24339. get manager(): ISpriteManager;
  24340. /**
  24341. * Creates a new Sprite
  24342. * @param name defines the name
  24343. * @param manager defines the manager
  24344. */
  24345. constructor(
  24346. /** defines the name */
  24347. name: string, manager: ISpriteManager);
  24348. /**
  24349. * Returns the string "Sprite"
  24350. * @returns "Sprite"
  24351. */
  24352. getClassName(): string;
  24353. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  24354. get fromIndex(): number;
  24355. set fromIndex(value: number);
  24356. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  24357. get toIndex(): number;
  24358. set toIndex(value: number);
  24359. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  24360. get loopAnimation(): boolean;
  24361. set loopAnimation(value: boolean);
  24362. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  24363. get delay(): number;
  24364. set delay(value: number);
  24365. /**
  24366. * Starts an animation
  24367. * @param from defines the initial key
  24368. * @param to defines the end key
  24369. * @param loop defines if the animation must loop
  24370. * @param delay defines the start delay (in ms)
  24371. * @param onAnimationEnd defines a callback to call when animation ends
  24372. */
  24373. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  24374. private _endAnimation;
  24375. /** Release associated resources */
  24376. dispose(): void;
  24377. /**
  24378. * Serializes the sprite to a JSON object
  24379. * @returns the JSON object
  24380. */
  24381. serialize(): any;
  24382. /**
  24383. * Parses a JSON object to create a new sprite
  24384. * @param parsedSprite The JSON object to parse
  24385. * @param manager defines the hosting manager
  24386. * @returns the new sprite
  24387. */
  24388. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  24389. }
  24390. }
  24391. declare module BABYLON {
  24392. /**
  24393. * Information about the result of picking within a scene
  24394. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  24395. */
  24396. export class PickingInfo {
  24397. /** @hidden */
  24398. _pickingUnavailable: boolean;
  24399. /**
  24400. * If the pick collided with an object
  24401. */
  24402. hit: boolean;
  24403. /**
  24404. * Distance away where the pick collided
  24405. */
  24406. distance: number;
  24407. /**
  24408. * The location of pick collision
  24409. */
  24410. pickedPoint: Nullable<Vector3>;
  24411. /**
  24412. * The mesh corresponding the the pick collision
  24413. */
  24414. pickedMesh: Nullable<AbstractMesh>;
  24415. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  24416. bu: number;
  24417. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  24418. bv: number;
  24419. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24420. faceId: number;
  24421. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  24422. subMeshFaceId: number;
  24423. /** Id of the the submesh that was picked */
  24424. subMeshId: number;
  24425. /** If a sprite was picked, this will be the sprite the pick collided with */
  24426. pickedSprite: Nullable<Sprite>;
  24427. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  24428. thinInstanceIndex: number;
  24429. /**
  24430. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  24431. */
  24432. originMesh: Nullable<AbstractMesh>;
  24433. /**
  24434. * The ray that was used to perform the picking.
  24435. */
  24436. ray: Nullable<Ray>;
  24437. /**
  24438. * Gets the normal correspodning to the face the pick collided with
  24439. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  24440. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  24441. * @returns The normal correspodning to the face the pick collided with
  24442. */
  24443. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  24444. /**
  24445. * Gets the texture coordinates of where the pick occured
  24446. * @returns the vector containing the coordnates of the texture
  24447. */
  24448. getTextureCoordinates(): Nullable<Vector2>;
  24449. }
  24450. }
  24451. declare module BABYLON {
  24452. /**
  24453. * Gather the list of pointer event types as constants.
  24454. */
  24455. export class PointerEventTypes {
  24456. /**
  24457. * 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.
  24458. */
  24459. static readonly POINTERDOWN: number;
  24460. /**
  24461. * The pointerup event is fired when a pointer is no longer active.
  24462. */
  24463. static readonly POINTERUP: number;
  24464. /**
  24465. * The pointermove event is fired when a pointer changes coordinates.
  24466. */
  24467. static readonly POINTERMOVE: number;
  24468. /**
  24469. * The pointerwheel event is fired when a mouse wheel has been rotated.
  24470. */
  24471. static readonly POINTERWHEEL: number;
  24472. /**
  24473. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  24474. */
  24475. static readonly POINTERPICK: number;
  24476. /**
  24477. * The pointertap event is fired when a the object has been touched and released without drag.
  24478. */
  24479. static readonly POINTERTAP: number;
  24480. /**
  24481. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  24482. */
  24483. static readonly POINTERDOUBLETAP: number;
  24484. }
  24485. /**
  24486. * Base class of pointer info types.
  24487. */
  24488. export class PointerInfoBase {
  24489. /**
  24490. * Defines the type of event (PointerEventTypes)
  24491. */
  24492. type: number;
  24493. /**
  24494. * Defines the related dom event
  24495. */
  24496. event: PointerEvent | MouseWheelEvent;
  24497. /**
  24498. * Instantiates the base class of pointers info.
  24499. * @param type Defines the type of event (PointerEventTypes)
  24500. * @param event Defines the related dom event
  24501. */
  24502. constructor(
  24503. /**
  24504. * Defines the type of event (PointerEventTypes)
  24505. */
  24506. type: number,
  24507. /**
  24508. * Defines the related dom event
  24509. */
  24510. event: PointerEvent | MouseWheelEvent);
  24511. }
  24512. /**
  24513. * This class is used to store pointer related info for the onPrePointerObservable event.
  24514. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  24515. */
  24516. export class PointerInfoPre extends PointerInfoBase {
  24517. /**
  24518. * Ray from a pointer if availible (eg. 6dof controller)
  24519. */
  24520. ray: Nullable<Ray>;
  24521. /**
  24522. * Defines the local position of the pointer on the canvas.
  24523. */
  24524. localPosition: Vector2;
  24525. /**
  24526. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  24527. */
  24528. skipOnPointerObservable: boolean;
  24529. /**
  24530. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  24531. * @param type Defines the type of event (PointerEventTypes)
  24532. * @param event Defines the related dom event
  24533. * @param localX Defines the local x coordinates of the pointer when the event occured
  24534. * @param localY Defines the local y coordinates of the pointer when the event occured
  24535. */
  24536. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  24537. }
  24538. /**
  24539. * This type contains all the data related to a pointer event in Babylon.js.
  24540. * 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.
  24541. */
  24542. export class PointerInfo extends PointerInfoBase {
  24543. /**
  24544. * Defines the picking info associated to the info (if any)\
  24545. */
  24546. pickInfo: Nullable<PickingInfo>;
  24547. /**
  24548. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  24549. * @param type Defines the type of event (PointerEventTypes)
  24550. * @param event Defines the related dom event
  24551. * @param pickInfo Defines the picking info associated to the info (if any)\
  24552. */
  24553. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  24554. /**
  24555. * Defines the picking info associated to the info (if any)\
  24556. */
  24557. pickInfo: Nullable<PickingInfo>);
  24558. }
  24559. /**
  24560. * Data relating to a touch event on the screen.
  24561. */
  24562. export interface PointerTouch {
  24563. /**
  24564. * X coordinate of touch.
  24565. */
  24566. x: number;
  24567. /**
  24568. * Y coordinate of touch.
  24569. */
  24570. y: number;
  24571. /**
  24572. * Id of touch. Unique for each finger.
  24573. */
  24574. pointerId: number;
  24575. /**
  24576. * Event type passed from DOM.
  24577. */
  24578. type: any;
  24579. }
  24580. }
  24581. declare module BABYLON {
  24582. /**
  24583. * Manage the mouse inputs to control the movement of a free camera.
  24584. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24585. */
  24586. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  24587. /**
  24588. * Define if touch is enabled in the mouse input
  24589. */
  24590. touchEnabled: boolean;
  24591. /**
  24592. * Defines the camera the input is attached to.
  24593. */
  24594. camera: FreeCamera;
  24595. /**
  24596. * Defines the buttons associated with the input to handle camera move.
  24597. */
  24598. buttons: number[];
  24599. /**
  24600. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  24601. */
  24602. angularSensibility: number;
  24603. private _pointerInput;
  24604. private _onMouseMove;
  24605. private _observer;
  24606. private previousPosition;
  24607. /**
  24608. * Observable for when a pointer move event occurs containing the move offset
  24609. */
  24610. onPointerMovedObservable: Observable<{
  24611. offsetX: number;
  24612. offsetY: number;
  24613. }>;
  24614. /**
  24615. * @hidden
  24616. * If the camera should be rotated automatically based on pointer movement
  24617. */
  24618. _allowCameraRotation: boolean;
  24619. /**
  24620. * Manage the mouse inputs to control the movement of a free camera.
  24621. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24622. * @param touchEnabled Defines if touch is enabled or not
  24623. */
  24624. constructor(
  24625. /**
  24626. * Define if touch is enabled in the mouse input
  24627. */
  24628. touchEnabled?: boolean);
  24629. /**
  24630. * Attach the input controls to a specific dom element to get the input from.
  24631. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24632. */
  24633. attachControl(noPreventDefault?: boolean): void;
  24634. /**
  24635. * Called on JS contextmenu event.
  24636. * Override this method to provide functionality.
  24637. */
  24638. protected onContextMenu(evt: PointerEvent): void;
  24639. /**
  24640. * Detach the current controls from the specified dom element.
  24641. */
  24642. detachControl(): void;
  24643. /**
  24644. * Gets the class name of the current intput.
  24645. * @returns the class name
  24646. */
  24647. getClassName(): string;
  24648. /**
  24649. * Get the friendly name associated with the input class.
  24650. * @returns the input friendly name
  24651. */
  24652. getSimpleName(): string;
  24653. }
  24654. }
  24655. declare module BABYLON {
  24656. /**
  24657. * Base class for mouse wheel input..
  24658. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  24659. * for example usage.
  24660. */
  24661. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  24662. /**
  24663. * Defines the camera the input is attached to.
  24664. */
  24665. abstract camera: Camera;
  24666. /**
  24667. * How fast is the camera moves in relation to X axis mouseWheel events.
  24668. * Use negative value to reverse direction.
  24669. */
  24670. wheelPrecisionX: number;
  24671. /**
  24672. * How fast is the camera moves in relation to Y axis mouseWheel events.
  24673. * Use negative value to reverse direction.
  24674. */
  24675. wheelPrecisionY: number;
  24676. /**
  24677. * How fast is the camera moves in relation to Z axis mouseWheel events.
  24678. * Use negative value to reverse direction.
  24679. */
  24680. wheelPrecisionZ: number;
  24681. /**
  24682. * Observable for when a mouse wheel move event occurs.
  24683. */
  24684. onChangedObservable: Observable<{
  24685. wheelDeltaX: number;
  24686. wheelDeltaY: number;
  24687. wheelDeltaZ: number;
  24688. }>;
  24689. private _wheel;
  24690. private _observer;
  24691. /**
  24692. * Attach the input controls to a specific dom element to get the input from.
  24693. * @param noPreventDefault Defines whether event caught by the controls
  24694. * should call preventdefault().
  24695. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24696. */
  24697. attachControl(noPreventDefault?: boolean): void;
  24698. /**
  24699. * Detach the current controls from the specified dom element.
  24700. */
  24701. detachControl(): void;
  24702. /**
  24703. * Called for each rendered frame.
  24704. */
  24705. checkInputs(): void;
  24706. /**
  24707. * Gets the class name of the current intput.
  24708. * @returns the class name
  24709. */
  24710. getClassName(): string;
  24711. /**
  24712. * Get the friendly name associated with the input class.
  24713. * @returns the input friendly name
  24714. */
  24715. getSimpleName(): string;
  24716. /**
  24717. * Incremental value of multiple mouse wheel movements of the X axis.
  24718. * Should be zero-ed when read.
  24719. */
  24720. protected _wheelDeltaX: number;
  24721. /**
  24722. * Incremental value of multiple mouse wheel movements of the Y axis.
  24723. * Should be zero-ed when read.
  24724. */
  24725. protected _wheelDeltaY: number;
  24726. /**
  24727. * Incremental value of multiple mouse wheel movements of the Z axis.
  24728. * Should be zero-ed when read.
  24729. */
  24730. protected _wheelDeltaZ: number;
  24731. /**
  24732. * Firefox uses a different scheme to report scroll distances to other
  24733. * browsers. Rather than use complicated methods to calculate the exact
  24734. * multiple we need to apply, let's just cheat and use a constant.
  24735. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  24736. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  24737. */
  24738. private readonly _ffMultiplier;
  24739. /**
  24740. * Different event attributes for wheel data fall into a few set ranges.
  24741. * Some relevant but dated date here:
  24742. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  24743. */
  24744. private readonly _normalize;
  24745. }
  24746. }
  24747. declare module BABYLON {
  24748. /**
  24749. * Manage the mouse wheel inputs to control a free camera.
  24750. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24751. */
  24752. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  24753. /**
  24754. * Defines the camera the input is attached to.
  24755. */
  24756. camera: FreeCamera;
  24757. /**
  24758. * Gets the class name of the current input.
  24759. * @returns the class name
  24760. */
  24761. getClassName(): string;
  24762. /**
  24763. * Set which movement axis (relative to camera's orientation) the mouse
  24764. * wheel's X axis controls.
  24765. * @param axis The axis to be moved. Set null to clear.
  24766. */
  24767. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  24768. /**
  24769. * Get the configured movement axis (relative to camera's orientation) the
  24770. * mouse wheel's X axis controls.
  24771. * @returns The configured axis or null if none.
  24772. */
  24773. get wheelXMoveRelative(): Nullable<Coordinate>;
  24774. /**
  24775. * Set which movement axis (relative to camera's orientation) the mouse
  24776. * wheel's Y axis controls.
  24777. * @param axis The axis to be moved. Set null to clear.
  24778. */
  24779. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  24780. /**
  24781. * Get the configured movement axis (relative to camera's orientation) the
  24782. * mouse wheel's Y axis controls.
  24783. * @returns The configured axis or null if none.
  24784. */
  24785. get wheelYMoveRelative(): Nullable<Coordinate>;
  24786. /**
  24787. * Set which movement axis (relative to camera's orientation) the mouse
  24788. * wheel's Z axis controls.
  24789. * @param axis The axis to be moved. Set null to clear.
  24790. */
  24791. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  24792. /**
  24793. * Get the configured movement axis (relative to camera's orientation) the
  24794. * mouse wheel's Z axis controls.
  24795. * @returns The configured axis or null if none.
  24796. */
  24797. get wheelZMoveRelative(): Nullable<Coordinate>;
  24798. /**
  24799. * Set which rotation axis (relative to camera's orientation) the mouse
  24800. * wheel's X axis controls.
  24801. * @param axis The axis to be moved. Set null to clear.
  24802. */
  24803. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  24804. /**
  24805. * Get the configured rotation axis (relative to camera's orientation) the
  24806. * mouse wheel's X axis controls.
  24807. * @returns The configured axis or null if none.
  24808. */
  24809. get wheelXRotateRelative(): Nullable<Coordinate>;
  24810. /**
  24811. * Set which rotation axis (relative to camera's orientation) the mouse
  24812. * wheel's Y axis controls.
  24813. * @param axis The axis to be moved. Set null to clear.
  24814. */
  24815. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  24816. /**
  24817. * Get the configured rotation axis (relative to camera's orientation) the
  24818. * mouse wheel's Y axis controls.
  24819. * @returns The configured axis or null if none.
  24820. */
  24821. get wheelYRotateRelative(): Nullable<Coordinate>;
  24822. /**
  24823. * Set which rotation axis (relative to camera's orientation) the mouse
  24824. * wheel's Z axis controls.
  24825. * @param axis The axis to be moved. Set null to clear.
  24826. */
  24827. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  24828. /**
  24829. * Get the configured rotation axis (relative to camera's orientation) the
  24830. * mouse wheel's Z axis controls.
  24831. * @returns The configured axis or null if none.
  24832. */
  24833. get wheelZRotateRelative(): Nullable<Coordinate>;
  24834. /**
  24835. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  24836. * controls.
  24837. * @param axis The axis to be moved. Set null to clear.
  24838. */
  24839. set wheelXMoveScene(axis: Nullable<Coordinate>);
  24840. /**
  24841. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24842. * X axis controls.
  24843. * @returns The configured axis or null if none.
  24844. */
  24845. get wheelXMoveScene(): Nullable<Coordinate>;
  24846. /**
  24847. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  24848. * controls.
  24849. * @param axis The axis to be moved. Set null to clear.
  24850. */
  24851. set wheelYMoveScene(axis: Nullable<Coordinate>);
  24852. /**
  24853. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24854. * Y axis controls.
  24855. * @returns The configured axis or null if none.
  24856. */
  24857. get wheelYMoveScene(): Nullable<Coordinate>;
  24858. /**
  24859. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  24860. * controls.
  24861. * @param axis The axis to be moved. Set null to clear.
  24862. */
  24863. set wheelZMoveScene(axis: Nullable<Coordinate>);
  24864. /**
  24865. * Get the configured movement axis (relative to the scene) the mouse wheel's
  24866. * Z axis controls.
  24867. * @returns The configured axis or null if none.
  24868. */
  24869. get wheelZMoveScene(): Nullable<Coordinate>;
  24870. /**
  24871. * Called for each rendered frame.
  24872. */
  24873. checkInputs(): void;
  24874. private _moveRelative;
  24875. private _rotateRelative;
  24876. private _moveScene;
  24877. /**
  24878. * These are set to the desired default behaviour.
  24879. */
  24880. private _wheelXAction;
  24881. private _wheelXActionCoordinate;
  24882. private _wheelYAction;
  24883. private _wheelYActionCoordinate;
  24884. private _wheelZAction;
  24885. private _wheelZActionCoordinate;
  24886. /**
  24887. * Update the camera according to any configured properties for the 3
  24888. * mouse-wheel axis.
  24889. */
  24890. private _updateCamera;
  24891. /**
  24892. * Update one property of the camera.
  24893. */
  24894. private _updateCameraProperty;
  24895. }
  24896. }
  24897. declare module BABYLON {
  24898. /**
  24899. * Manage the touch inputs to control the movement of a free camera.
  24900. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24901. */
  24902. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  24903. /**
  24904. * Define if mouse events can be treated as touch events
  24905. */
  24906. allowMouse: boolean;
  24907. /**
  24908. * Defines the camera the input is attached to.
  24909. */
  24910. camera: FreeCamera;
  24911. /**
  24912. * Defines the touch sensibility for rotation.
  24913. * The higher the faster.
  24914. */
  24915. touchAngularSensibility: number;
  24916. /**
  24917. * Defines the touch sensibility for move.
  24918. * The higher the faster.
  24919. */
  24920. touchMoveSensibility: number;
  24921. private _offsetX;
  24922. private _offsetY;
  24923. private _pointerPressed;
  24924. private _pointerInput?;
  24925. private _observer;
  24926. private _onLostFocus;
  24927. /**
  24928. * Manage the touch inputs to control the movement of a free camera.
  24929. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24930. * @param allowMouse Defines if mouse events can be treated as touch events
  24931. */
  24932. constructor(
  24933. /**
  24934. * Define if mouse events can be treated as touch events
  24935. */
  24936. allowMouse?: boolean);
  24937. /**
  24938. * Attach the input controls to a specific dom element to get the input from.
  24939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24940. */
  24941. attachControl(noPreventDefault?: boolean): void;
  24942. /**
  24943. * Detach the current controls from the specified dom element.
  24944. */
  24945. detachControl(): void;
  24946. /**
  24947. * Update the current camera state depending on the inputs that have been used this frame.
  24948. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  24949. */
  24950. checkInputs(): void;
  24951. /**
  24952. * Gets the class name of the current intput.
  24953. * @returns the class name
  24954. */
  24955. getClassName(): string;
  24956. /**
  24957. * Get the friendly name associated with the input class.
  24958. * @returns the input friendly name
  24959. */
  24960. getSimpleName(): string;
  24961. }
  24962. }
  24963. declare module BABYLON {
  24964. /**
  24965. * Default Inputs manager for the FreeCamera.
  24966. * It groups all the default supported inputs for ease of use.
  24967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  24968. */
  24969. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  24970. /**
  24971. * @hidden
  24972. */
  24973. _mouseInput: Nullable<FreeCameraMouseInput>;
  24974. /**
  24975. * @hidden
  24976. */
  24977. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  24978. /**
  24979. * Instantiates a new FreeCameraInputsManager.
  24980. * @param camera Defines the camera the inputs belong to
  24981. */
  24982. constructor(camera: FreeCamera);
  24983. /**
  24984. * Add keyboard input support to the input manager.
  24985. * @returns the current input manager
  24986. */
  24987. addKeyboard(): FreeCameraInputsManager;
  24988. /**
  24989. * Add mouse input support to the input manager.
  24990. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  24991. * @returns the current input manager
  24992. */
  24993. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  24994. /**
  24995. * Removes the mouse input support from the manager
  24996. * @returns the current input manager
  24997. */
  24998. removeMouse(): FreeCameraInputsManager;
  24999. /**
  25000. * Add mouse wheel input support to the input manager.
  25001. * @returns the current input manager
  25002. */
  25003. addMouseWheel(): FreeCameraInputsManager;
  25004. /**
  25005. * Removes the mouse wheel input support from the manager
  25006. * @returns the current input manager
  25007. */
  25008. removeMouseWheel(): FreeCameraInputsManager;
  25009. /**
  25010. * Add touch input support to the input manager.
  25011. * @returns the current input manager
  25012. */
  25013. addTouch(): FreeCameraInputsManager;
  25014. /**
  25015. * Remove all attached input methods from a camera
  25016. */
  25017. clear(): void;
  25018. }
  25019. }
  25020. declare module BABYLON {
  25021. /**
  25022. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25023. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  25024. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25025. */
  25026. export class FreeCamera extends TargetCamera {
  25027. /**
  25028. * Define the collision ellipsoid of the camera.
  25029. * This is helpful to simulate a camera body like the player body around the camera
  25030. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  25031. */
  25032. ellipsoid: Vector3;
  25033. /**
  25034. * Define an offset for the position of the ellipsoid around the camera.
  25035. * This can be helpful to determine the center of the body near the gravity center of the body
  25036. * instead of its head.
  25037. */
  25038. ellipsoidOffset: Vector3;
  25039. /**
  25040. * Enable or disable collisions of the camera with the rest of the scene objects.
  25041. */
  25042. checkCollisions: boolean;
  25043. /**
  25044. * Enable or disable gravity on the camera.
  25045. */
  25046. applyGravity: boolean;
  25047. /**
  25048. * Define the input manager associated to the camera.
  25049. */
  25050. inputs: FreeCameraInputsManager;
  25051. /**
  25052. * Gets the input sensibility for a mouse input. (default is 2000.0)
  25053. * Higher values reduce sensitivity.
  25054. */
  25055. get angularSensibility(): number;
  25056. /**
  25057. * Sets the input sensibility for a mouse input. (default is 2000.0)
  25058. * Higher values reduce sensitivity.
  25059. */
  25060. set angularSensibility(value: number);
  25061. /**
  25062. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  25063. */
  25064. get keysUp(): number[];
  25065. set keysUp(value: number[]);
  25066. /**
  25067. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  25068. */
  25069. get keysUpward(): number[];
  25070. set keysUpward(value: number[]);
  25071. /**
  25072. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  25073. */
  25074. get keysDown(): number[];
  25075. set keysDown(value: number[]);
  25076. /**
  25077. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  25078. */
  25079. get keysDownward(): number[];
  25080. set keysDownward(value: number[]);
  25081. /**
  25082. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  25083. */
  25084. get keysLeft(): number[];
  25085. set keysLeft(value: number[]);
  25086. /**
  25087. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  25088. */
  25089. get keysRight(): number[];
  25090. set keysRight(value: number[]);
  25091. /**
  25092. * Event raised when the camera collide with a mesh in the scene.
  25093. */
  25094. onCollide: (collidedMesh: AbstractMesh) => void;
  25095. private _collider;
  25096. private _needMoveForGravity;
  25097. private _oldPosition;
  25098. private _diffPosition;
  25099. private _newPosition;
  25100. /** @hidden */
  25101. _localDirection: Vector3;
  25102. /** @hidden */
  25103. _transformedDirection: Vector3;
  25104. /**
  25105. * Instantiates a Free Camera.
  25106. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  25107. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  25108. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  25109. * @param name Define the name of the camera in the scene
  25110. * @param position Define the start position of the camera in the scene
  25111. * @param scene Define the scene the camera belongs to
  25112. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  25113. */
  25114. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25115. /**
  25116. * Attach the input controls to a specific dom element to get the input from.
  25117. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25118. */
  25119. attachControl(noPreventDefault?: boolean): void;
  25120. /**
  25121. * Attach the input controls to a specific dom element to get the input from.
  25122. * @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
  25123. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25124. * BACK COMPAT SIGNATURE ONLY.
  25125. */
  25126. attachControl(ignored: any, noPreventDefault?: boolean): void;
  25127. /**
  25128. * Detach the current controls from the specified dom element.
  25129. */
  25130. detachControl(): void;
  25131. /**
  25132. * Detach the current controls from the specified dom element.
  25133. * @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
  25134. */
  25135. detachControl(ignored: any): void;
  25136. private _collisionMask;
  25137. /**
  25138. * Define a collision mask to limit the list of object the camera can collide with
  25139. */
  25140. get collisionMask(): number;
  25141. set collisionMask(mask: number);
  25142. /** @hidden */
  25143. _collideWithWorld(displacement: Vector3): void;
  25144. private _onCollisionPositionChange;
  25145. /** @hidden */
  25146. _checkInputs(): void;
  25147. /** @hidden */
  25148. _decideIfNeedsToMove(): boolean;
  25149. /** @hidden */
  25150. _updatePosition(): void;
  25151. /**
  25152. * Destroy the camera and release the current resources hold by it.
  25153. */
  25154. dispose(): void;
  25155. /**
  25156. * Gets the current object class name.
  25157. * @return the class name
  25158. */
  25159. getClassName(): string;
  25160. }
  25161. }
  25162. declare module BABYLON {
  25163. /**
  25164. * Represents a gamepad control stick position
  25165. */
  25166. export class StickValues {
  25167. /**
  25168. * The x component of the control stick
  25169. */
  25170. x: number;
  25171. /**
  25172. * The y component of the control stick
  25173. */
  25174. y: number;
  25175. /**
  25176. * Initializes the gamepad x and y control stick values
  25177. * @param x The x component of the gamepad control stick value
  25178. * @param y The y component of the gamepad control stick value
  25179. */
  25180. constructor(
  25181. /**
  25182. * The x component of the control stick
  25183. */
  25184. x: number,
  25185. /**
  25186. * The y component of the control stick
  25187. */
  25188. y: number);
  25189. }
  25190. /**
  25191. * An interface which manages callbacks for gamepad button changes
  25192. */
  25193. export interface GamepadButtonChanges {
  25194. /**
  25195. * Called when a gamepad has been changed
  25196. */
  25197. changed: boolean;
  25198. /**
  25199. * Called when a gamepad press event has been triggered
  25200. */
  25201. pressChanged: boolean;
  25202. /**
  25203. * Called when a touch event has been triggered
  25204. */
  25205. touchChanged: boolean;
  25206. /**
  25207. * Called when a value has changed
  25208. */
  25209. valueChanged: boolean;
  25210. }
  25211. /**
  25212. * Represents a gamepad
  25213. */
  25214. export class Gamepad {
  25215. /**
  25216. * The id of the gamepad
  25217. */
  25218. id: string;
  25219. /**
  25220. * The index of the gamepad
  25221. */
  25222. index: number;
  25223. /**
  25224. * The browser gamepad
  25225. */
  25226. browserGamepad: any;
  25227. /**
  25228. * Specifies what type of gamepad this represents
  25229. */
  25230. type: number;
  25231. private _leftStick;
  25232. private _rightStick;
  25233. /** @hidden */
  25234. _isConnected: boolean;
  25235. private _leftStickAxisX;
  25236. private _leftStickAxisY;
  25237. private _rightStickAxisX;
  25238. private _rightStickAxisY;
  25239. /**
  25240. * Triggered when the left control stick has been changed
  25241. */
  25242. private _onleftstickchanged;
  25243. /**
  25244. * Triggered when the right control stick has been changed
  25245. */
  25246. private _onrightstickchanged;
  25247. /**
  25248. * Represents a gamepad controller
  25249. */
  25250. static GAMEPAD: number;
  25251. /**
  25252. * Represents a generic controller
  25253. */
  25254. static GENERIC: number;
  25255. /**
  25256. * Represents an XBox controller
  25257. */
  25258. static XBOX: number;
  25259. /**
  25260. * Represents a pose-enabled controller
  25261. */
  25262. static POSE_ENABLED: number;
  25263. /**
  25264. * Represents an Dual Shock controller
  25265. */
  25266. static DUALSHOCK: number;
  25267. /**
  25268. * Specifies whether the left control stick should be Y-inverted
  25269. */
  25270. protected _invertLeftStickY: boolean;
  25271. /**
  25272. * Specifies if the gamepad has been connected
  25273. */
  25274. get isConnected(): boolean;
  25275. /**
  25276. * Initializes the gamepad
  25277. * @param id The id of the gamepad
  25278. * @param index The index of the gamepad
  25279. * @param browserGamepad The browser gamepad
  25280. * @param leftStickX The x component of the left joystick
  25281. * @param leftStickY The y component of the left joystick
  25282. * @param rightStickX The x component of the right joystick
  25283. * @param rightStickY The y component of the right joystick
  25284. */
  25285. constructor(
  25286. /**
  25287. * The id of the gamepad
  25288. */
  25289. id: string,
  25290. /**
  25291. * The index of the gamepad
  25292. */
  25293. index: number,
  25294. /**
  25295. * The browser gamepad
  25296. */
  25297. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  25298. /**
  25299. * Callback triggered when the left joystick has changed
  25300. * @param callback
  25301. */
  25302. onleftstickchanged(callback: (values: StickValues) => void): void;
  25303. /**
  25304. * Callback triggered when the right joystick has changed
  25305. * @param callback
  25306. */
  25307. onrightstickchanged(callback: (values: StickValues) => void): void;
  25308. /**
  25309. * Gets the left joystick
  25310. */
  25311. get leftStick(): StickValues;
  25312. /**
  25313. * Sets the left joystick values
  25314. */
  25315. set leftStick(newValues: StickValues);
  25316. /**
  25317. * Gets the right joystick
  25318. */
  25319. get rightStick(): StickValues;
  25320. /**
  25321. * Sets the right joystick value
  25322. */
  25323. set rightStick(newValues: StickValues);
  25324. /**
  25325. * Updates the gamepad joystick positions
  25326. */
  25327. update(): void;
  25328. /**
  25329. * Disposes the gamepad
  25330. */
  25331. dispose(): void;
  25332. }
  25333. /**
  25334. * Represents a generic gamepad
  25335. */
  25336. export class GenericPad extends Gamepad {
  25337. private _buttons;
  25338. private _onbuttondown;
  25339. private _onbuttonup;
  25340. /**
  25341. * Observable triggered when a button has been pressed
  25342. */
  25343. onButtonDownObservable: Observable<number>;
  25344. /**
  25345. * Observable triggered when a button has been released
  25346. */
  25347. onButtonUpObservable: Observable<number>;
  25348. /**
  25349. * Callback triggered when a button has been pressed
  25350. * @param callback Called when a button has been pressed
  25351. */
  25352. onbuttondown(callback: (buttonPressed: number) => void): void;
  25353. /**
  25354. * Callback triggered when a button has been released
  25355. * @param callback Called when a button has been released
  25356. */
  25357. onbuttonup(callback: (buttonReleased: number) => void): void;
  25358. /**
  25359. * Initializes the generic gamepad
  25360. * @param id The id of the generic gamepad
  25361. * @param index The index of the generic gamepad
  25362. * @param browserGamepad The browser gamepad
  25363. */
  25364. constructor(id: string, index: number, browserGamepad: any);
  25365. private _setButtonValue;
  25366. /**
  25367. * Updates the generic gamepad
  25368. */
  25369. update(): void;
  25370. /**
  25371. * Disposes the generic gamepad
  25372. */
  25373. dispose(): void;
  25374. }
  25375. }
  25376. declare module BABYLON {
  25377. /**
  25378. * Defines a runtime animation
  25379. */
  25380. export class RuntimeAnimation {
  25381. private _events;
  25382. /**
  25383. * The current frame of the runtime animation
  25384. */
  25385. private _currentFrame;
  25386. /**
  25387. * The animation used by the runtime animation
  25388. */
  25389. private _animation;
  25390. /**
  25391. * The target of the runtime animation
  25392. */
  25393. private _target;
  25394. /**
  25395. * The initiating animatable
  25396. */
  25397. private _host;
  25398. /**
  25399. * The original value of the runtime animation
  25400. */
  25401. private _originalValue;
  25402. /**
  25403. * The original blend value of the runtime animation
  25404. */
  25405. private _originalBlendValue;
  25406. /**
  25407. * The offsets cache of the runtime animation
  25408. */
  25409. private _offsetsCache;
  25410. /**
  25411. * The high limits cache of the runtime animation
  25412. */
  25413. private _highLimitsCache;
  25414. /**
  25415. * Specifies if the runtime animation has been stopped
  25416. */
  25417. private _stopped;
  25418. /**
  25419. * The blending factor of the runtime animation
  25420. */
  25421. private _blendingFactor;
  25422. /**
  25423. * The BabylonJS scene
  25424. */
  25425. private _scene;
  25426. /**
  25427. * The current value of the runtime animation
  25428. */
  25429. private _currentValue;
  25430. /** @hidden */
  25431. _animationState: _IAnimationState;
  25432. /**
  25433. * The active target of the runtime animation
  25434. */
  25435. private _activeTargets;
  25436. private _currentActiveTarget;
  25437. private _directTarget;
  25438. /**
  25439. * The target path of the runtime animation
  25440. */
  25441. private _targetPath;
  25442. /**
  25443. * The weight of the runtime animation
  25444. */
  25445. private _weight;
  25446. /**
  25447. * The ratio offset of the runtime animation
  25448. */
  25449. private _ratioOffset;
  25450. /**
  25451. * The previous delay of the runtime animation
  25452. */
  25453. private _previousDelay;
  25454. /**
  25455. * The previous ratio of the runtime animation
  25456. */
  25457. private _previousRatio;
  25458. private _enableBlending;
  25459. private _keys;
  25460. private _minFrame;
  25461. private _maxFrame;
  25462. private _minValue;
  25463. private _maxValue;
  25464. private _targetIsArray;
  25465. /**
  25466. * Gets the current frame of the runtime animation
  25467. */
  25468. get currentFrame(): number;
  25469. /**
  25470. * Gets the weight of the runtime animation
  25471. */
  25472. get weight(): number;
  25473. /**
  25474. * Gets the current value of the runtime animation
  25475. */
  25476. get currentValue(): any;
  25477. /**
  25478. * Gets the target path of the runtime animation
  25479. */
  25480. get targetPath(): string;
  25481. /**
  25482. * Gets the actual target of the runtime animation
  25483. */
  25484. get target(): any;
  25485. /**
  25486. * Gets the additive state of the runtime animation
  25487. */
  25488. get isAdditive(): boolean;
  25489. /** @hidden */
  25490. _onLoop: () => void;
  25491. /**
  25492. * Create a new RuntimeAnimation object
  25493. * @param target defines the target of the animation
  25494. * @param animation defines the source animation object
  25495. * @param scene defines the hosting scene
  25496. * @param host defines the initiating Animatable
  25497. */
  25498. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  25499. private _preparePath;
  25500. /**
  25501. * Gets the animation from the runtime animation
  25502. */
  25503. get animation(): Animation;
  25504. /**
  25505. * Resets the runtime animation to the beginning
  25506. * @param restoreOriginal defines whether to restore the target property to the original value
  25507. */
  25508. reset(restoreOriginal?: boolean): void;
  25509. /**
  25510. * Specifies if the runtime animation is stopped
  25511. * @returns Boolean specifying if the runtime animation is stopped
  25512. */
  25513. isStopped(): boolean;
  25514. /**
  25515. * Disposes of the runtime animation
  25516. */
  25517. dispose(): void;
  25518. /**
  25519. * Apply the interpolated value to the target
  25520. * @param currentValue defines the value computed by the animation
  25521. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  25522. */
  25523. setValue(currentValue: any, weight: number): void;
  25524. private _getOriginalValues;
  25525. private _setValue;
  25526. /**
  25527. * Gets the loop pmode of the runtime animation
  25528. * @returns Loop Mode
  25529. */
  25530. private _getCorrectLoopMode;
  25531. /**
  25532. * Move the current animation to a given frame
  25533. * @param frame defines the frame to move to
  25534. */
  25535. goToFrame(frame: number): void;
  25536. /**
  25537. * @hidden Internal use only
  25538. */
  25539. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  25540. /**
  25541. * Execute the current animation
  25542. * @param delay defines the delay to add to the current frame
  25543. * @param from defines the lower bound of the animation range
  25544. * @param to defines the upper bound of the animation range
  25545. * @param loop defines if the current animation must loop
  25546. * @param speedRatio defines the current speed ratio
  25547. * @param weight defines the weight of the animation (default is -1 so no weight)
  25548. * @param onLoop optional callback called when animation loops
  25549. * @returns a boolean indicating if the animation is running
  25550. */
  25551. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  25552. }
  25553. }
  25554. declare module BABYLON {
  25555. /**
  25556. * Class used to store an actual running animation
  25557. */
  25558. export class Animatable {
  25559. /** defines the target object */
  25560. target: any;
  25561. /** defines the starting frame number (default is 0) */
  25562. fromFrame: number;
  25563. /** defines the ending frame number (default is 100) */
  25564. toFrame: number;
  25565. /** defines if the animation must loop (default is false) */
  25566. loopAnimation: boolean;
  25567. /** defines a callback to call when animation ends if it is not looping */
  25568. onAnimationEnd?: (() => void) | null | undefined;
  25569. /** defines a callback to call when animation loops */
  25570. onAnimationLoop?: (() => void) | null | undefined;
  25571. /** defines whether the animation should be evaluated additively */
  25572. isAdditive: boolean;
  25573. private _localDelayOffset;
  25574. private _pausedDelay;
  25575. private _runtimeAnimations;
  25576. private _paused;
  25577. private _scene;
  25578. private _speedRatio;
  25579. private _weight;
  25580. private _syncRoot;
  25581. /**
  25582. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  25583. * This will only apply for non looping animation (default is true)
  25584. */
  25585. disposeOnEnd: boolean;
  25586. /**
  25587. * Gets a boolean indicating if the animation has started
  25588. */
  25589. animationStarted: boolean;
  25590. /**
  25591. * Observer raised when the animation ends
  25592. */
  25593. onAnimationEndObservable: Observable<Animatable>;
  25594. /**
  25595. * Observer raised when the animation loops
  25596. */
  25597. onAnimationLoopObservable: Observable<Animatable>;
  25598. /**
  25599. * Gets the root Animatable used to synchronize and normalize animations
  25600. */
  25601. get syncRoot(): Nullable<Animatable>;
  25602. /**
  25603. * Gets the current frame of the first RuntimeAnimation
  25604. * Used to synchronize Animatables
  25605. */
  25606. get masterFrame(): number;
  25607. /**
  25608. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  25609. */
  25610. get weight(): number;
  25611. set weight(value: number);
  25612. /**
  25613. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  25614. */
  25615. get speedRatio(): number;
  25616. set speedRatio(value: number);
  25617. /**
  25618. * Creates a new Animatable
  25619. * @param scene defines the hosting scene
  25620. * @param target defines the target object
  25621. * @param fromFrame defines the starting frame number (default is 0)
  25622. * @param toFrame defines the ending frame number (default is 100)
  25623. * @param loopAnimation defines if the animation must loop (default is false)
  25624. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  25625. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  25626. * @param animations defines a group of animation to add to the new Animatable
  25627. * @param onAnimationLoop defines a callback to call when animation loops
  25628. * @param isAdditive defines whether the animation should be evaluated additively
  25629. */
  25630. constructor(scene: Scene,
  25631. /** defines the target object */
  25632. target: any,
  25633. /** defines the starting frame number (default is 0) */
  25634. fromFrame?: number,
  25635. /** defines the ending frame number (default is 100) */
  25636. toFrame?: number,
  25637. /** defines if the animation must loop (default is false) */
  25638. loopAnimation?: boolean, speedRatio?: number,
  25639. /** defines a callback to call when animation ends if it is not looping */
  25640. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  25641. /** defines a callback to call when animation loops */
  25642. onAnimationLoop?: (() => void) | null | undefined,
  25643. /** defines whether the animation should be evaluated additively */
  25644. isAdditive?: boolean);
  25645. /**
  25646. * Synchronize and normalize current Animatable with a source Animatable
  25647. * This is useful when using animation weights and when animations are not of the same length
  25648. * @param root defines the root Animatable to synchronize with
  25649. * @returns the current Animatable
  25650. */
  25651. syncWith(root: Animatable): Animatable;
  25652. /**
  25653. * Gets the list of runtime animations
  25654. * @returns an array of RuntimeAnimation
  25655. */
  25656. getAnimations(): RuntimeAnimation[];
  25657. /**
  25658. * Adds more animations to the current animatable
  25659. * @param target defines the target of the animations
  25660. * @param animations defines the new animations to add
  25661. */
  25662. appendAnimations(target: any, animations: Animation[]): void;
  25663. /**
  25664. * Gets the source animation for a specific property
  25665. * @param property defines the propertyu to look for
  25666. * @returns null or the source animation for the given property
  25667. */
  25668. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  25669. /**
  25670. * Gets the runtime animation for a specific property
  25671. * @param property defines the propertyu to look for
  25672. * @returns null or the runtime animation for the given property
  25673. */
  25674. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  25675. /**
  25676. * Resets the animatable to its original state
  25677. */
  25678. reset(): void;
  25679. /**
  25680. * Allows the animatable to blend with current running animations
  25681. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25682. * @param blendingSpeed defines the blending speed to use
  25683. */
  25684. enableBlending(blendingSpeed: number): void;
  25685. /**
  25686. * Disable animation blending
  25687. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  25688. */
  25689. disableBlending(): void;
  25690. /**
  25691. * Jump directly to a given frame
  25692. * @param frame defines the frame to jump to
  25693. */
  25694. goToFrame(frame: number): void;
  25695. /**
  25696. * Pause the animation
  25697. */
  25698. pause(): void;
  25699. /**
  25700. * Restart the animation
  25701. */
  25702. restart(): void;
  25703. private _raiseOnAnimationEnd;
  25704. /**
  25705. * Stop and delete the current animation
  25706. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  25707. * @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)
  25708. */
  25709. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  25710. /**
  25711. * Wait asynchronously for the animation to end
  25712. * @returns a promise which will be fullfilled when the animation ends
  25713. */
  25714. waitAsync(): Promise<Animatable>;
  25715. /** @hidden */
  25716. _animate(delay: number): boolean;
  25717. }
  25718. interface Scene {
  25719. /** @hidden */
  25720. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  25721. /** @hidden */
  25722. _processLateAnimationBindingsForMatrices(holder: {
  25723. totalWeight: number;
  25724. totalAdditiveWeight: number;
  25725. animations: RuntimeAnimation[];
  25726. additiveAnimations: RuntimeAnimation[];
  25727. originalValue: Matrix;
  25728. }): any;
  25729. /** @hidden */
  25730. _processLateAnimationBindingsForQuaternions(holder: {
  25731. totalWeight: number;
  25732. totalAdditiveWeight: number;
  25733. animations: RuntimeAnimation[];
  25734. additiveAnimations: RuntimeAnimation[];
  25735. originalValue: Quaternion;
  25736. }, refQuaternion: Quaternion): Quaternion;
  25737. /** @hidden */
  25738. _processLateAnimationBindings(): void;
  25739. /**
  25740. * Will start the animation sequence of a given target
  25741. * @param target defines the target
  25742. * @param from defines from which frame should animation start
  25743. * @param to defines until which frame should animation run.
  25744. * @param weight defines the weight to apply to the animation (1.0 by default)
  25745. * @param loop defines if the animation loops
  25746. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25747. * @param onAnimationEnd defines the function to be executed when the animation ends
  25748. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25749. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25750. * @param onAnimationLoop defines the callback to call when an animation loops
  25751. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25752. * @returns the animatable object created for this animation
  25753. */
  25754. 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;
  25755. /**
  25756. * Will start the animation sequence of a given target
  25757. * @param target defines the target
  25758. * @param from defines from which frame should animation start
  25759. * @param to defines until which frame should animation run.
  25760. * @param loop defines if the animation loops
  25761. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25762. * @param onAnimationEnd defines the function to be executed when the animation ends
  25763. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25764. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25765. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  25766. * @param onAnimationLoop defines the callback to call when an animation loops
  25767. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25768. * @returns the animatable object created for this animation
  25769. */
  25770. 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;
  25771. /**
  25772. * Will start the animation sequence of a given target and its hierarchy
  25773. * @param target defines the target
  25774. * @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.
  25775. * @param from defines from which frame should animation start
  25776. * @param to defines until which frame should animation run.
  25777. * @param loop defines if the animation loops
  25778. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  25779. * @param onAnimationEnd defines the function to be executed when the animation ends
  25780. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  25781. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  25782. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  25783. * @param onAnimationLoop defines the callback to call when an animation loops
  25784. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25785. * @returns the list of created animatables
  25786. */
  25787. 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[];
  25788. /**
  25789. * Begin a new animation on a given node
  25790. * @param target defines the target where the animation will take place
  25791. * @param animations defines the list of animations to start
  25792. * @param from defines the initial value
  25793. * @param to defines the final value
  25794. * @param loop defines if you want animation to loop (off by default)
  25795. * @param speedRatio defines the speed ratio to apply to all animations
  25796. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25797. * @param onAnimationLoop defines the callback to call when an animation loops
  25798. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25799. * @returns the list of created animatables
  25800. */
  25801. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  25802. /**
  25803. * Begin a new animation on a given node and its hierarchy
  25804. * @param target defines the root node where the animation will take place
  25805. * @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.
  25806. * @param animations defines the list of animations to start
  25807. * @param from defines the initial value
  25808. * @param to defines the final value
  25809. * @param loop defines if you want animation to loop (off by default)
  25810. * @param speedRatio defines the speed ratio to apply to all animations
  25811. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25812. * @param onAnimationLoop defines the callback to call when an animation loops
  25813. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  25814. * @returns the list of animatables created for all nodes
  25815. */
  25816. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  25817. /**
  25818. * Gets the animatable associated with a specific target
  25819. * @param target defines the target of the animatable
  25820. * @returns the required animatable if found
  25821. */
  25822. getAnimatableByTarget(target: any): Nullable<Animatable>;
  25823. /**
  25824. * Gets all animatables associated with a given target
  25825. * @param target defines the target to look animatables for
  25826. * @returns an array of Animatables
  25827. */
  25828. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  25829. /**
  25830. * Stops and removes all animations that have been applied to the scene
  25831. */
  25832. stopAllAnimations(): void;
  25833. /**
  25834. * Gets the current delta time used by animation engine
  25835. */
  25836. deltaTime: number;
  25837. }
  25838. interface Bone {
  25839. /**
  25840. * Copy an animation range from another bone
  25841. * @param source defines the source bone
  25842. * @param rangeName defines the range name to copy
  25843. * @param frameOffset defines the frame offset
  25844. * @param rescaleAsRequired defines if rescaling must be applied if required
  25845. * @param skelDimensionsRatio defines the scaling ratio
  25846. * @returns true if operation was successful
  25847. */
  25848. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  25849. }
  25850. }
  25851. declare module BABYLON {
  25852. /**
  25853. * Class used to override all child animations of a given target
  25854. */
  25855. export class AnimationPropertiesOverride {
  25856. /**
  25857. * Gets or sets a value indicating if animation blending must be used
  25858. */
  25859. enableBlending: boolean;
  25860. /**
  25861. * Gets or sets the blending speed to use when enableBlending is true
  25862. */
  25863. blendingSpeed: number;
  25864. /**
  25865. * Gets or sets the default loop mode to use
  25866. */
  25867. loopMode: number;
  25868. }
  25869. }
  25870. declare module BABYLON {
  25871. /**
  25872. * Class used to handle skinning animations
  25873. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25874. */
  25875. export class Skeleton implements IAnimatable {
  25876. /** defines the skeleton name */
  25877. name: string;
  25878. /** defines the skeleton Id */
  25879. id: string;
  25880. /**
  25881. * Defines the list of child bones
  25882. */
  25883. bones: Bone[];
  25884. /**
  25885. * Defines an estimate of the dimension of the skeleton at rest
  25886. */
  25887. dimensionsAtRest: Vector3;
  25888. /**
  25889. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  25890. */
  25891. needInitialSkinMatrix: boolean;
  25892. /**
  25893. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  25894. */
  25895. overrideMesh: Nullable<AbstractMesh>;
  25896. /**
  25897. * Gets the list of animations attached to this skeleton
  25898. */
  25899. animations: Array<Animation>;
  25900. private _scene;
  25901. private _isDirty;
  25902. private _transformMatrices;
  25903. private _transformMatrixTexture;
  25904. private _meshesWithPoseMatrix;
  25905. private _animatables;
  25906. private _identity;
  25907. private _synchronizedWithMesh;
  25908. private _ranges;
  25909. private _lastAbsoluteTransformsUpdateId;
  25910. private _canUseTextureForBones;
  25911. private _uniqueId;
  25912. /** @hidden */
  25913. _numBonesWithLinkedTransformNode: number;
  25914. /** @hidden */
  25915. _hasWaitingData: Nullable<boolean>;
  25916. /** @hidden */
  25917. _waitingOverrideMeshId: Nullable<string>;
  25918. /**
  25919. * Specifies if the skeleton should be serialized
  25920. */
  25921. doNotSerialize: boolean;
  25922. private _useTextureToStoreBoneMatrices;
  25923. /**
  25924. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  25925. * Please note that this option is not available if the hardware does not support it
  25926. */
  25927. get useTextureToStoreBoneMatrices(): boolean;
  25928. set useTextureToStoreBoneMatrices(value: boolean);
  25929. private _animationPropertiesOverride;
  25930. /**
  25931. * Gets or sets the animation properties override
  25932. */
  25933. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  25934. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  25935. /**
  25936. * List of inspectable custom properties (used by the Inspector)
  25937. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25938. */
  25939. inspectableCustomProperties: IInspectable[];
  25940. /**
  25941. * An observable triggered before computing the skeleton's matrices
  25942. */
  25943. onBeforeComputeObservable: Observable<Skeleton>;
  25944. /**
  25945. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  25946. */
  25947. get isUsingTextureForMatrices(): boolean;
  25948. /**
  25949. * Gets the unique ID of this skeleton
  25950. */
  25951. get uniqueId(): number;
  25952. /**
  25953. * Creates a new skeleton
  25954. * @param name defines the skeleton name
  25955. * @param id defines the skeleton Id
  25956. * @param scene defines the hosting scene
  25957. */
  25958. constructor(
  25959. /** defines the skeleton name */
  25960. name: string,
  25961. /** defines the skeleton Id */
  25962. id: string, scene: Scene);
  25963. /**
  25964. * Gets the current object class name.
  25965. * @return the class name
  25966. */
  25967. getClassName(): string;
  25968. /**
  25969. * Returns an array containing the root bones
  25970. * @returns an array containing the root bones
  25971. */
  25972. getChildren(): Array<Bone>;
  25973. /**
  25974. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  25975. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25976. * @returns a Float32Array containing matrices data
  25977. */
  25978. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  25979. /**
  25980. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  25981. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  25982. * @returns a raw texture containing the data
  25983. */
  25984. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  25985. /**
  25986. * Gets the current hosting scene
  25987. * @returns a scene object
  25988. */
  25989. getScene(): Scene;
  25990. /**
  25991. * Gets a string representing the current skeleton data
  25992. * @param fullDetails defines a boolean indicating if we want a verbose version
  25993. * @returns a string representing the current skeleton data
  25994. */
  25995. toString(fullDetails?: boolean): string;
  25996. /**
  25997. * Get bone's index searching by name
  25998. * @param name defines bone's name to search for
  25999. * @return the indice of the bone. Returns -1 if not found
  26000. */
  26001. getBoneIndexByName(name: string): number;
  26002. /**
  26003. * Creater a new animation range
  26004. * @param name defines the name of the range
  26005. * @param from defines the start key
  26006. * @param to defines the end key
  26007. */
  26008. createAnimationRange(name: string, from: number, to: number): void;
  26009. /**
  26010. * Delete a specific animation range
  26011. * @param name defines the name of the range
  26012. * @param deleteFrames defines if frames must be removed as well
  26013. */
  26014. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26015. /**
  26016. * Gets a specific animation range
  26017. * @param name defines the name of the range to look for
  26018. * @returns the requested animation range or null if not found
  26019. */
  26020. getAnimationRange(name: string): Nullable<AnimationRange>;
  26021. /**
  26022. * Gets the list of all animation ranges defined on this skeleton
  26023. * @returns an array
  26024. */
  26025. getAnimationRanges(): Nullable<AnimationRange>[];
  26026. /**
  26027. * Copy animation range from a source skeleton.
  26028. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  26029. * @param source defines the source skeleton
  26030. * @param name defines the name of the range to copy
  26031. * @param rescaleAsRequired defines if rescaling must be applied if required
  26032. * @returns true if operation was successful
  26033. */
  26034. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  26035. /**
  26036. * Forces the skeleton to go to rest pose
  26037. */
  26038. returnToRest(): void;
  26039. private _getHighestAnimationFrame;
  26040. /**
  26041. * Begin a specific animation range
  26042. * @param name defines the name of the range to start
  26043. * @param loop defines if looping must be turned on (false by default)
  26044. * @param speedRatio defines the speed ratio to apply (1 by default)
  26045. * @param onAnimationEnd defines a callback which will be called when animation will end
  26046. * @returns a new animatable
  26047. */
  26048. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26049. /**
  26050. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  26051. * @param skeleton defines the Skeleton containing the animation range to convert
  26052. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  26053. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  26054. * @returns the original skeleton
  26055. */
  26056. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  26057. /** @hidden */
  26058. _markAsDirty(): void;
  26059. /** @hidden */
  26060. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26061. /** @hidden */
  26062. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  26063. private _computeTransformMatrices;
  26064. /**
  26065. * Build all resources required to render a skeleton
  26066. */
  26067. prepare(): void;
  26068. /**
  26069. * Gets the list of animatables currently running for this skeleton
  26070. * @returns an array of animatables
  26071. */
  26072. getAnimatables(): IAnimatable[];
  26073. /**
  26074. * Clone the current skeleton
  26075. * @param name defines the name of the new skeleton
  26076. * @param id defines the id of the new skeleton
  26077. * @returns the new skeleton
  26078. */
  26079. clone(name: string, id?: string): Skeleton;
  26080. /**
  26081. * Enable animation blending for this skeleton
  26082. * @param blendingSpeed defines the blending speed to apply
  26083. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  26084. */
  26085. enableBlending(blendingSpeed?: number): void;
  26086. /**
  26087. * Releases all resources associated with the current skeleton
  26088. */
  26089. dispose(): void;
  26090. /**
  26091. * Serialize the skeleton in a JSON object
  26092. * @returns a JSON object
  26093. */
  26094. serialize(): any;
  26095. /**
  26096. * Creates a new skeleton from serialized data
  26097. * @param parsedSkeleton defines the serialized data
  26098. * @param scene defines the hosting scene
  26099. * @returns a new skeleton
  26100. */
  26101. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  26102. /**
  26103. * Compute all node absolute transforms
  26104. * @param forceUpdate defines if computation must be done even if cache is up to date
  26105. */
  26106. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  26107. /**
  26108. * Gets the root pose matrix
  26109. * @returns a matrix
  26110. */
  26111. getPoseMatrix(): Nullable<Matrix>;
  26112. /**
  26113. * Sorts bones per internal index
  26114. */
  26115. sortBones(): void;
  26116. private _sortBones;
  26117. /**
  26118. * Set the current local matrix as the restPose for all bones in the skeleton.
  26119. */
  26120. setCurrentPoseAsRest(): void;
  26121. }
  26122. }
  26123. declare module BABYLON {
  26124. /**
  26125. * Class used to store bone information
  26126. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26127. */
  26128. export class Bone extends Node {
  26129. /**
  26130. * defines the bone name
  26131. */
  26132. name: string;
  26133. private static _tmpVecs;
  26134. private static _tmpQuat;
  26135. private static _tmpMats;
  26136. /**
  26137. * Gets the list of child bones
  26138. */
  26139. children: Bone[];
  26140. /** Gets the animations associated with this bone */
  26141. animations: Animation[];
  26142. /**
  26143. * Gets or sets bone length
  26144. */
  26145. length: number;
  26146. /**
  26147. * @hidden Internal only
  26148. * Set this value to map this bone to a different index in the transform matrices
  26149. * Set this value to -1 to exclude the bone from the transform matrices
  26150. */
  26151. _index: Nullable<number>;
  26152. private _skeleton;
  26153. private _localMatrix;
  26154. private _restPose;
  26155. private _bindPose;
  26156. private _baseMatrix;
  26157. private _absoluteTransform;
  26158. private _invertedAbsoluteTransform;
  26159. private _parent;
  26160. private _scalingDeterminant;
  26161. private _worldTransform;
  26162. private _localScaling;
  26163. private _localRotation;
  26164. private _localPosition;
  26165. private _needToDecompose;
  26166. private _needToCompose;
  26167. /** @hidden */
  26168. _linkedTransformNode: Nullable<TransformNode>;
  26169. /** @hidden */
  26170. _waitingTransformNodeId: Nullable<string>;
  26171. /** @hidden */
  26172. get _matrix(): Matrix;
  26173. /** @hidden */
  26174. set _matrix(value: Matrix);
  26175. /**
  26176. * Create a new bone
  26177. * @param name defines the bone name
  26178. * @param skeleton defines the parent skeleton
  26179. * @param parentBone defines the parent (can be null if the bone is the root)
  26180. * @param localMatrix defines the local matrix
  26181. * @param restPose defines the rest pose matrix
  26182. * @param baseMatrix defines the base matrix
  26183. * @param index defines index of the bone in the hiearchy
  26184. */
  26185. constructor(
  26186. /**
  26187. * defines the bone name
  26188. */
  26189. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  26190. /**
  26191. * Gets the current object class name.
  26192. * @return the class name
  26193. */
  26194. getClassName(): string;
  26195. /**
  26196. * Gets the parent skeleton
  26197. * @returns a skeleton
  26198. */
  26199. getSkeleton(): Skeleton;
  26200. /**
  26201. * Gets parent bone
  26202. * @returns a bone or null if the bone is the root of the bone hierarchy
  26203. */
  26204. getParent(): Nullable<Bone>;
  26205. /**
  26206. * Returns an array containing the root bones
  26207. * @returns an array containing the root bones
  26208. */
  26209. getChildren(): Array<Bone>;
  26210. /**
  26211. * Gets the node index in matrix array generated for rendering
  26212. * @returns the node index
  26213. */
  26214. getIndex(): number;
  26215. /**
  26216. * Sets the parent bone
  26217. * @param parent defines the parent (can be null if the bone is the root)
  26218. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26219. */
  26220. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  26221. /**
  26222. * Gets the local matrix
  26223. * @returns a matrix
  26224. */
  26225. getLocalMatrix(): Matrix;
  26226. /**
  26227. * Gets the base matrix (initial matrix which remains unchanged)
  26228. * @returns a matrix
  26229. */
  26230. getBaseMatrix(): Matrix;
  26231. /**
  26232. * Gets the rest pose matrix
  26233. * @returns a matrix
  26234. */
  26235. getRestPose(): Matrix;
  26236. /**
  26237. * Sets the rest pose matrix
  26238. * @param matrix the local-space rest pose to set for this bone
  26239. */
  26240. setRestPose(matrix: Matrix): void;
  26241. /**
  26242. * Gets the bind pose matrix
  26243. * @returns the bind pose matrix
  26244. */
  26245. getBindPose(): Matrix;
  26246. /**
  26247. * Sets the bind pose matrix
  26248. * @param matrix the local-space bind pose to set for this bone
  26249. */
  26250. setBindPose(matrix: Matrix): void;
  26251. /**
  26252. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  26253. */
  26254. getWorldMatrix(): Matrix;
  26255. /**
  26256. * Sets the local matrix to rest pose matrix
  26257. */
  26258. returnToRest(): void;
  26259. /**
  26260. * Gets the inverse of the absolute transform matrix.
  26261. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  26262. * @returns a matrix
  26263. */
  26264. getInvertedAbsoluteTransform(): Matrix;
  26265. /**
  26266. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  26267. * @returns a matrix
  26268. */
  26269. getAbsoluteTransform(): Matrix;
  26270. /**
  26271. * Links with the given transform node.
  26272. * The local matrix of this bone is copied from the transform node every frame.
  26273. * @param transformNode defines the transform node to link to
  26274. */
  26275. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  26276. /**
  26277. * Gets the node used to drive the bone's transformation
  26278. * @returns a transform node or null
  26279. */
  26280. getTransformNode(): Nullable<TransformNode>;
  26281. /** Gets or sets current position (in local space) */
  26282. get position(): Vector3;
  26283. set position(newPosition: Vector3);
  26284. /** Gets or sets current rotation (in local space) */
  26285. get rotation(): Vector3;
  26286. set rotation(newRotation: Vector3);
  26287. /** Gets or sets current rotation quaternion (in local space) */
  26288. get rotationQuaternion(): Quaternion;
  26289. set rotationQuaternion(newRotation: Quaternion);
  26290. /** Gets or sets current scaling (in local space) */
  26291. get scaling(): Vector3;
  26292. set scaling(newScaling: Vector3);
  26293. /**
  26294. * Gets the animation properties override
  26295. */
  26296. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26297. private _decompose;
  26298. private _compose;
  26299. /**
  26300. * Update the base and local matrices
  26301. * @param matrix defines the new base or local matrix
  26302. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  26303. * @param updateLocalMatrix defines if the local matrix should be updated
  26304. */
  26305. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  26306. /** @hidden */
  26307. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  26308. /**
  26309. * Flag the bone as dirty (Forcing it to update everything)
  26310. */
  26311. markAsDirty(): void;
  26312. /** @hidden */
  26313. _markAsDirtyAndCompose(): void;
  26314. private _markAsDirtyAndDecompose;
  26315. /**
  26316. * Translate the bone in local or world space
  26317. * @param vec The amount to translate the bone
  26318. * @param space The space that the translation is in
  26319. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26320. */
  26321. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26322. /**
  26323. * Set the postion of the bone in local or world space
  26324. * @param position The position to set the bone
  26325. * @param space The space that the position is in
  26326. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26327. */
  26328. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26329. /**
  26330. * Set the absolute position of the bone (world space)
  26331. * @param position The position to set the bone
  26332. * @param mesh The mesh that this bone is attached to
  26333. */
  26334. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  26335. /**
  26336. * Scale the bone on the x, y and z axes (in local space)
  26337. * @param x The amount to scale the bone on the x axis
  26338. * @param y The amount to scale the bone on the y axis
  26339. * @param z The amount to scale the bone on the z axis
  26340. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  26341. */
  26342. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  26343. /**
  26344. * Set the bone scaling in local space
  26345. * @param scale defines the scaling vector
  26346. */
  26347. setScale(scale: Vector3): void;
  26348. /**
  26349. * Gets the current scaling in local space
  26350. * @returns the current scaling vector
  26351. */
  26352. getScale(): Vector3;
  26353. /**
  26354. * Gets the current scaling in local space and stores it in a target vector
  26355. * @param result defines the target vector
  26356. */
  26357. getScaleToRef(result: Vector3): void;
  26358. /**
  26359. * Set the yaw, pitch, and roll of the bone in local or world space
  26360. * @param yaw The rotation of the bone on the y axis
  26361. * @param pitch The rotation of the bone on the x axis
  26362. * @param roll The rotation of the bone on the z axis
  26363. * @param space The space that the axes of rotation are in
  26364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26365. */
  26366. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  26367. /**
  26368. * Add a rotation to the bone on an axis in local or world space
  26369. * @param axis The axis to rotate the bone on
  26370. * @param amount The amount to rotate the bone
  26371. * @param space The space that the axis is in
  26372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26373. */
  26374. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  26375. /**
  26376. * Set the rotation of the bone to a particular axis angle in local or world space
  26377. * @param axis The axis to rotate the bone on
  26378. * @param angle The angle that the bone should be rotated to
  26379. * @param space The space that the axis is in
  26380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26381. */
  26382. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  26383. /**
  26384. * Set the euler rotation of the bone in local or world space
  26385. * @param rotation The euler rotation that the bone should be set to
  26386. * @param space The space that the rotation is in
  26387. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26388. */
  26389. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  26390. /**
  26391. * Set the quaternion rotation of the bone in local or world space
  26392. * @param quat The quaternion rotation that the bone should be set to
  26393. * @param space The space that the rotation is in
  26394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26395. */
  26396. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  26397. /**
  26398. * Set the rotation matrix of the bone in local or world space
  26399. * @param rotMat The rotation matrix that the bone should be set to
  26400. * @param space The space that the rotation is in
  26401. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26402. */
  26403. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  26404. private _rotateWithMatrix;
  26405. private _getNegativeRotationToRef;
  26406. /**
  26407. * Get the position of the bone in local or world space
  26408. * @param space The space that the returned position is in
  26409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26410. * @returns The position of the bone
  26411. */
  26412. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26413. /**
  26414. * Copy the position of the bone to a vector3 in local or world space
  26415. * @param space The space that the returned position is in
  26416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26417. * @param result The vector3 to copy the position to
  26418. */
  26419. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  26420. /**
  26421. * Get the absolute position of the bone (world space)
  26422. * @param mesh The mesh that this bone is attached to
  26423. * @returns The absolute position of the bone
  26424. */
  26425. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  26426. /**
  26427. * Copy the absolute position of the bone (world space) to the result param
  26428. * @param mesh The mesh that this bone is attached to
  26429. * @param result The vector3 to copy the absolute position to
  26430. */
  26431. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  26432. /**
  26433. * Compute the absolute transforms of this bone and its children
  26434. */
  26435. computeAbsoluteTransforms(): void;
  26436. /**
  26437. * Get the world direction from an axis that is in the local space of the bone
  26438. * @param localAxis The local direction that is used to compute the world direction
  26439. * @param mesh The mesh that this bone is attached to
  26440. * @returns The world direction
  26441. */
  26442. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26443. /**
  26444. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  26445. * @param localAxis The local direction that is used to compute the world direction
  26446. * @param mesh The mesh that this bone is attached to
  26447. * @param result The vector3 that the world direction will be copied to
  26448. */
  26449. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26450. /**
  26451. * Get the euler rotation of the bone in local or world space
  26452. * @param space The space that the rotation should be in
  26453. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26454. * @returns The euler rotation
  26455. */
  26456. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  26457. /**
  26458. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  26459. * @param space The space that the rotation should be in
  26460. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26461. * @param result The vector3 that the rotation should be copied to
  26462. */
  26463. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26464. /**
  26465. * Get the quaternion rotation of the bone in either local or world space
  26466. * @param space The space that the rotation should be in
  26467. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26468. * @returns The quaternion rotation
  26469. */
  26470. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  26471. /**
  26472. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  26473. * @param space The space that the rotation should be in
  26474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26475. * @param result The quaternion that the rotation should be copied to
  26476. */
  26477. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  26478. /**
  26479. * Get the rotation matrix of the bone in local or world space
  26480. * @param space The space that the rotation should be in
  26481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26482. * @returns The rotation matrix
  26483. */
  26484. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  26485. /**
  26486. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  26487. * @param space The space that the rotation should be in
  26488. * @param mesh The mesh that this bone is attached to. This is only used in world space
  26489. * @param result The quaternion that the rotation should be copied to
  26490. */
  26491. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  26492. /**
  26493. * Get the world position of a point that is in the local space of the bone
  26494. * @param position The local position
  26495. * @param mesh The mesh that this bone is attached to
  26496. * @returns The world position
  26497. */
  26498. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26499. /**
  26500. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  26501. * @param position The local position
  26502. * @param mesh The mesh that this bone is attached to
  26503. * @param result The vector3 that the world position should be copied to
  26504. */
  26505. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26506. /**
  26507. * Get the local position of a point that is in world space
  26508. * @param position The world position
  26509. * @param mesh The mesh that this bone is attached to
  26510. * @returns The local position
  26511. */
  26512. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  26513. /**
  26514. * Get the local position of a point that is in world space and copy it to the result param
  26515. * @param position The world position
  26516. * @param mesh The mesh that this bone is attached to
  26517. * @param result The vector3 that the local position should be copied to
  26518. */
  26519. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  26520. /**
  26521. * Set the current local matrix as the restPose for this bone.
  26522. */
  26523. setCurrentPoseAsRest(): void;
  26524. }
  26525. }
  26526. declare module BABYLON {
  26527. /**
  26528. * 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.
  26529. * @see https://doc.babylonjs.com/how_to/transformnode
  26530. */
  26531. export class TransformNode extends Node {
  26532. /**
  26533. * Object will not rotate to face the camera
  26534. */
  26535. static BILLBOARDMODE_NONE: number;
  26536. /**
  26537. * Object will rotate to face the camera but only on the x axis
  26538. */
  26539. static BILLBOARDMODE_X: number;
  26540. /**
  26541. * Object will rotate to face the camera but only on the y axis
  26542. */
  26543. static BILLBOARDMODE_Y: number;
  26544. /**
  26545. * Object will rotate to face the camera but only on the z axis
  26546. */
  26547. static BILLBOARDMODE_Z: number;
  26548. /**
  26549. * Object will rotate to face the camera
  26550. */
  26551. static BILLBOARDMODE_ALL: number;
  26552. /**
  26553. * Object will rotate to face the camera's position instead of orientation
  26554. */
  26555. static BILLBOARDMODE_USE_POSITION: number;
  26556. private static _TmpRotation;
  26557. private static _TmpScaling;
  26558. private static _TmpTranslation;
  26559. private _forward;
  26560. private _forwardInverted;
  26561. private _up;
  26562. private _right;
  26563. private _rightInverted;
  26564. private _position;
  26565. private _rotation;
  26566. private _rotationQuaternion;
  26567. protected _scaling: Vector3;
  26568. protected _isDirty: boolean;
  26569. private _transformToBoneReferal;
  26570. private _isAbsoluteSynced;
  26571. private _billboardMode;
  26572. /**
  26573. * Gets or sets the billboard mode. Default is 0.
  26574. *
  26575. * | Value | Type | Description |
  26576. * | --- | --- | --- |
  26577. * | 0 | BILLBOARDMODE_NONE | |
  26578. * | 1 | BILLBOARDMODE_X | |
  26579. * | 2 | BILLBOARDMODE_Y | |
  26580. * | 4 | BILLBOARDMODE_Z | |
  26581. * | 7 | BILLBOARDMODE_ALL | |
  26582. *
  26583. */
  26584. get billboardMode(): number;
  26585. set billboardMode(value: number);
  26586. private _preserveParentRotationForBillboard;
  26587. /**
  26588. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  26589. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  26590. */
  26591. get preserveParentRotationForBillboard(): boolean;
  26592. set preserveParentRotationForBillboard(value: boolean);
  26593. /**
  26594. * 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
  26595. */
  26596. scalingDeterminant: number;
  26597. private _infiniteDistance;
  26598. /**
  26599. * Gets or sets the distance of the object to max, often used by skybox
  26600. */
  26601. get infiniteDistance(): boolean;
  26602. set infiniteDistance(value: boolean);
  26603. /**
  26604. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  26605. * By default the system will update normals to compensate
  26606. */
  26607. ignoreNonUniformScaling: boolean;
  26608. /**
  26609. * 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
  26610. */
  26611. reIntegrateRotationIntoRotationQuaternion: boolean;
  26612. /** @hidden */
  26613. _poseMatrix: Nullable<Matrix>;
  26614. /** @hidden */
  26615. _localMatrix: Matrix;
  26616. private _usePivotMatrix;
  26617. private _absolutePosition;
  26618. private _absoluteScaling;
  26619. private _absoluteRotationQuaternion;
  26620. private _pivotMatrix;
  26621. private _pivotMatrixInverse;
  26622. /** @hidden */
  26623. _postMultiplyPivotMatrix: boolean;
  26624. protected _isWorldMatrixFrozen: boolean;
  26625. /** @hidden */
  26626. _indexInSceneTransformNodesArray: number;
  26627. /**
  26628. * An event triggered after the world matrix is updated
  26629. */
  26630. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  26631. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  26632. /**
  26633. * Gets a string identifying the name of the class
  26634. * @returns "TransformNode" string
  26635. */
  26636. getClassName(): string;
  26637. /**
  26638. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  26639. */
  26640. get position(): Vector3;
  26641. set position(newPosition: Vector3);
  26642. /**
  26643. * 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)).
  26644. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  26645. */
  26646. get rotation(): Vector3;
  26647. set rotation(newRotation: Vector3);
  26648. /**
  26649. * 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)).
  26650. */
  26651. get scaling(): Vector3;
  26652. set scaling(newScaling: Vector3);
  26653. /**
  26654. * 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).
  26655. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  26656. */
  26657. get rotationQuaternion(): Nullable<Quaternion>;
  26658. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  26659. /**
  26660. * The forward direction of that transform in world space.
  26661. */
  26662. get forward(): Vector3;
  26663. /**
  26664. * The up direction of that transform in world space.
  26665. */
  26666. get up(): Vector3;
  26667. /**
  26668. * The right direction of that transform in world space.
  26669. */
  26670. get right(): Vector3;
  26671. /**
  26672. * Copies the parameter passed Matrix into the mesh Pose matrix.
  26673. * @param matrix the matrix to copy the pose from
  26674. * @returns this TransformNode.
  26675. */
  26676. updatePoseMatrix(matrix: Matrix): TransformNode;
  26677. /**
  26678. * Returns the mesh Pose matrix.
  26679. * @returns the pose matrix
  26680. */
  26681. getPoseMatrix(): Matrix;
  26682. /** @hidden */
  26683. _isSynchronized(): boolean;
  26684. /** @hidden */
  26685. _initCache(): void;
  26686. /**
  26687. * Flag the transform node as dirty (Forcing it to update everything)
  26688. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  26689. * @returns this transform node
  26690. */
  26691. markAsDirty(property: string): TransformNode;
  26692. /**
  26693. * Returns the current mesh absolute position.
  26694. * Returns a Vector3.
  26695. */
  26696. get absolutePosition(): Vector3;
  26697. /**
  26698. * Returns the current mesh absolute scaling.
  26699. * Returns a Vector3.
  26700. */
  26701. get absoluteScaling(): Vector3;
  26702. /**
  26703. * Returns the current mesh absolute rotation.
  26704. * Returns a Quaternion.
  26705. */
  26706. get absoluteRotationQuaternion(): Quaternion;
  26707. /**
  26708. * Sets a new matrix to apply before all other transformation
  26709. * @param matrix defines the transform matrix
  26710. * @returns the current TransformNode
  26711. */
  26712. setPreTransformMatrix(matrix: Matrix): TransformNode;
  26713. /**
  26714. * Sets a new pivot matrix to the current node
  26715. * @param matrix defines the new pivot matrix to use
  26716. * @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
  26717. * @returns the current TransformNode
  26718. */
  26719. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  26720. /**
  26721. * Returns the mesh pivot matrix.
  26722. * Default : Identity.
  26723. * @returns the matrix
  26724. */
  26725. getPivotMatrix(): Matrix;
  26726. /**
  26727. * Instantiate (when possible) or clone that node with its hierarchy
  26728. * @param newParent defines the new parent to use for the instance (or clone)
  26729. * @param options defines options to configure how copy is done
  26730. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  26731. * @returns an instance (or a clone) of the current node with its hiearchy
  26732. */
  26733. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  26734. doNotInstantiate: boolean;
  26735. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  26736. /**
  26737. * Prevents the World matrix to be computed any longer
  26738. * @param newWorldMatrix defines an optional matrix to use as world matrix
  26739. * @returns the TransformNode.
  26740. */
  26741. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  26742. /**
  26743. * Allows back the World matrix computation.
  26744. * @returns the TransformNode.
  26745. */
  26746. unfreezeWorldMatrix(): this;
  26747. /**
  26748. * True if the World matrix has been frozen.
  26749. */
  26750. get isWorldMatrixFrozen(): boolean;
  26751. /**
  26752. * Retuns the mesh absolute position in the World.
  26753. * @returns a Vector3.
  26754. */
  26755. getAbsolutePosition(): Vector3;
  26756. /**
  26757. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  26758. * @param absolutePosition the absolute position to set
  26759. * @returns the TransformNode.
  26760. */
  26761. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  26762. /**
  26763. * Sets the mesh position in its local space.
  26764. * @param vector3 the position to set in localspace
  26765. * @returns the TransformNode.
  26766. */
  26767. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  26768. /**
  26769. * Returns the mesh position in the local space from the current World matrix values.
  26770. * @returns a new Vector3.
  26771. */
  26772. getPositionExpressedInLocalSpace(): Vector3;
  26773. /**
  26774. * Translates the mesh along the passed Vector3 in its local space.
  26775. * @param vector3 the distance to translate in localspace
  26776. * @returns the TransformNode.
  26777. */
  26778. locallyTranslate(vector3: Vector3): TransformNode;
  26779. private static _lookAtVectorCache;
  26780. /**
  26781. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  26782. * @param targetPoint the position (must be in same space as current mesh) to look at
  26783. * @param yawCor optional yaw (y-axis) correction in radians
  26784. * @param pitchCor optional pitch (x-axis) correction in radians
  26785. * @param rollCor optional roll (z-axis) correction in radians
  26786. * @param space the choosen space of the target
  26787. * @returns the TransformNode.
  26788. */
  26789. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  26790. /**
  26791. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26792. * This Vector3 is expressed in the World space.
  26793. * @param localAxis axis to rotate
  26794. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  26795. */
  26796. getDirection(localAxis: Vector3): Vector3;
  26797. /**
  26798. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  26799. * localAxis is expressed in the mesh local space.
  26800. * result is computed in the Wordl space from the mesh World matrix.
  26801. * @param localAxis axis to rotate
  26802. * @param result the resulting transformnode
  26803. * @returns this TransformNode.
  26804. */
  26805. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  26806. /**
  26807. * Sets this transform node rotation to the given local axis.
  26808. * @param localAxis the axis in local space
  26809. * @param yawCor optional yaw (y-axis) correction in radians
  26810. * @param pitchCor optional pitch (x-axis) correction in radians
  26811. * @param rollCor optional roll (z-axis) correction in radians
  26812. * @returns this TransformNode
  26813. */
  26814. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  26815. /**
  26816. * Sets a new pivot point to the current node
  26817. * @param point defines the new pivot point to use
  26818. * @param space defines if the point is in world or local space (local by default)
  26819. * @returns the current TransformNode
  26820. */
  26821. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  26822. /**
  26823. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  26824. * @returns the pivot point
  26825. */
  26826. getPivotPoint(): Vector3;
  26827. /**
  26828. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  26829. * @param result the vector3 to store the result
  26830. * @returns this TransformNode.
  26831. */
  26832. getPivotPointToRef(result: Vector3): TransformNode;
  26833. /**
  26834. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  26835. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  26836. */
  26837. getAbsolutePivotPoint(): Vector3;
  26838. /**
  26839. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  26840. * @param result vector3 to store the result
  26841. * @returns this TransformNode.
  26842. */
  26843. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  26844. /**
  26845. * Defines the passed node as the parent of the current node.
  26846. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  26847. * @see https://doc.babylonjs.com/how_to/parenting
  26848. * @param node the node ot set as the parent
  26849. * @returns this TransformNode.
  26850. */
  26851. setParent(node: Nullable<Node>): TransformNode;
  26852. private _nonUniformScaling;
  26853. /**
  26854. * True if the scaling property of this object is non uniform eg. (1,2,1)
  26855. */
  26856. get nonUniformScaling(): boolean;
  26857. /** @hidden */
  26858. _updateNonUniformScalingState(value: boolean): boolean;
  26859. /**
  26860. * Attach the current TransformNode to another TransformNode associated with a bone
  26861. * @param bone Bone affecting the TransformNode
  26862. * @param affectedTransformNode TransformNode associated with the bone
  26863. * @returns this object
  26864. */
  26865. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  26866. /**
  26867. * Detach the transform node if its associated with a bone
  26868. * @returns this object
  26869. */
  26870. detachFromBone(): TransformNode;
  26871. private static _rotationAxisCache;
  26872. /**
  26873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  26874. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26875. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26876. * The passed axis is also normalized.
  26877. * @param axis the axis to rotate around
  26878. * @param amount the amount to rotate in radians
  26879. * @param space Space to rotate in (Default: local)
  26880. * @returns the TransformNode.
  26881. */
  26882. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  26883. /**
  26884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  26885. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  26886. * The passed axis is also normalized. .
  26887. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  26888. * @param point the point to rotate around
  26889. * @param axis the axis to rotate around
  26890. * @param amount the amount to rotate in radians
  26891. * @returns the TransformNode
  26892. */
  26893. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  26894. /**
  26895. * Translates the mesh along the axis vector for the passed distance in the given space.
  26896. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  26897. * @param axis the axis to translate in
  26898. * @param distance the distance to translate
  26899. * @param space Space to rotate in (Default: local)
  26900. * @returns the TransformNode.
  26901. */
  26902. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  26903. /**
  26904. * Adds a rotation step to the mesh current rotation.
  26905. * x, y, z are Euler angles expressed in radians.
  26906. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  26907. * This means this rotation is made in the mesh local space only.
  26908. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  26909. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  26910. * ```javascript
  26911. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  26912. * ```
  26913. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  26914. * 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.
  26915. * @param x Rotation to add
  26916. * @param y Rotation to add
  26917. * @param z Rotation to add
  26918. * @returns the TransformNode.
  26919. */
  26920. addRotation(x: number, y: number, z: number): TransformNode;
  26921. /**
  26922. * @hidden
  26923. */
  26924. protected _getEffectiveParent(): Nullable<Node>;
  26925. /**
  26926. * Computes the world matrix of the node
  26927. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26928. * @returns the world matrix
  26929. */
  26930. computeWorldMatrix(force?: boolean): Matrix;
  26931. /**
  26932. * Resets this nodeTransform's local matrix to Matrix.Identity().
  26933. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  26934. */
  26935. resetLocalMatrix(independentOfChildren?: boolean): void;
  26936. protected _afterComputeWorldMatrix(): void;
  26937. /**
  26938. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  26939. * @param func callback function to add
  26940. *
  26941. * @returns the TransformNode.
  26942. */
  26943. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26944. /**
  26945. * Removes a registered callback function.
  26946. * @param func callback function to remove
  26947. * @returns the TransformNode.
  26948. */
  26949. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  26950. /**
  26951. * Gets the position of the current mesh in camera space
  26952. * @param camera defines the camera to use
  26953. * @returns a position
  26954. */
  26955. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  26956. /**
  26957. * Returns the distance from the mesh to the active camera
  26958. * @param camera defines the camera to use
  26959. * @returns the distance
  26960. */
  26961. getDistanceToCamera(camera?: Nullable<Camera>): number;
  26962. /**
  26963. * Clone the current transform node
  26964. * @param name Name of the new clone
  26965. * @param newParent New parent for the clone
  26966. * @param doNotCloneChildren Do not clone children hierarchy
  26967. * @returns the new transform node
  26968. */
  26969. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  26970. /**
  26971. * Serializes the objects information.
  26972. * @param currentSerializationObject defines the object to serialize in
  26973. * @returns the serialized object
  26974. */
  26975. serialize(currentSerializationObject?: any): any;
  26976. /**
  26977. * Returns a new TransformNode object parsed from the source provided.
  26978. * @param parsedTransformNode is the source.
  26979. * @param scene the scne the object belongs to
  26980. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  26981. * @returns a new TransformNode object parsed from the source provided.
  26982. */
  26983. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  26984. /**
  26985. * Get all child-transformNodes of this node
  26986. * @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
  26987. * @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
  26988. * @returns an array of TransformNode
  26989. */
  26990. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  26991. /**
  26992. * Releases resources associated with this transform node.
  26993. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26994. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26995. */
  26996. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26997. /**
  26998. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26999. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27000. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27001. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27002. * @returns the current mesh
  27003. */
  27004. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  27005. private _syncAbsoluteScalingAndRotation;
  27006. }
  27007. }
  27008. declare module BABYLON {
  27009. /**
  27010. * Defines the types of pose enabled controllers that are supported
  27011. */
  27012. export enum PoseEnabledControllerType {
  27013. /**
  27014. * HTC Vive
  27015. */
  27016. VIVE = 0,
  27017. /**
  27018. * Oculus Rift
  27019. */
  27020. OCULUS = 1,
  27021. /**
  27022. * Windows mixed reality
  27023. */
  27024. WINDOWS = 2,
  27025. /**
  27026. * Samsung gear VR
  27027. */
  27028. GEAR_VR = 3,
  27029. /**
  27030. * Google Daydream
  27031. */
  27032. DAYDREAM = 4,
  27033. /**
  27034. * Generic
  27035. */
  27036. GENERIC = 5
  27037. }
  27038. /**
  27039. * Defines the MutableGamepadButton interface for the state of a gamepad button
  27040. */
  27041. export interface MutableGamepadButton {
  27042. /**
  27043. * Value of the button/trigger
  27044. */
  27045. value: number;
  27046. /**
  27047. * If the button/trigger is currently touched
  27048. */
  27049. touched: boolean;
  27050. /**
  27051. * If the button/trigger is currently pressed
  27052. */
  27053. pressed: boolean;
  27054. }
  27055. /**
  27056. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  27057. * @hidden
  27058. */
  27059. export interface ExtendedGamepadButton extends GamepadButton {
  27060. /**
  27061. * If the button/trigger is currently pressed
  27062. */
  27063. readonly pressed: boolean;
  27064. /**
  27065. * If the button/trigger is currently touched
  27066. */
  27067. readonly touched: boolean;
  27068. /**
  27069. * Value of the button/trigger
  27070. */
  27071. readonly value: number;
  27072. }
  27073. /** @hidden */
  27074. export interface _GamePadFactory {
  27075. /**
  27076. * Returns whether or not the current gamepad can be created for this type of controller.
  27077. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27078. * @returns true if it can be created, otherwise false
  27079. */
  27080. canCreate(gamepadInfo: any): boolean;
  27081. /**
  27082. * Creates a new instance of the Gamepad.
  27083. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  27084. * @returns the new gamepad instance
  27085. */
  27086. create(gamepadInfo: any): Gamepad;
  27087. }
  27088. /**
  27089. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27090. */
  27091. export class PoseEnabledControllerHelper {
  27092. /** @hidden */
  27093. static _ControllerFactories: _GamePadFactory[];
  27094. /** @hidden */
  27095. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  27096. /**
  27097. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  27098. * @param vrGamepad the gamepad to initialized
  27099. * @returns a vr controller of the type the gamepad identified as
  27100. */
  27101. static InitiateController(vrGamepad: any): Gamepad;
  27102. }
  27103. /**
  27104. * Defines the PoseEnabledController object that contains state of a vr capable controller
  27105. */
  27106. export class PoseEnabledController extends Gamepad implements PoseControlled {
  27107. /**
  27108. * If the controller is used in a webXR session
  27109. */
  27110. isXR: boolean;
  27111. private _deviceRoomPosition;
  27112. private _deviceRoomRotationQuaternion;
  27113. /**
  27114. * The device position in babylon space
  27115. */
  27116. devicePosition: Vector3;
  27117. /**
  27118. * The device rotation in babylon space
  27119. */
  27120. deviceRotationQuaternion: Quaternion;
  27121. /**
  27122. * The scale factor of the device in babylon space
  27123. */
  27124. deviceScaleFactor: number;
  27125. /**
  27126. * (Likely devicePosition should be used instead) The device position in its room space
  27127. */
  27128. position: Vector3;
  27129. /**
  27130. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  27131. */
  27132. rotationQuaternion: Quaternion;
  27133. /**
  27134. * The type of controller (Eg. Windows mixed reality)
  27135. */
  27136. controllerType: PoseEnabledControllerType;
  27137. protected _calculatedPosition: Vector3;
  27138. private _calculatedRotation;
  27139. /**
  27140. * The raw pose from the device
  27141. */
  27142. rawPose: DevicePose;
  27143. private _trackPosition;
  27144. private _maxRotationDistFromHeadset;
  27145. private _draggedRoomRotation;
  27146. /**
  27147. * @hidden
  27148. */
  27149. _disableTrackPosition(fixedPosition: Vector3): void;
  27150. /**
  27151. * Internal, the mesh attached to the controller
  27152. * @hidden
  27153. */
  27154. _mesh: Nullable<AbstractMesh>;
  27155. private _poseControlledCamera;
  27156. private _leftHandSystemQuaternion;
  27157. /**
  27158. * Internal, matrix used to convert room space to babylon space
  27159. * @hidden
  27160. */
  27161. _deviceToWorld: Matrix;
  27162. /**
  27163. * Node to be used when casting a ray from the controller
  27164. * @hidden
  27165. */
  27166. _pointingPoseNode: Nullable<TransformNode>;
  27167. /**
  27168. * Name of the child mesh that can be used to cast a ray from the controller
  27169. */
  27170. static readonly POINTING_POSE: string;
  27171. /**
  27172. * Creates a new PoseEnabledController from a gamepad
  27173. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  27174. */
  27175. constructor(browserGamepad: any);
  27176. private _workingMatrix;
  27177. /**
  27178. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  27179. */
  27180. update(): void;
  27181. /**
  27182. * Updates only the pose device and mesh without doing any button event checking
  27183. */
  27184. protected _updatePoseAndMesh(): void;
  27185. /**
  27186. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  27187. * @param poseData raw pose fromthe device
  27188. */
  27189. updateFromDevice(poseData: DevicePose): void;
  27190. /**
  27191. * @hidden
  27192. */
  27193. _meshAttachedObservable: Observable<AbstractMesh>;
  27194. /**
  27195. * Attaches a mesh to the controller
  27196. * @param mesh the mesh to be attached
  27197. */
  27198. attachToMesh(mesh: AbstractMesh): void;
  27199. /**
  27200. * Attaches the controllers mesh to a camera
  27201. * @param camera the camera the mesh should be attached to
  27202. */
  27203. attachToPoseControlledCamera(camera: TargetCamera): void;
  27204. /**
  27205. * Disposes of the controller
  27206. */
  27207. dispose(): void;
  27208. /**
  27209. * The mesh that is attached to the controller
  27210. */
  27211. get mesh(): Nullable<AbstractMesh>;
  27212. /**
  27213. * Gets the ray of the controller in the direction the controller is pointing
  27214. * @param length the length the resulting ray should be
  27215. * @returns a ray in the direction the controller is pointing
  27216. */
  27217. getForwardRay(length?: number): Ray;
  27218. }
  27219. }
  27220. declare module BABYLON {
  27221. /**
  27222. * Defines the WebVRController object that represents controllers tracked in 3D space
  27223. */
  27224. export abstract class WebVRController extends PoseEnabledController {
  27225. /**
  27226. * Internal, the default controller model for the controller
  27227. */
  27228. protected _defaultModel: Nullable<AbstractMesh>;
  27229. /**
  27230. * Fired when the trigger state has changed
  27231. */
  27232. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  27233. /**
  27234. * Fired when the main button state has changed
  27235. */
  27236. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27237. /**
  27238. * Fired when the secondary button state has changed
  27239. */
  27240. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  27241. /**
  27242. * Fired when the pad state has changed
  27243. */
  27244. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  27245. /**
  27246. * Fired when controllers stick values have changed
  27247. */
  27248. onPadValuesChangedObservable: Observable<StickValues>;
  27249. /**
  27250. * Array of button availible on the controller
  27251. */
  27252. protected _buttons: Array<MutableGamepadButton>;
  27253. private _onButtonStateChange;
  27254. /**
  27255. * Fired when a controller button's state has changed
  27256. * @param callback the callback containing the button that was modified
  27257. */
  27258. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  27259. /**
  27260. * X and Y axis corresponding to the controllers joystick
  27261. */
  27262. pad: StickValues;
  27263. /**
  27264. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  27265. */
  27266. hand: string;
  27267. /**
  27268. * The default controller model for the controller
  27269. */
  27270. get defaultModel(): Nullable<AbstractMesh>;
  27271. /**
  27272. * Creates a new WebVRController from a gamepad
  27273. * @param vrGamepad the gamepad that the WebVRController should be created from
  27274. */
  27275. constructor(vrGamepad: any);
  27276. /**
  27277. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  27278. */
  27279. update(): void;
  27280. /**
  27281. * Function to be called when a button is modified
  27282. */
  27283. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  27284. /**
  27285. * Loads a mesh and attaches it to the controller
  27286. * @param scene the scene the mesh should be added to
  27287. * @param meshLoaded callback for when the mesh has been loaded
  27288. */
  27289. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  27290. private _setButtonValue;
  27291. private _changes;
  27292. private _checkChanges;
  27293. /**
  27294. * Disposes of th webVRCOntroller
  27295. */
  27296. dispose(): void;
  27297. }
  27298. }
  27299. declare module BABYLON {
  27300. /**
  27301. * The HemisphericLight simulates the ambient environment light,
  27302. * so the passed direction is the light reflection direction, not the incoming direction.
  27303. */
  27304. export class HemisphericLight extends Light {
  27305. /**
  27306. * The groundColor is the light in the opposite direction to the one specified during creation.
  27307. * 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.
  27308. */
  27309. groundColor: Color3;
  27310. /**
  27311. * The light reflection direction, not the incoming direction.
  27312. */
  27313. direction: Vector3;
  27314. /**
  27315. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  27316. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  27317. * The HemisphericLight can't cast shadows.
  27318. * Documentation : https://doc.babylonjs.com/babylon101/lights
  27319. * @param name The friendly name of the light
  27320. * @param direction The direction of the light reflection
  27321. * @param scene The scene the light belongs to
  27322. */
  27323. constructor(name: string, direction: Vector3, scene: Scene);
  27324. protected _buildUniformLayout(): void;
  27325. /**
  27326. * Returns the string "HemisphericLight".
  27327. * @return The class name
  27328. */
  27329. getClassName(): string;
  27330. /**
  27331. * Sets the HemisphericLight direction towards the passed target (Vector3).
  27332. * Returns the updated direction.
  27333. * @param target The target the direction should point to
  27334. * @return The computed direction
  27335. */
  27336. setDirectionToTarget(target: Vector3): Vector3;
  27337. /**
  27338. * Returns the shadow generator associated to the light.
  27339. * @returns Always null for hemispheric lights because it does not support shadows.
  27340. */
  27341. getShadowGenerator(): Nullable<IShadowGenerator>;
  27342. /**
  27343. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  27344. * @param effect The effect to update
  27345. * @param lightIndex The index of the light in the effect to update
  27346. * @returns The hemispheric light
  27347. */
  27348. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  27349. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  27350. /**
  27351. * Computes the world matrix of the node
  27352. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27353. * @param useWasUpdatedFlag defines a reserved property
  27354. * @returns the world matrix
  27355. */
  27356. computeWorldMatrix(): Matrix;
  27357. /**
  27358. * Returns the integer 3.
  27359. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  27360. */
  27361. getTypeID(): number;
  27362. /**
  27363. * Prepares the list of defines specific to the light type.
  27364. * @param defines the list of defines
  27365. * @param lightIndex defines the index of the light for the effect
  27366. */
  27367. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  27368. }
  27369. }
  27370. declare module BABYLON {
  27371. /** @hidden */
  27372. export var vrMultiviewToSingleviewPixelShader: {
  27373. name: string;
  27374. shader: string;
  27375. };
  27376. }
  27377. declare module BABYLON {
  27378. /**
  27379. * Renders to multiple views with a single draw call
  27380. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  27381. */
  27382. export class MultiviewRenderTarget extends RenderTargetTexture {
  27383. /**
  27384. * Creates a multiview render target
  27385. * @param scene scene used with the render target
  27386. * @param size the size of the render target (used for each view)
  27387. */
  27388. constructor(scene: Scene, size?: number | {
  27389. width: number;
  27390. height: number;
  27391. } | {
  27392. ratio: number;
  27393. });
  27394. /**
  27395. * @hidden
  27396. * @param faceIndex the face index, if its a cube texture
  27397. */
  27398. _bindFrameBuffer(faceIndex?: number): void;
  27399. /**
  27400. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  27401. * @returns the view count
  27402. */
  27403. getViewCount(): number;
  27404. }
  27405. }
  27406. declare module BABYLON {
  27407. interface Engine {
  27408. /**
  27409. * Creates a new multiview render target
  27410. * @param width defines the width of the texture
  27411. * @param height defines the height of the texture
  27412. * @returns the created multiview texture
  27413. */
  27414. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  27415. /**
  27416. * Binds a multiview framebuffer to be drawn to
  27417. * @param multiviewTexture texture to bind
  27418. */
  27419. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  27420. }
  27421. interface Camera {
  27422. /**
  27423. * @hidden
  27424. * 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)
  27425. */
  27426. _useMultiviewToSingleView: boolean;
  27427. /**
  27428. * @hidden
  27429. * 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)
  27430. */
  27431. _multiviewTexture: Nullable<RenderTargetTexture>;
  27432. /**
  27433. * @hidden
  27434. * ensures the multiview texture of the camera exists and has the specified width/height
  27435. * @param width height to set on the multiview texture
  27436. * @param height width to set on the multiview texture
  27437. */
  27438. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  27439. }
  27440. interface Scene {
  27441. /** @hidden */
  27442. _transformMatrixR: Matrix;
  27443. /** @hidden */
  27444. _multiviewSceneUbo: Nullable<UniformBuffer>;
  27445. /** @hidden */
  27446. _createMultiviewUbo(): void;
  27447. /** @hidden */
  27448. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  27449. /** @hidden */
  27450. _renderMultiviewToSingleView(camera: Camera): void;
  27451. }
  27452. }
  27453. declare module BABYLON {
  27454. /**
  27455. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  27456. * This will not be used for webXR as it supports displaying texture arrays directly
  27457. */
  27458. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  27459. /**
  27460. * Gets a string identifying the name of the class
  27461. * @returns "VRMultiviewToSingleviewPostProcess" string
  27462. */
  27463. getClassName(): string;
  27464. /**
  27465. * Initializes a VRMultiviewToSingleview
  27466. * @param name name of the post process
  27467. * @param camera camera to be applied to
  27468. * @param scaleFactor scaling factor to the size of the output texture
  27469. */
  27470. constructor(name: string, camera: Camera, scaleFactor: number);
  27471. }
  27472. }
  27473. declare module BABYLON {
  27474. /**
  27475. * Interface used to define additional presentation attributes
  27476. */
  27477. export interface IVRPresentationAttributes {
  27478. /**
  27479. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  27480. */
  27481. highRefreshRate: boolean;
  27482. /**
  27483. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  27484. */
  27485. foveationLevel: number;
  27486. }
  27487. interface Engine {
  27488. /** @hidden */
  27489. _vrDisplay: any;
  27490. /** @hidden */
  27491. _vrSupported: boolean;
  27492. /** @hidden */
  27493. _oldSize: Size;
  27494. /** @hidden */
  27495. _oldHardwareScaleFactor: number;
  27496. /** @hidden */
  27497. _vrExclusivePointerMode: boolean;
  27498. /** @hidden */
  27499. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  27500. /** @hidden */
  27501. _onVRDisplayPointerRestricted: () => void;
  27502. /** @hidden */
  27503. _onVRDisplayPointerUnrestricted: () => void;
  27504. /** @hidden */
  27505. _onVrDisplayConnect: Nullable<(display: any) => void>;
  27506. /** @hidden */
  27507. _onVrDisplayDisconnect: Nullable<() => void>;
  27508. /** @hidden */
  27509. _onVrDisplayPresentChange: Nullable<() => void>;
  27510. /**
  27511. * Observable signaled when VR display mode changes
  27512. */
  27513. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  27514. /**
  27515. * Observable signaled when VR request present is complete
  27516. */
  27517. onVRRequestPresentComplete: Observable<boolean>;
  27518. /**
  27519. * Observable signaled when VR request present starts
  27520. */
  27521. onVRRequestPresentStart: Observable<Engine>;
  27522. /**
  27523. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  27524. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  27525. */
  27526. isInVRExclusivePointerMode: boolean;
  27527. /**
  27528. * Gets a boolean indicating if a webVR device was detected
  27529. * @returns true if a webVR device was detected
  27530. */
  27531. isVRDevicePresent(): boolean;
  27532. /**
  27533. * Gets the current webVR device
  27534. * @returns the current webVR device (or null)
  27535. */
  27536. getVRDevice(): any;
  27537. /**
  27538. * Initializes a webVR display and starts listening to display change events
  27539. * The onVRDisplayChangedObservable will be notified upon these changes
  27540. * @returns A promise containing a VRDisplay and if vr is supported
  27541. */
  27542. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  27543. /** @hidden */
  27544. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  27545. /**
  27546. * Gets or sets the presentation attributes used to configure VR rendering
  27547. */
  27548. vrPresentationAttributes?: IVRPresentationAttributes;
  27549. /**
  27550. * Call this function to switch to webVR mode
  27551. * Will do nothing if webVR is not supported or if there is no webVR device
  27552. * @param options the webvr options provided to the camera. mainly used for multiview
  27553. * @see https://doc.babylonjs.com/how_to/webvr_camera
  27554. */
  27555. enableVR(options: WebVROptions): void;
  27556. /** @hidden */
  27557. _onVRFullScreenTriggered(): void;
  27558. }
  27559. }
  27560. declare module BABYLON {
  27561. /**
  27562. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  27563. * IMPORTANT!! The data is right-hand data.
  27564. * @export
  27565. * @interface DevicePose
  27566. */
  27567. export interface DevicePose {
  27568. /**
  27569. * The position of the device, values in array are [x,y,z].
  27570. */
  27571. readonly position: Nullable<Float32Array>;
  27572. /**
  27573. * The linearVelocity of the device, values in array are [x,y,z].
  27574. */
  27575. readonly linearVelocity: Nullable<Float32Array>;
  27576. /**
  27577. * The linearAcceleration of the device, values in array are [x,y,z].
  27578. */
  27579. readonly linearAcceleration: Nullable<Float32Array>;
  27580. /**
  27581. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  27582. */
  27583. readonly orientation: Nullable<Float32Array>;
  27584. /**
  27585. * The angularVelocity of the device, values in array are [x,y,z].
  27586. */
  27587. readonly angularVelocity: Nullable<Float32Array>;
  27588. /**
  27589. * The angularAcceleration of the device, values in array are [x,y,z].
  27590. */
  27591. readonly angularAcceleration: Nullable<Float32Array>;
  27592. }
  27593. /**
  27594. * Interface representing a pose controlled object in Babylon.
  27595. * A pose controlled object has both regular pose values as well as pose values
  27596. * from an external device such as a VR head mounted display
  27597. */
  27598. export interface PoseControlled {
  27599. /**
  27600. * The position of the object in babylon space.
  27601. */
  27602. position: Vector3;
  27603. /**
  27604. * The rotation quaternion of the object in babylon space.
  27605. */
  27606. rotationQuaternion: Quaternion;
  27607. /**
  27608. * The position of the device in babylon space.
  27609. */
  27610. devicePosition?: Vector3;
  27611. /**
  27612. * The rotation quaternion of the device in babylon space.
  27613. */
  27614. deviceRotationQuaternion: Quaternion;
  27615. /**
  27616. * The raw pose coming from the device.
  27617. */
  27618. rawPose: Nullable<DevicePose>;
  27619. /**
  27620. * The scale of the device to be used when translating from device space to babylon space.
  27621. */
  27622. deviceScaleFactor: number;
  27623. /**
  27624. * Updates the poseControlled values based on the input device pose.
  27625. * @param poseData the pose data to update the object with
  27626. */
  27627. updateFromDevice(poseData: DevicePose): void;
  27628. }
  27629. /**
  27630. * Set of options to customize the webVRCamera
  27631. */
  27632. export interface WebVROptions {
  27633. /**
  27634. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  27635. */
  27636. trackPosition?: boolean;
  27637. /**
  27638. * Sets the scale of the vrDevice in babylon space. (default: 1)
  27639. */
  27640. positionScale?: number;
  27641. /**
  27642. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  27643. */
  27644. displayName?: string;
  27645. /**
  27646. * Should the native controller meshes be initialized. (default: true)
  27647. */
  27648. controllerMeshes?: boolean;
  27649. /**
  27650. * Creating a default HemiLight only on controllers. (default: true)
  27651. */
  27652. defaultLightingOnControllers?: boolean;
  27653. /**
  27654. * If you don't want to use the default VR button of the helper. (default: false)
  27655. */
  27656. useCustomVRButton?: boolean;
  27657. /**
  27658. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  27659. */
  27660. customVRButton?: HTMLButtonElement;
  27661. /**
  27662. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  27663. */
  27664. rayLength?: number;
  27665. /**
  27666. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  27667. */
  27668. defaultHeight?: number;
  27669. /**
  27670. * If multiview should be used if availible (default: false)
  27671. */
  27672. useMultiview?: boolean;
  27673. }
  27674. /**
  27675. * This represents a WebVR camera.
  27676. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  27677. * @example https://doc.babylonjs.com/how_to/webvr_camera
  27678. */
  27679. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  27680. private webVROptions;
  27681. /**
  27682. * @hidden
  27683. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  27684. */
  27685. _vrDevice: any;
  27686. /**
  27687. * The rawPose of the vrDevice.
  27688. */
  27689. rawPose: Nullable<DevicePose>;
  27690. private _onVREnabled;
  27691. private _specsVersion;
  27692. private _attached;
  27693. private _frameData;
  27694. protected _descendants: Array<Node>;
  27695. private _deviceRoomPosition;
  27696. /** @hidden */
  27697. _deviceRoomRotationQuaternion: Quaternion;
  27698. private _standingMatrix;
  27699. /**
  27700. * Represents device position in babylon space.
  27701. */
  27702. devicePosition: Vector3;
  27703. /**
  27704. * Represents device rotation in babylon space.
  27705. */
  27706. deviceRotationQuaternion: Quaternion;
  27707. /**
  27708. * The scale of the device to be used when translating from device space to babylon space.
  27709. */
  27710. deviceScaleFactor: number;
  27711. private _deviceToWorld;
  27712. private _worldToDevice;
  27713. /**
  27714. * References to the webVR controllers for the vrDevice.
  27715. */
  27716. controllers: Array<WebVRController>;
  27717. /**
  27718. * Emits an event when a controller is attached.
  27719. */
  27720. onControllersAttachedObservable: Observable<WebVRController[]>;
  27721. /**
  27722. * Emits an event when a controller's mesh has been loaded;
  27723. */
  27724. onControllerMeshLoadedObservable: Observable<WebVRController>;
  27725. /**
  27726. * Emits an event when the HMD's pose has been updated.
  27727. */
  27728. onPoseUpdatedFromDeviceObservable: Observable<any>;
  27729. private _poseSet;
  27730. /**
  27731. * If the rig cameras be used as parent instead of this camera.
  27732. */
  27733. rigParenting: boolean;
  27734. private _lightOnControllers;
  27735. private _defaultHeight?;
  27736. /**
  27737. * Instantiates a WebVRFreeCamera.
  27738. * @param name The name of the WebVRFreeCamera
  27739. * @param position The starting anchor position for the camera
  27740. * @param scene The scene the camera belongs to
  27741. * @param webVROptions a set of customizable options for the webVRCamera
  27742. */
  27743. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  27744. /**
  27745. * Gets the device distance from the ground in meters.
  27746. * @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.
  27747. */
  27748. deviceDistanceToRoomGround(): number;
  27749. /**
  27750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27751. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  27752. */
  27753. useStandingMatrix(callback?: (bool: boolean) => void): void;
  27754. /**
  27755. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  27756. * @returns A promise with a boolean set to if the standing matrix is supported.
  27757. */
  27758. useStandingMatrixAsync(): Promise<boolean>;
  27759. /**
  27760. * Disposes the camera
  27761. */
  27762. dispose(): void;
  27763. /**
  27764. * Gets a vrController by name.
  27765. * @param name The name of the controller to retreive
  27766. * @returns the controller matching the name specified or null if not found
  27767. */
  27768. getControllerByName(name: string): Nullable<WebVRController>;
  27769. private _leftController;
  27770. /**
  27771. * The controller corresponding to the users left hand.
  27772. */
  27773. get leftController(): Nullable<WebVRController>;
  27774. private _rightController;
  27775. /**
  27776. * The controller corresponding to the users right hand.
  27777. */
  27778. get rightController(): Nullable<WebVRController>;
  27779. /**
  27780. * Casts a ray forward from the vrCamera's gaze.
  27781. * @param length Length of the ray (default: 100)
  27782. * @returns the ray corresponding to the gaze
  27783. */
  27784. getForwardRay(length?: number): Ray;
  27785. /**
  27786. * @hidden
  27787. * Updates the camera based on device's frame data
  27788. */
  27789. _checkInputs(): void;
  27790. /**
  27791. * Updates the poseControlled values based on the input device pose.
  27792. * @param poseData Pose coming from the device
  27793. */
  27794. updateFromDevice(poseData: DevicePose): void;
  27795. private _detachIfAttached;
  27796. /**
  27797. * WebVR's attach control will start broadcasting frames to the device.
  27798. * Note that in certain browsers (chrome for example) this function must be called
  27799. * within a user-interaction callback. Example:
  27800. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  27801. *
  27802. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  27803. */
  27804. attachControl(noPreventDefault?: boolean): void;
  27805. /**
  27806. * Detach the current controls from the specified dom element.
  27807. */
  27808. detachControl(): void;
  27809. /**
  27810. * @returns the name of this class
  27811. */
  27812. getClassName(): string;
  27813. /**
  27814. * Calls resetPose on the vrDisplay
  27815. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  27816. */
  27817. resetToCurrentRotation(): void;
  27818. /**
  27819. * @hidden
  27820. * Updates the rig cameras (left and right eye)
  27821. */
  27822. _updateRigCameras(): void;
  27823. private _workingVector;
  27824. private _oneVector;
  27825. private _workingMatrix;
  27826. private updateCacheCalled;
  27827. private _correctPositionIfNotTrackPosition;
  27828. /**
  27829. * @hidden
  27830. * Updates the cached values of the camera
  27831. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  27832. */
  27833. _updateCache(ignoreParentClass?: boolean): void;
  27834. /**
  27835. * @hidden
  27836. * Get current device position in babylon world
  27837. */
  27838. _computeDevicePosition(): void;
  27839. /**
  27840. * Updates the current device position and rotation in the babylon world
  27841. */
  27842. update(): void;
  27843. /**
  27844. * @hidden
  27845. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  27846. * @returns an identity matrix
  27847. */
  27848. _getViewMatrix(): Matrix;
  27849. private _tmpMatrix;
  27850. /**
  27851. * This function is called by the two RIG cameras.
  27852. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  27853. * @hidden
  27854. */
  27855. _getWebVRViewMatrix(): Matrix;
  27856. /** @hidden */
  27857. _getWebVRProjectionMatrix(): Matrix;
  27858. private _onGamepadConnectedObserver;
  27859. private _onGamepadDisconnectedObserver;
  27860. private _updateCacheWhenTrackingDisabledObserver;
  27861. /**
  27862. * Initializes the controllers and their meshes
  27863. */
  27864. initControllers(): void;
  27865. }
  27866. }
  27867. declare module BABYLON {
  27868. /**
  27869. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  27870. *
  27871. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  27872. *
  27873. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  27874. */
  27875. export class MaterialHelper {
  27876. /**
  27877. * Bind the current view position to an effect.
  27878. * @param effect The effect to be bound
  27879. * @param scene The scene the eyes position is used from
  27880. * @param variableName name of the shader variable that will hold the eye position
  27881. * @param isVector3 true to indicates that variableName is a Vector3 and not a Vector4
  27882. * @return the computed eye position
  27883. */
  27884. static BindEyePosition(effect: Nullable<Effect>, scene: Scene, variableName?: string, isVector3?: boolean): Vector4;
  27885. /**
  27886. * Helps preparing the defines values about the UVs in used in the effect.
  27887. * UVs are shared as much as we can accross channels in the shaders.
  27888. * @param texture The texture we are preparing the UVs for
  27889. * @param defines The defines to update
  27890. * @param key The channel key "diffuse", "specular"... used in the shader
  27891. */
  27892. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  27893. /**
  27894. * Binds a texture matrix value to its corrsponding uniform
  27895. * @param texture The texture to bind the matrix for
  27896. * @param uniformBuffer The uniform buffer receivin the data
  27897. * @param key The channel key "diffuse", "specular"... used in the shader
  27898. */
  27899. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  27900. /**
  27901. * Gets the current status of the fog (should it be enabled?)
  27902. * @param mesh defines the mesh to evaluate for fog support
  27903. * @param scene defines the hosting scene
  27904. * @returns true if fog must be enabled
  27905. */
  27906. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  27907. /**
  27908. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  27909. * @param mesh defines the current mesh
  27910. * @param scene defines the current scene
  27911. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  27912. * @param pointsCloud defines if point cloud rendering has to be turned on
  27913. * @param fogEnabled defines if fog has to be turned on
  27914. * @param alphaTest defines if alpha testing has to be turned on
  27915. * @param defines defines the current list of defines
  27916. */
  27917. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  27918. /**
  27919. * Helper used to prepare the list of defines associated with frame values for shader compilation
  27920. * @param scene defines the current scene
  27921. * @param engine defines the current engine
  27922. * @param defines specifies the list of active defines
  27923. * @param useInstances defines if instances have to be turned on
  27924. * @param useClipPlane defines if clip plane have to be turned on
  27925. * @param useInstances defines if instances have to be turned on
  27926. * @param useThinInstances defines if thin instances have to be turned on
  27927. */
  27928. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  27929. /**
  27930. * Prepares the defines for bones
  27931. * @param mesh The mesh containing the geometry data we will draw
  27932. * @param defines The defines to update
  27933. */
  27934. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  27935. /**
  27936. * Prepares the defines for morph targets
  27937. * @param mesh The mesh containing the geometry data we will draw
  27938. * @param defines The defines to update
  27939. */
  27940. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  27941. /**
  27942. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  27943. * @param mesh The mesh containing the geometry data we will draw
  27944. * @param defines The defines to update
  27945. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  27946. * @param useBones Precise whether bones should be used or not (override mesh info)
  27947. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  27948. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  27949. * @returns false if defines are considered not dirty and have not been checked
  27950. */
  27951. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  27952. /**
  27953. * Prepares the defines related to multiview
  27954. * @param scene The scene we are intending to draw
  27955. * @param defines The defines to update
  27956. */
  27957. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  27958. /**
  27959. * Prepares the defines related to the prepass
  27960. * @param scene The scene we are intending to draw
  27961. * @param defines The defines to update
  27962. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  27963. */
  27964. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  27965. /**
  27966. * Prepares the defines related to the light information passed in parameter
  27967. * @param scene The scene we are intending to draw
  27968. * @param mesh The mesh the effect is compiling for
  27969. * @param light The light the effect is compiling for
  27970. * @param lightIndex The index of the light
  27971. * @param defines The defines to update
  27972. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27973. * @param state Defines the current state regarding what is needed (normals, etc...)
  27974. */
  27975. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  27976. needNormals: boolean;
  27977. needRebuild: boolean;
  27978. shadowEnabled: boolean;
  27979. specularEnabled: boolean;
  27980. lightmapMode: boolean;
  27981. }): void;
  27982. /**
  27983. * Prepares the defines related to the light information passed in parameter
  27984. * @param scene The scene we are intending to draw
  27985. * @param mesh The mesh the effect is compiling for
  27986. * @param defines The defines to update
  27987. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  27988. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  27989. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  27990. * @returns true if normals will be required for the rest of the effect
  27991. */
  27992. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  27993. /**
  27994. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  27995. * @param lightIndex defines the light index
  27996. * @param uniformsList The uniform list
  27997. * @param samplersList The sampler list
  27998. * @param projectedLightTexture defines if projected texture must be used
  27999. * @param uniformBuffersList defines an optional list of uniform buffers
  28000. * @param updateOnlyBuffersList True to only update the uniformBuffersList array
  28001. */
  28002. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>, updateOnlyBuffersList?: boolean): void;
  28003. /**
  28004. * Prepares the uniforms and samplers list to be used in the effect
  28005. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  28006. * @param samplersList The sampler list
  28007. * @param defines The defines helping in the list generation
  28008. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  28009. */
  28010. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  28011. /**
  28012. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  28013. * @param defines The defines to update while falling back
  28014. * @param fallbacks The authorized effect fallbacks
  28015. * @param maxSimultaneousLights The maximum number of lights allowed
  28016. * @param rank the current rank of the Effect
  28017. * @returns The newly affected rank
  28018. */
  28019. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  28020. private static _TmpMorphInfluencers;
  28021. /**
  28022. * Prepares the list of attributes required for morph targets according to the effect defines.
  28023. * @param attribs The current list of supported attribs
  28024. * @param mesh The mesh to prepare the morph targets attributes for
  28025. * @param influencers The number of influencers
  28026. */
  28027. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  28028. /**
  28029. * Prepares the list of attributes required for morph targets according to the effect defines.
  28030. * @param attribs The current list of supported attribs
  28031. * @param mesh The mesh to prepare the morph targets attributes for
  28032. * @param defines The current Defines of the effect
  28033. */
  28034. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  28035. /**
  28036. * Prepares the list of attributes required for bones according to the effect defines.
  28037. * @param attribs The current list of supported attribs
  28038. * @param mesh The mesh to prepare the bones attributes for
  28039. * @param defines The current Defines of the effect
  28040. * @param fallbacks The current efffect fallback strategy
  28041. */
  28042. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  28043. /**
  28044. * Check and prepare the list of attributes required for instances according to the effect defines.
  28045. * @param attribs The current list of supported attribs
  28046. * @param defines The current MaterialDefines of the effect
  28047. */
  28048. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  28049. /**
  28050. * Add the list of attributes required for instances to the attribs array.
  28051. * @param attribs The current list of supported attribs
  28052. */
  28053. static PushAttributesForInstances(attribs: string[]): void;
  28054. /**
  28055. * Binds the light information to the effect.
  28056. * @param light The light containing the generator
  28057. * @param effect The effect we are binding the data to
  28058. * @param lightIndex The light index in the effect used to render
  28059. */
  28060. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  28061. /**
  28062. * Binds the lights information from the scene to the effect for the given mesh.
  28063. * @param light Light to bind
  28064. * @param lightIndex Light index
  28065. * @param scene The scene where the light belongs to
  28066. * @param effect The effect we are binding the data to
  28067. * @param useSpecular Defines if specular is supported
  28068. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28069. */
  28070. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  28071. /**
  28072. * Binds the lights information from the scene to the effect for the given mesh.
  28073. * @param scene The scene the lights belongs to
  28074. * @param mesh The mesh we are binding the information to render
  28075. * @param effect The effect we are binding the data to
  28076. * @param defines The generated defines for the effect
  28077. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  28078. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  28079. */
  28080. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  28081. private static _tempFogColor;
  28082. /**
  28083. * Binds the fog information from the scene to the effect for the given mesh.
  28084. * @param scene The scene the lights belongs to
  28085. * @param mesh The mesh we are binding the information to render
  28086. * @param effect The effect we are binding the data to
  28087. * @param linearSpace Defines if the fog effect is applied in linear space
  28088. */
  28089. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  28090. /**
  28091. * Binds the bones information from the mesh to the effect.
  28092. * @param mesh The mesh we are binding the information to render
  28093. * @param effect The effect we are binding the data to
  28094. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  28095. */
  28096. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  28097. private static _CopyBonesTransformationMatrices;
  28098. /**
  28099. * Binds the morph targets information from the mesh to the effect.
  28100. * @param abstractMesh The mesh we are binding the information to render
  28101. * @param effect The effect we are binding the data to
  28102. */
  28103. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  28104. /**
  28105. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  28106. * @param defines The generated defines used in the effect
  28107. * @param effect The effect we are binding the data to
  28108. * @param scene The scene we are willing to render with logarithmic scale for
  28109. */
  28110. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  28111. /**
  28112. * Binds the clip plane information from the scene to the effect.
  28113. * @param scene The scene the clip plane information are extracted from
  28114. * @param effect The effect we are binding the data to
  28115. */
  28116. static BindClipPlane(effect: Effect, scene: Scene): void;
  28117. }
  28118. }
  28119. declare module BABYLON {
  28120. /** @hidden */
  28121. export var bayerDitherFunctions: {
  28122. name: string;
  28123. shader: string;
  28124. };
  28125. }
  28126. declare module BABYLON {
  28127. /** @hidden */
  28128. export var shadowMapFragmentDeclaration: {
  28129. name: string;
  28130. shader: string;
  28131. };
  28132. }
  28133. declare module BABYLON {
  28134. /** @hidden */
  28135. export var shadowMapFragment: {
  28136. name: string;
  28137. shader: string;
  28138. };
  28139. }
  28140. declare module BABYLON {
  28141. /** @hidden */
  28142. export var shadowMapPixelShader: {
  28143. name: string;
  28144. shader: string;
  28145. };
  28146. }
  28147. declare module BABYLON {
  28148. /** @hidden */
  28149. export var shadowMapVertexDeclaration: {
  28150. name: string;
  28151. shader: string;
  28152. };
  28153. }
  28154. declare module BABYLON {
  28155. /** @hidden */
  28156. export var shadowMapVertexNormalBias: {
  28157. name: string;
  28158. shader: string;
  28159. };
  28160. }
  28161. declare module BABYLON {
  28162. /** @hidden */
  28163. export var shadowMapVertexMetric: {
  28164. name: string;
  28165. shader: string;
  28166. };
  28167. }
  28168. declare module BABYLON {
  28169. /** @hidden */
  28170. export var shadowMapVertexShader: {
  28171. name: string;
  28172. shader: string;
  28173. };
  28174. }
  28175. declare module BABYLON {
  28176. /** @hidden */
  28177. export var depthBoxBlurPixelShader: {
  28178. name: string;
  28179. shader: string;
  28180. };
  28181. }
  28182. declare module BABYLON {
  28183. /** @hidden */
  28184. export var shadowMapFragmentSoftTransparentShadow: {
  28185. name: string;
  28186. shader: string;
  28187. };
  28188. }
  28189. declare module BABYLON {
  28190. /**
  28191. * Creates an instance based on a source mesh.
  28192. */
  28193. export class InstancedMesh extends AbstractMesh {
  28194. private _sourceMesh;
  28195. private _currentLOD;
  28196. /** @hidden */
  28197. _indexInSourceMeshInstanceArray: number;
  28198. constructor(name: string, source: Mesh);
  28199. /**
  28200. * Returns the string "InstancedMesh".
  28201. */
  28202. getClassName(): string;
  28203. /** Gets the list of lights affecting that mesh */
  28204. get lightSources(): Light[];
  28205. _resyncLightSources(): void;
  28206. _resyncLightSource(light: Light): void;
  28207. _removeLightSource(light: Light, dispose: boolean): void;
  28208. /**
  28209. * If the source mesh receives shadows
  28210. */
  28211. get receiveShadows(): boolean;
  28212. /**
  28213. * The material of the source mesh
  28214. */
  28215. get material(): Nullable<Material>;
  28216. /**
  28217. * Visibility of the source mesh
  28218. */
  28219. get visibility(): number;
  28220. /**
  28221. * Skeleton of the source mesh
  28222. */
  28223. get skeleton(): Nullable<Skeleton>;
  28224. /**
  28225. * Rendering ground id of the source mesh
  28226. */
  28227. get renderingGroupId(): number;
  28228. set renderingGroupId(value: number);
  28229. /**
  28230. * Returns the total number of vertices (integer).
  28231. */
  28232. getTotalVertices(): number;
  28233. /**
  28234. * Returns a positive integer : the total number of indices in this mesh geometry.
  28235. * @returns the numner of indices or zero if the mesh has no geometry.
  28236. */
  28237. getTotalIndices(): number;
  28238. /**
  28239. * The source mesh of the instance
  28240. */
  28241. get sourceMesh(): Mesh;
  28242. /**
  28243. * Creates a new InstancedMesh object from the mesh model.
  28244. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28245. * @param name defines the name of the new instance
  28246. * @returns a new InstancedMesh
  28247. */
  28248. createInstance(name: string): InstancedMesh;
  28249. /**
  28250. * Is this node ready to be used/rendered
  28251. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28252. * @return {boolean} is it ready
  28253. */
  28254. isReady(completeCheck?: boolean): boolean;
  28255. /**
  28256. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28257. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  28258. * @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.
  28259. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  28260. */
  28261. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  28262. /**
  28263. * Sets the vertex data of the mesh geometry for the requested `kind`.
  28264. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  28265. * The `data` are either a numeric array either a Float32Array.
  28266. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  28267. * 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).
  28268. * Note that a new underlying VertexBuffer object is created each call.
  28269. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  28270. *
  28271. * Possible `kind` values :
  28272. * - VertexBuffer.PositionKind
  28273. * - VertexBuffer.UVKind
  28274. * - VertexBuffer.UV2Kind
  28275. * - VertexBuffer.UV3Kind
  28276. * - VertexBuffer.UV4Kind
  28277. * - VertexBuffer.UV5Kind
  28278. * - VertexBuffer.UV6Kind
  28279. * - VertexBuffer.ColorKind
  28280. * - VertexBuffer.MatricesIndicesKind
  28281. * - VertexBuffer.MatricesIndicesExtraKind
  28282. * - VertexBuffer.MatricesWeightsKind
  28283. * - VertexBuffer.MatricesWeightsExtraKind
  28284. *
  28285. * Returns the Mesh.
  28286. */
  28287. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28288. /**
  28289. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  28290. * If the mesh has no geometry, it is simply returned as it is.
  28291. * The `data` are either a numeric array either a Float32Array.
  28292. * No new underlying VertexBuffer object is created.
  28293. * 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.
  28294. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  28295. *
  28296. * Possible `kind` values :
  28297. * - VertexBuffer.PositionKind
  28298. * - VertexBuffer.UVKind
  28299. * - VertexBuffer.UV2Kind
  28300. * - VertexBuffer.UV3Kind
  28301. * - VertexBuffer.UV4Kind
  28302. * - VertexBuffer.UV5Kind
  28303. * - VertexBuffer.UV6Kind
  28304. * - VertexBuffer.ColorKind
  28305. * - VertexBuffer.MatricesIndicesKind
  28306. * - VertexBuffer.MatricesIndicesExtraKind
  28307. * - VertexBuffer.MatricesWeightsKind
  28308. * - VertexBuffer.MatricesWeightsExtraKind
  28309. *
  28310. * Returns the Mesh.
  28311. */
  28312. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  28313. /**
  28314. * Sets the mesh indices.
  28315. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  28316. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  28317. * This method creates a new index buffer each call.
  28318. * Returns the Mesh.
  28319. */
  28320. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  28321. /**
  28322. * Boolean : True if the mesh owns the requested kind of data.
  28323. */
  28324. isVerticesDataPresent(kind: string): boolean;
  28325. /**
  28326. * Returns an array of indices (IndicesArray).
  28327. */
  28328. getIndices(): Nullable<IndicesArray>;
  28329. get _positions(): Nullable<Vector3[]>;
  28330. /**
  28331. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28332. * This means the mesh underlying bounding box and sphere are recomputed.
  28333. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28334. * @returns the current mesh
  28335. */
  28336. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  28337. /** @hidden */
  28338. _preActivate(): InstancedMesh;
  28339. /** @hidden */
  28340. _activate(renderId: number, intermediateRendering: boolean): boolean;
  28341. /** @hidden */
  28342. _postActivate(): void;
  28343. getWorldMatrix(): Matrix;
  28344. get isAnInstance(): boolean;
  28345. /**
  28346. * Returns the current associated LOD AbstractMesh.
  28347. */
  28348. getLOD(camera: Camera): AbstractMesh;
  28349. /** @hidden */
  28350. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28351. /** @hidden */
  28352. _syncSubMeshes(): InstancedMesh;
  28353. /** @hidden */
  28354. _generatePointsArray(): boolean;
  28355. /** @hidden */
  28356. _updateBoundingInfo(): AbstractMesh;
  28357. /**
  28358. * Creates a new InstancedMesh from the current mesh.
  28359. * - name (string) : the cloned mesh name
  28360. * - newParent (optional Node) : the optional Node to parent the clone to.
  28361. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  28362. *
  28363. * Returns the clone.
  28364. */
  28365. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  28366. /**
  28367. * Disposes the InstancedMesh.
  28368. * Returns nothing.
  28369. */
  28370. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28371. }
  28372. interface Mesh {
  28373. /**
  28374. * Register a custom buffer that will be instanced
  28375. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28376. * @param kind defines the buffer kind
  28377. * @param stride defines the stride in floats
  28378. */
  28379. registerInstancedBuffer(kind: string, stride: number): void;
  28380. /**
  28381. * true to use the edge renderer for all instances of this mesh
  28382. */
  28383. edgesShareWithInstances: boolean;
  28384. /** @hidden */
  28385. _userInstancedBuffersStorage: {
  28386. data: {
  28387. [key: string]: Float32Array;
  28388. };
  28389. sizes: {
  28390. [key: string]: number;
  28391. };
  28392. vertexBuffers: {
  28393. [key: string]: Nullable<VertexBuffer>;
  28394. };
  28395. strides: {
  28396. [key: string]: number;
  28397. };
  28398. };
  28399. }
  28400. interface AbstractMesh {
  28401. /**
  28402. * Object used to store instanced buffers defined by user
  28403. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  28404. */
  28405. instancedBuffers: {
  28406. [key: string]: any;
  28407. };
  28408. }
  28409. }
  28410. declare module BABYLON {
  28411. /**
  28412. * Defines the options associated with the creation of a shader material.
  28413. */
  28414. export interface IShaderMaterialOptions {
  28415. /**
  28416. * Does the material work in alpha blend mode
  28417. */
  28418. needAlphaBlending: boolean;
  28419. /**
  28420. * Does the material work in alpha test mode
  28421. */
  28422. needAlphaTesting: boolean;
  28423. /**
  28424. * The list of attribute names used in the shader
  28425. */
  28426. attributes: string[];
  28427. /**
  28428. * The list of unifrom names used in the shader
  28429. */
  28430. uniforms: string[];
  28431. /**
  28432. * The list of UBO names used in the shader
  28433. */
  28434. uniformBuffers: string[];
  28435. /**
  28436. * The list of sampler names used in the shader
  28437. */
  28438. samplers: string[];
  28439. /**
  28440. * The list of defines used in the shader
  28441. */
  28442. defines: string[];
  28443. }
  28444. /**
  28445. * 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.
  28446. *
  28447. * This returned material effects how the mesh will look based on the code in the shaders.
  28448. *
  28449. * @see https://doc.babylonjs.com/how_to/shader_material
  28450. */
  28451. export class ShaderMaterial extends Material {
  28452. private _shaderPath;
  28453. private _options;
  28454. private _textures;
  28455. private _textureArrays;
  28456. private _floats;
  28457. private _ints;
  28458. private _floatsArrays;
  28459. private _colors3;
  28460. private _colors3Arrays;
  28461. private _colors4;
  28462. private _colors4Arrays;
  28463. private _vectors2;
  28464. private _vectors3;
  28465. private _vectors4;
  28466. private _matrices;
  28467. private _matrixArrays;
  28468. private _matrices3x3;
  28469. private _matrices2x2;
  28470. private _vectors2Arrays;
  28471. private _vectors3Arrays;
  28472. private _vectors4Arrays;
  28473. private _cachedWorldViewMatrix;
  28474. private _cachedWorldViewProjectionMatrix;
  28475. private _renderId;
  28476. private _multiview;
  28477. private _cachedDefines;
  28478. /** Define the Url to load snippets */
  28479. static SnippetUrl: string;
  28480. /** Snippet ID if the material was created from the snippet server */
  28481. snippetId: string;
  28482. /**
  28483. * Instantiate a new shader material.
  28484. * 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.
  28485. * This returned material effects how the mesh will look based on the code in the shaders.
  28486. * @see https://doc.babylonjs.com/how_to/shader_material
  28487. * @param name Define the name of the material in the scene
  28488. * @param scene Define the scene the material belongs to
  28489. * @param shaderPath Defines the route to the shader code in one of three ways:
  28490. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  28491. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  28492. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  28493. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  28494. * @param options Define the options used to create the shader
  28495. */
  28496. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  28497. /**
  28498. * Gets the shader path used to define the shader code
  28499. * It can be modified to trigger a new compilation
  28500. */
  28501. get shaderPath(): any;
  28502. /**
  28503. * Sets the shader path used to define the shader code
  28504. * It can be modified to trigger a new compilation
  28505. */
  28506. set shaderPath(shaderPath: any);
  28507. /**
  28508. * Gets the options used to compile the shader.
  28509. * They can be modified to trigger a new compilation
  28510. */
  28511. get options(): IShaderMaterialOptions;
  28512. /**
  28513. * Gets the current class name of the material e.g. "ShaderMaterial"
  28514. * Mainly use in serialization.
  28515. * @returns the class name
  28516. */
  28517. getClassName(): string;
  28518. /**
  28519. * Specifies if the material will require alpha blending
  28520. * @returns a boolean specifying if alpha blending is needed
  28521. */
  28522. needAlphaBlending(): boolean;
  28523. /**
  28524. * Specifies if this material should be rendered in alpha test mode
  28525. * @returns a boolean specifying if an alpha test is needed.
  28526. */
  28527. needAlphaTesting(): boolean;
  28528. private _checkUniform;
  28529. /**
  28530. * Set a texture in the shader.
  28531. * @param name Define the name of the uniform samplers as defined in the shader
  28532. * @param texture Define the texture to bind to this sampler
  28533. * @return the material itself allowing "fluent" like uniform updates
  28534. */
  28535. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  28536. /**
  28537. * Set a texture array in the shader.
  28538. * @param name Define the name of the uniform sampler array as defined in the shader
  28539. * @param textures Define the list of textures to bind to this sampler
  28540. * @return the material itself allowing "fluent" like uniform updates
  28541. */
  28542. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  28543. /**
  28544. * Set a float in the shader.
  28545. * @param name Define the name of the uniform as defined in the shader
  28546. * @param value Define the value to give to the uniform
  28547. * @return the material itself allowing "fluent" like uniform updates
  28548. */
  28549. setFloat(name: string, value: number): ShaderMaterial;
  28550. /**
  28551. * Set a int in the shader.
  28552. * @param name Define the name of the uniform as defined in the shader
  28553. * @param value Define the value to give to the uniform
  28554. * @return the material itself allowing "fluent" like uniform updates
  28555. */
  28556. setInt(name: string, value: number): ShaderMaterial;
  28557. /**
  28558. * Set an array of floats in the shader.
  28559. * @param name Define the name of the uniform as defined in the shader
  28560. * @param value Define the value to give to the uniform
  28561. * @return the material itself allowing "fluent" like uniform updates
  28562. */
  28563. setFloats(name: string, value: number[]): ShaderMaterial;
  28564. /**
  28565. * Set a vec3 in the shader from a Color3.
  28566. * @param name Define the name of the uniform as defined in the shader
  28567. * @param value Define the value to give to the uniform
  28568. * @return the material itself allowing "fluent" like uniform updates
  28569. */
  28570. setColor3(name: string, value: Color3): ShaderMaterial;
  28571. /**
  28572. * Set a vec3 array in the shader from a Color3 array.
  28573. * @param name Define the name of the uniform as defined in the shader
  28574. * @param value Define the value to give to the uniform
  28575. * @return the material itself allowing "fluent" like uniform updates
  28576. */
  28577. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  28578. /**
  28579. * Set a vec4 in the shader from a Color4.
  28580. * @param name Define the name of the uniform as defined in the shader
  28581. * @param value Define the value to give to the uniform
  28582. * @return the material itself allowing "fluent" like uniform updates
  28583. */
  28584. setColor4(name: string, value: Color4): ShaderMaterial;
  28585. /**
  28586. * Set a vec4 array in the shader from a Color4 array.
  28587. * @param name Define the name of the uniform as defined in the shader
  28588. * @param value Define the value to give to the uniform
  28589. * @return the material itself allowing "fluent" like uniform updates
  28590. */
  28591. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  28592. /**
  28593. * Set a vec2 in the shader from a Vector2.
  28594. * @param name Define the name of the uniform as defined in the shader
  28595. * @param value Define the value to give to the uniform
  28596. * @return the material itself allowing "fluent" like uniform updates
  28597. */
  28598. setVector2(name: string, value: Vector2): ShaderMaterial;
  28599. /**
  28600. * Set a vec3 in the shader from a Vector3.
  28601. * @param name Define the name of the uniform as defined in the shader
  28602. * @param value Define the value to give to the uniform
  28603. * @return the material itself allowing "fluent" like uniform updates
  28604. */
  28605. setVector3(name: string, value: Vector3): ShaderMaterial;
  28606. /**
  28607. * Set a vec4 in the shader from a Vector4.
  28608. * @param name Define the name of the uniform as defined in the shader
  28609. * @param value Define the value to give to the uniform
  28610. * @return the material itself allowing "fluent" like uniform updates
  28611. */
  28612. setVector4(name: string, value: Vector4): ShaderMaterial;
  28613. /**
  28614. * Set a mat4 in the shader from a Matrix.
  28615. * @param name Define the name of the uniform as defined in the shader
  28616. * @param value Define the value to give to the uniform
  28617. * @return the material itself allowing "fluent" like uniform updates
  28618. */
  28619. setMatrix(name: string, value: Matrix): ShaderMaterial;
  28620. /**
  28621. * Set a float32Array in the shader from a matrix array.
  28622. * @param name Define the name of the uniform as defined in the shader
  28623. * @param value Define the value to give to the uniform
  28624. * @return the material itself allowing "fluent" like uniform updates
  28625. */
  28626. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  28627. /**
  28628. * Set a mat3 in the shader from a Float32Array.
  28629. * @param name Define the name of the uniform as defined in the shader
  28630. * @param value Define the value to give to the uniform
  28631. * @return the material itself allowing "fluent" like uniform updates
  28632. */
  28633. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28634. /**
  28635. * Set a mat2 in the shader from a Float32Array.
  28636. * @param name Define the name of the uniform as defined in the shader
  28637. * @param value Define the value to give to the uniform
  28638. * @return the material itself allowing "fluent" like uniform updates
  28639. */
  28640. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  28641. /**
  28642. * Set a vec2 array in the shader from a number array.
  28643. * @param name Define the name of the uniform as defined in the shader
  28644. * @param value Define the value to give to the uniform
  28645. * @return the material itself allowing "fluent" like uniform updates
  28646. */
  28647. setArray2(name: string, value: number[]): ShaderMaterial;
  28648. /**
  28649. * Set a vec3 array in the shader from a number array.
  28650. * @param name Define the name of the uniform as defined in the shader
  28651. * @param value Define the value to give to the uniform
  28652. * @return the material itself allowing "fluent" like uniform updates
  28653. */
  28654. setArray3(name: string, value: number[]): ShaderMaterial;
  28655. /**
  28656. * Set a vec4 array in the shader from a number array.
  28657. * @param name Define the name of the uniform as defined in the shader
  28658. * @param value Define the value to give to the uniform
  28659. * @return the material itself allowing "fluent" like uniform updates
  28660. */
  28661. setArray4(name: string, value: number[]): ShaderMaterial;
  28662. private _checkCache;
  28663. /**
  28664. * Specifies that the submesh is ready to be used
  28665. * @param mesh defines the mesh to check
  28666. * @param subMesh defines which submesh to check
  28667. * @param useInstances specifies that instances should be used
  28668. * @returns a boolean indicating that the submesh is ready or not
  28669. */
  28670. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  28671. /**
  28672. * Checks if the material is ready to render the requested mesh
  28673. * @param mesh Define the mesh to render
  28674. * @param useInstances Define whether or not the material is used with instances
  28675. * @returns true if ready, otherwise false
  28676. */
  28677. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  28678. /**
  28679. * Binds the world matrix to the material
  28680. * @param world defines the world transformation matrix
  28681. * @param effectOverride - If provided, use this effect instead of internal effect
  28682. */
  28683. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  28684. /**
  28685. * Binds the submesh to this material by preparing the effect and shader to draw
  28686. * @param world defines the world transformation matrix
  28687. * @param mesh defines the mesh containing the submesh
  28688. * @param subMesh defines the submesh to bind the material to
  28689. */
  28690. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  28691. /**
  28692. * Binds the material to the mesh
  28693. * @param world defines the world transformation matrix
  28694. * @param mesh defines the mesh to bind the material to
  28695. * @param effectOverride - If provided, use this effect instead of internal effect
  28696. */
  28697. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  28698. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  28699. /**
  28700. * Gets the active textures from the material
  28701. * @returns an array of textures
  28702. */
  28703. getActiveTextures(): BaseTexture[];
  28704. /**
  28705. * Specifies if the material uses a texture
  28706. * @param texture defines the texture to check against the material
  28707. * @returns a boolean specifying if the material uses the texture
  28708. */
  28709. hasTexture(texture: BaseTexture): boolean;
  28710. /**
  28711. * Makes a duplicate of the material, and gives it a new name
  28712. * @param name defines the new name for the duplicated material
  28713. * @returns the cloned material
  28714. */
  28715. clone(name: string): ShaderMaterial;
  28716. /**
  28717. * Disposes the material
  28718. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  28719. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  28720. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  28721. */
  28722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  28723. /**
  28724. * Serializes this material in a JSON representation
  28725. * @returns the serialized material object
  28726. */
  28727. serialize(): any;
  28728. /**
  28729. * Creates a shader material from parsed shader material data
  28730. * @param source defines the JSON represnetation of the material
  28731. * @param scene defines the hosting scene
  28732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28733. * @returns a new material
  28734. */
  28735. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  28736. /**
  28737. * Creates a new ShaderMaterial from a snippet saved in a remote file
  28738. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  28739. * @param url defines the url to load from
  28740. * @param scene defines the hosting scene
  28741. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28742. * @returns a promise that will resolve to the new ShaderMaterial
  28743. */
  28744. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28745. /**
  28746. * Creates a ShaderMaterial from a snippet saved by the Inspector
  28747. * @param snippetId defines the snippet to load
  28748. * @param scene defines the hosting scene
  28749. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  28750. * @returns a promise that will resolve to the new ShaderMaterial
  28751. */
  28752. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  28753. }
  28754. }
  28755. declare module BABYLON {
  28756. /** @hidden */
  28757. export var colorPixelShader: {
  28758. name: string;
  28759. shader: string;
  28760. };
  28761. }
  28762. declare module BABYLON {
  28763. /** @hidden */
  28764. export var colorVertexShader: {
  28765. name: string;
  28766. shader: string;
  28767. };
  28768. }
  28769. declare module BABYLON {
  28770. /**
  28771. * Line mesh
  28772. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  28773. */
  28774. export class LinesMesh extends Mesh {
  28775. /**
  28776. * If vertex color should be applied to the mesh
  28777. */
  28778. readonly useVertexColor?: boolean | undefined;
  28779. /**
  28780. * If vertex alpha should be applied to the mesh
  28781. */
  28782. readonly useVertexAlpha?: boolean | undefined;
  28783. /**
  28784. * Color of the line (Default: White)
  28785. */
  28786. color: Color3;
  28787. /**
  28788. * Alpha of the line (Default: 1)
  28789. */
  28790. alpha: number;
  28791. /**
  28792. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28793. * This margin is expressed in world space coordinates, so its value may vary.
  28794. * Default value is 0.1
  28795. */
  28796. intersectionThreshold: number;
  28797. private _colorShader;
  28798. private color4;
  28799. /**
  28800. * Creates a new LinesMesh
  28801. * @param name defines the name
  28802. * @param scene defines the hosting scene
  28803. * @param parent defines the parent mesh if any
  28804. * @param source defines the optional source LinesMesh used to clone data from
  28805. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28806. * When false, achieved by calling a clone(), also passing False.
  28807. * This will make creation of children, recursive.
  28808. * @param useVertexColor defines if this LinesMesh supports vertex color
  28809. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  28810. */
  28811. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  28812. /**
  28813. * If vertex color should be applied to the mesh
  28814. */
  28815. useVertexColor?: boolean | undefined,
  28816. /**
  28817. * If vertex alpha should be applied to the mesh
  28818. */
  28819. useVertexAlpha?: boolean | undefined);
  28820. private _addClipPlaneDefine;
  28821. private _removeClipPlaneDefine;
  28822. isReady(): boolean;
  28823. /**
  28824. * Returns the string "LineMesh"
  28825. */
  28826. getClassName(): string;
  28827. /**
  28828. * @hidden
  28829. */
  28830. get material(): Material;
  28831. /**
  28832. * @hidden
  28833. */
  28834. set material(value: Material);
  28835. /**
  28836. * @hidden
  28837. */
  28838. get checkCollisions(): boolean;
  28839. set checkCollisions(value: boolean);
  28840. /** @hidden */
  28841. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28842. /** @hidden */
  28843. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28844. /**
  28845. * Disposes of the line mesh
  28846. * @param doNotRecurse If children should be disposed
  28847. */
  28848. dispose(doNotRecurse?: boolean): void;
  28849. /**
  28850. * Returns a new LineMesh object cloned from the current one.
  28851. */
  28852. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  28853. /**
  28854. * Creates a new InstancedLinesMesh object from the mesh model.
  28855. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28856. * @param name defines the name of the new instance
  28857. * @returns a new InstancedLinesMesh
  28858. */
  28859. createInstance(name: string): InstancedLinesMesh;
  28860. }
  28861. /**
  28862. * Creates an instance based on a source LinesMesh
  28863. */
  28864. export class InstancedLinesMesh extends InstancedMesh {
  28865. /**
  28866. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  28867. * This margin is expressed in world space coordinates, so its value may vary.
  28868. * Initilized with the intersectionThreshold value of the source LinesMesh
  28869. */
  28870. intersectionThreshold: number;
  28871. constructor(name: string, source: LinesMesh);
  28872. /**
  28873. * Returns the string "InstancedLinesMesh".
  28874. */
  28875. getClassName(): string;
  28876. }
  28877. }
  28878. declare module BABYLON {
  28879. /** @hidden */
  28880. export var linePixelShader: {
  28881. name: string;
  28882. shader: string;
  28883. };
  28884. }
  28885. declare module BABYLON {
  28886. /** @hidden */
  28887. export var lineVertexShader: {
  28888. name: string;
  28889. shader: string;
  28890. };
  28891. }
  28892. declare module BABYLON {
  28893. interface Scene {
  28894. /** @hidden */
  28895. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  28896. }
  28897. interface AbstractMesh {
  28898. /**
  28899. * Gets the edgesRenderer associated with the mesh
  28900. */
  28901. edgesRenderer: Nullable<EdgesRenderer>;
  28902. }
  28903. interface LinesMesh {
  28904. /**
  28905. * Enables the edge rendering mode on the mesh.
  28906. * This mode makes the mesh edges visible
  28907. * @param epsilon defines the maximal distance between two angles to detect a face
  28908. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28909. * @returns the currentAbstractMesh
  28910. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28911. */
  28912. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  28913. }
  28914. interface InstancedLinesMesh {
  28915. /**
  28916. * Enables the edge rendering mode on the mesh.
  28917. * This mode makes the mesh edges visible
  28918. * @param epsilon defines the maximal distance between two angles to detect a face
  28919. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  28920. * @returns the current InstancedLinesMesh
  28921. * @see https://www.babylonjs-playground.com/#19O9TU#0
  28922. */
  28923. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  28924. }
  28925. /**
  28926. * Defines the minimum contract an Edges renderer should follow.
  28927. */
  28928. export interface IEdgesRenderer extends IDisposable {
  28929. /**
  28930. * Gets or sets a boolean indicating if the edgesRenderer is active
  28931. */
  28932. isEnabled: boolean;
  28933. /**
  28934. * Renders the edges of the attached mesh,
  28935. */
  28936. render(): void;
  28937. /**
  28938. * Checks wether or not the edges renderer is ready to render.
  28939. * @return true if ready, otherwise false.
  28940. */
  28941. isReady(): boolean;
  28942. /**
  28943. * List of instances to render in case the source mesh has instances
  28944. */
  28945. customInstances: SmartArray<Matrix>;
  28946. }
  28947. /**
  28948. * Defines the additional options of the edges renderer
  28949. */
  28950. export interface IEdgesRendererOptions {
  28951. /**
  28952. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  28953. * If not defined, the default value is true
  28954. */
  28955. useAlternateEdgeFinder?: boolean;
  28956. /**
  28957. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  28958. * If not defined, the default value is true.
  28959. * 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)
  28960. * This option is used only if useAlternateEdgeFinder = true
  28961. */
  28962. useFastVertexMerger?: boolean;
  28963. /**
  28964. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  28965. * The default value is 1e-6
  28966. * This option is used only if useAlternateEdgeFinder = true
  28967. */
  28968. epsilonVertexMerge?: number;
  28969. /**
  28970. * 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
  28971. * 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.
  28972. * This option is used only if useAlternateEdgeFinder = true
  28973. */
  28974. applyTessellation?: boolean;
  28975. /**
  28976. * 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
  28977. * The default value is 1e-6
  28978. * This option is used only if useAlternateEdgeFinder = true
  28979. */
  28980. epsilonVertexAligned?: number;
  28981. }
  28982. /**
  28983. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  28984. */
  28985. export class EdgesRenderer implements IEdgesRenderer {
  28986. /**
  28987. * Define the size of the edges with an orthographic camera
  28988. */
  28989. edgesWidthScalerForOrthographic: number;
  28990. /**
  28991. * Define the size of the edges with a perspective camera
  28992. */
  28993. edgesWidthScalerForPerspective: number;
  28994. protected _source: AbstractMesh;
  28995. protected _linesPositions: number[];
  28996. protected _linesNormals: number[];
  28997. protected _linesIndices: number[];
  28998. protected _epsilon: number;
  28999. protected _indicesCount: number;
  29000. protected _lineShader: ShaderMaterial;
  29001. protected _ib: DataBuffer;
  29002. protected _buffers: {
  29003. [key: string]: Nullable<VertexBuffer>;
  29004. };
  29005. protected _buffersForInstances: {
  29006. [key: string]: Nullable<VertexBuffer>;
  29007. };
  29008. protected _checkVerticesInsteadOfIndices: boolean;
  29009. protected _options: Nullable<IEdgesRendererOptions>;
  29010. private _meshRebuildObserver;
  29011. private _meshDisposeObserver;
  29012. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  29013. isEnabled: boolean;
  29014. /** Gets the vertices generated by the edge renderer */
  29015. get linesPositions(): Immutable<Array<number>>;
  29016. /** Gets the normals generated by the edge renderer */
  29017. get linesNormals(): Immutable<Array<number>>;
  29018. /** Gets the indices generated by the edge renderer */
  29019. get linesIndices(): Immutable<Array<number>>;
  29020. /**
  29021. * List of instances to render in case the source mesh has instances
  29022. */
  29023. customInstances: SmartArray<Matrix>;
  29024. private static GetShader;
  29025. /**
  29026. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  29027. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  29028. * @param source Mesh used to create edges
  29029. * @param epsilon sum of angles in adjacency to check for edge
  29030. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  29031. * @param generateEdgesLines - should generate Lines or only prepare resources.
  29032. * @param options The options to apply when generating the edges
  29033. */
  29034. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  29035. protected _prepareRessources(): void;
  29036. /** @hidden */
  29037. _rebuild(): void;
  29038. /**
  29039. * Releases the required resources for the edges renderer
  29040. */
  29041. dispose(): void;
  29042. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  29043. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  29044. /**
  29045. * Checks if the pair of p0 and p1 is en edge
  29046. * @param faceIndex
  29047. * @param edge
  29048. * @param faceNormals
  29049. * @param p0
  29050. * @param p1
  29051. * @private
  29052. */
  29053. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  29054. /**
  29055. * push line into the position, normal and index buffer
  29056. * @protected
  29057. */
  29058. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  29059. /**
  29060. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  29061. */
  29062. private _tessellateTriangle;
  29063. private _generateEdgesLinesAlternate;
  29064. /**
  29065. * Generates lines edges from adjacencjes
  29066. * @private
  29067. */
  29068. _generateEdgesLines(): void;
  29069. /**
  29070. * Checks wether or not the edges renderer is ready to render.
  29071. * @return true if ready, otherwise false.
  29072. */
  29073. isReady(): boolean;
  29074. /**
  29075. * Renders the edges of the attached mesh,
  29076. */
  29077. render(): void;
  29078. }
  29079. /**
  29080. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  29081. */
  29082. export class LineEdgesRenderer extends EdgesRenderer {
  29083. /**
  29084. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  29085. * @param source LineMesh used to generate edges
  29086. * @param epsilon not important (specified angle for edge detection)
  29087. * @param checkVerticesInsteadOfIndices not important for LineMesh
  29088. */
  29089. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  29090. /**
  29091. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  29092. */
  29093. _generateEdgesLines(): void;
  29094. }
  29095. }
  29096. declare module BABYLON {
  29097. /**
  29098. * This represents the object necessary to create a rendering group.
  29099. * This is exclusively used and created by the rendering manager.
  29100. * To modify the behavior, you use the available helpers in your scene or meshes.
  29101. * @hidden
  29102. */
  29103. export class RenderingGroup {
  29104. index: number;
  29105. private static _zeroVector;
  29106. private _scene;
  29107. private _opaqueSubMeshes;
  29108. private _transparentSubMeshes;
  29109. private _alphaTestSubMeshes;
  29110. private _depthOnlySubMeshes;
  29111. private _particleSystems;
  29112. private _spriteManagers;
  29113. private _opaqueSortCompareFn;
  29114. private _alphaTestSortCompareFn;
  29115. private _transparentSortCompareFn;
  29116. private _renderOpaque;
  29117. private _renderAlphaTest;
  29118. private _renderTransparent;
  29119. /** @hidden */
  29120. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  29121. onBeforeTransparentRendering: () => void;
  29122. /**
  29123. * Set the opaque sort comparison function.
  29124. * If null the sub meshes will be render in the order they were created
  29125. */
  29126. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29127. /**
  29128. * Set the alpha test sort comparison function.
  29129. * If null the sub meshes will be render in the order they were created
  29130. */
  29131. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29132. /**
  29133. * Set the transparent sort comparison function.
  29134. * If null the sub meshes will be render in the order they were created
  29135. */
  29136. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  29137. /**
  29138. * Creates a new rendering group.
  29139. * @param index The rendering group index
  29140. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  29141. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  29142. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  29143. */
  29144. 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>);
  29145. /**
  29146. * Render all the sub meshes contained in the group.
  29147. * @param customRenderFunction Used to override the default render behaviour of the group.
  29148. * @returns true if rendered some submeshes.
  29149. */
  29150. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  29151. /**
  29152. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  29153. * @param subMeshes The submeshes to render
  29154. */
  29155. private renderOpaqueSorted;
  29156. /**
  29157. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  29158. * @param subMeshes The submeshes to render
  29159. */
  29160. private renderAlphaTestSorted;
  29161. /**
  29162. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  29163. * @param subMeshes The submeshes to render
  29164. */
  29165. private renderTransparentSorted;
  29166. /**
  29167. * Renders the submeshes in a specified order.
  29168. * @param subMeshes The submeshes to sort before render
  29169. * @param sortCompareFn The comparison function use to sort
  29170. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  29171. * @param transparent Specifies to activate blending if true
  29172. */
  29173. private static renderSorted;
  29174. /**
  29175. * Renders the submeshes in the order they were dispatched (no sort applied).
  29176. * @param subMeshes The submeshes to render
  29177. */
  29178. private static renderUnsorted;
  29179. /**
  29180. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29181. * are rendered back to front if in the same alpha index.
  29182. *
  29183. * @param a The first submesh
  29184. * @param b The second submesh
  29185. * @returns The result of the comparison
  29186. */
  29187. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  29188. /**
  29189. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29190. * are rendered back to front.
  29191. *
  29192. * @param a The first submesh
  29193. * @param b The second submesh
  29194. * @returns The result of the comparison
  29195. */
  29196. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  29197. /**
  29198. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  29199. * are rendered front to back (prevent overdraw).
  29200. *
  29201. * @param a The first submesh
  29202. * @param b The second submesh
  29203. * @returns The result of the comparison
  29204. */
  29205. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  29206. /**
  29207. * Resets the different lists of submeshes to prepare a new frame.
  29208. */
  29209. prepare(): void;
  29210. dispose(): void;
  29211. /**
  29212. * Inserts the submesh in its correct queue depending on its material.
  29213. * @param subMesh The submesh to dispatch
  29214. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29215. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29216. */
  29217. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29218. dispatchSprites(spriteManager: ISpriteManager): void;
  29219. dispatchParticles(particleSystem: IParticleSystem): void;
  29220. private _renderParticles;
  29221. private _renderSprites;
  29222. }
  29223. }
  29224. declare module BABYLON {
  29225. /**
  29226. * Interface describing the different options available in the rendering manager
  29227. * regarding Auto Clear between groups.
  29228. */
  29229. export interface IRenderingManagerAutoClearSetup {
  29230. /**
  29231. * Defines whether or not autoclear is enable.
  29232. */
  29233. autoClear: boolean;
  29234. /**
  29235. * Defines whether or not to autoclear the depth buffer.
  29236. */
  29237. depth: boolean;
  29238. /**
  29239. * Defines whether or not to autoclear the stencil buffer.
  29240. */
  29241. stencil: boolean;
  29242. }
  29243. /**
  29244. * This class is used by the onRenderingGroupObservable
  29245. */
  29246. export class RenderingGroupInfo {
  29247. /**
  29248. * The Scene that being rendered
  29249. */
  29250. scene: Scene;
  29251. /**
  29252. * The camera currently used for the rendering pass
  29253. */
  29254. camera: Nullable<Camera>;
  29255. /**
  29256. * The ID of the renderingGroup being processed
  29257. */
  29258. renderingGroupId: number;
  29259. }
  29260. /**
  29261. * This is the manager responsible of all the rendering for meshes sprites and particles.
  29262. * It is enable to manage the different groups as well as the different necessary sort functions.
  29263. * This should not be used directly aside of the few static configurations
  29264. */
  29265. export class RenderingManager {
  29266. /**
  29267. * The max id used for rendering groups (not included)
  29268. */
  29269. static MAX_RENDERINGGROUPS: number;
  29270. /**
  29271. * The min id used for rendering groups (included)
  29272. */
  29273. static MIN_RENDERINGGROUPS: number;
  29274. /**
  29275. * Used to globally prevent autoclearing scenes.
  29276. */
  29277. static AUTOCLEAR: boolean;
  29278. /**
  29279. * @hidden
  29280. */
  29281. _useSceneAutoClearSetup: boolean;
  29282. private _scene;
  29283. private _renderingGroups;
  29284. private _depthStencilBufferAlreadyCleaned;
  29285. private _autoClearDepthStencil;
  29286. private _customOpaqueSortCompareFn;
  29287. private _customAlphaTestSortCompareFn;
  29288. private _customTransparentSortCompareFn;
  29289. private _renderingGroupInfo;
  29290. /**
  29291. * Instantiates a new rendering group for a particular scene
  29292. * @param scene Defines the scene the groups belongs to
  29293. */
  29294. constructor(scene: Scene);
  29295. private _clearDepthStencilBuffer;
  29296. /**
  29297. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  29298. * @hidden
  29299. */
  29300. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  29301. /**
  29302. * Resets the different information of the group to prepare a new frame
  29303. * @hidden
  29304. */
  29305. reset(): void;
  29306. /**
  29307. * Dispose and release the group and its associated resources.
  29308. * @hidden
  29309. */
  29310. dispose(): void;
  29311. /**
  29312. * Clear the info related to rendering groups preventing retention points during dispose.
  29313. */
  29314. freeRenderingGroups(): void;
  29315. private _prepareRenderingGroup;
  29316. /**
  29317. * Add a sprite manager to the rendering manager in order to render it this frame.
  29318. * @param spriteManager Define the sprite manager to render
  29319. */
  29320. dispatchSprites(spriteManager: ISpriteManager): void;
  29321. /**
  29322. * Add a particle system to the rendering manager in order to render it this frame.
  29323. * @param particleSystem Define the particle system to render
  29324. */
  29325. dispatchParticles(particleSystem: IParticleSystem): void;
  29326. /**
  29327. * Add a submesh to the manager in order to render it this frame
  29328. * @param subMesh The submesh to dispatch
  29329. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  29330. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  29331. */
  29332. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  29333. /**
  29334. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  29335. * This allowed control for front to back rendering or reversly depending of the special needs.
  29336. *
  29337. * @param renderingGroupId The rendering group id corresponding to its index
  29338. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  29339. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  29340. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  29341. */
  29342. 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;
  29343. /**
  29344. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  29345. *
  29346. * @param renderingGroupId The rendering group id corresponding to its index
  29347. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  29348. * @param depth Automatically clears depth between groups if true and autoClear is true.
  29349. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  29350. */
  29351. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  29352. /**
  29353. * Gets the current auto clear configuration for one rendering group of the rendering
  29354. * manager.
  29355. * @param index the rendering group index to get the information for
  29356. * @returns The auto clear setup for the requested rendering group
  29357. */
  29358. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  29359. }
  29360. }
  29361. declare module BABYLON {
  29362. /**
  29363. * Defines the options associated with the creation of a custom shader for a shadow generator.
  29364. */
  29365. export interface ICustomShaderOptions {
  29366. /**
  29367. * Gets or sets the custom shader name to use
  29368. */
  29369. shaderName: string;
  29370. /**
  29371. * The list of attribute names used in the shader
  29372. */
  29373. attributes?: string[];
  29374. /**
  29375. * The list of unifrom names used in the shader
  29376. */
  29377. uniforms?: string[];
  29378. /**
  29379. * The list of sampler names used in the shader
  29380. */
  29381. samplers?: string[];
  29382. /**
  29383. * The list of defines used in the shader
  29384. */
  29385. defines?: string[];
  29386. }
  29387. /**
  29388. * Interface to implement to create a shadow generator compatible with BJS.
  29389. */
  29390. export interface IShadowGenerator {
  29391. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29392. id: string;
  29393. /**
  29394. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29395. * @returns The render target texture if present otherwise, null
  29396. */
  29397. getShadowMap(): Nullable<RenderTargetTexture>;
  29398. /**
  29399. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29400. * @param subMesh The submesh we want to render in the shadow map
  29401. * @param useInstances Defines wether will draw in the map using instances
  29402. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29403. * @returns true if ready otherwise, false
  29404. */
  29405. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29406. /**
  29407. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29408. * @param defines Defines of the material we want to update
  29409. * @param lightIndex Index of the light in the enabled light list of the material
  29410. */
  29411. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  29412. /**
  29413. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29414. * defined in the generator but impacting the effect).
  29415. * It implies the unifroms available on the materials are the standard BJS ones.
  29416. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29417. * @param effect The effect we are binfing the information for
  29418. */
  29419. bindShadowLight(lightIndex: string, effect: Effect): void;
  29420. /**
  29421. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29422. * (eq to shadow prjection matrix * light transform matrix)
  29423. * @returns The transform matrix used to create the shadow map
  29424. */
  29425. getTransformMatrix(): Matrix;
  29426. /**
  29427. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29428. * Cube and 2D textures for instance.
  29429. */
  29430. recreateShadowMap(): void;
  29431. /**
  29432. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29433. * @param onCompiled Callback triggered at the and of the effects compilation
  29434. * @param options Sets of optional options forcing the compilation with different modes
  29435. */
  29436. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29437. useInstances: boolean;
  29438. }>): void;
  29439. /**
  29440. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29441. * @param options Sets of optional options forcing the compilation with different modes
  29442. * @returns A promise that resolves when the compilation completes
  29443. */
  29444. forceCompilationAsync(options?: Partial<{
  29445. useInstances: boolean;
  29446. }>): Promise<void>;
  29447. /**
  29448. * Serializes the shadow generator setup to a json object.
  29449. * @returns The serialized JSON object
  29450. */
  29451. serialize(): any;
  29452. /**
  29453. * Disposes the Shadow map and related Textures and effects.
  29454. */
  29455. dispose(): void;
  29456. }
  29457. /**
  29458. * Default implementation IShadowGenerator.
  29459. * This is the main object responsible of generating shadows in the framework.
  29460. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  29461. */
  29462. export class ShadowGenerator implements IShadowGenerator {
  29463. private static _Counter;
  29464. /**
  29465. * Name of the shadow generator class
  29466. */
  29467. static CLASSNAME: string;
  29468. /**
  29469. * Shadow generator mode None: no filtering applied.
  29470. */
  29471. static readonly FILTER_NONE: number;
  29472. /**
  29473. * Shadow generator mode ESM: Exponential Shadow Mapping.
  29474. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29475. */
  29476. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  29477. /**
  29478. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  29479. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  29480. */
  29481. static readonly FILTER_POISSONSAMPLING: number;
  29482. /**
  29483. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  29484. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29485. */
  29486. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  29487. /**
  29488. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  29489. * edge artifacts on steep falloff.
  29490. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29491. */
  29492. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  29493. /**
  29494. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  29495. * edge artifacts on steep falloff.
  29496. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  29497. */
  29498. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  29499. /**
  29500. * Shadow generator mode PCF: Percentage Closer Filtering
  29501. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29502. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  29503. */
  29504. static readonly FILTER_PCF: number;
  29505. /**
  29506. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  29507. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  29508. * Contact Hardening
  29509. */
  29510. static readonly FILTER_PCSS: number;
  29511. /**
  29512. * Reserved for PCF and PCSS
  29513. * Highest Quality.
  29514. *
  29515. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  29516. *
  29517. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  29518. */
  29519. static readonly QUALITY_HIGH: number;
  29520. /**
  29521. * Reserved for PCF and PCSS
  29522. * Good tradeoff for quality/perf cross devices
  29523. *
  29524. * Execute PCF on a 3*3 kernel.
  29525. *
  29526. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  29527. */
  29528. static readonly QUALITY_MEDIUM: number;
  29529. /**
  29530. * Reserved for PCF and PCSS
  29531. * The lowest quality but the fastest.
  29532. *
  29533. * Execute PCF on a 1*1 kernel.
  29534. *
  29535. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  29536. */
  29537. static readonly QUALITY_LOW: number;
  29538. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  29539. id: string;
  29540. /** Gets or sets the custom shader name to use */
  29541. customShaderOptions: ICustomShaderOptions;
  29542. /** Gets or sets a custom function to allow/disallow rendering a sub mesh in the shadow map */
  29543. customAllowRendering: (subMesh: SubMesh) => boolean;
  29544. /**
  29545. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  29546. */
  29547. onBeforeShadowMapRenderObservable: Observable<Effect>;
  29548. /**
  29549. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  29550. */
  29551. onAfterShadowMapRenderObservable: Observable<Effect>;
  29552. /**
  29553. * Observable triggered before a mesh is rendered in the shadow map.
  29554. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  29555. */
  29556. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  29557. /**
  29558. * Observable triggered after a mesh is rendered in the shadow map.
  29559. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  29560. */
  29561. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  29562. protected _bias: number;
  29563. /**
  29564. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  29565. */
  29566. get bias(): number;
  29567. /**
  29568. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  29569. */
  29570. set bias(bias: number);
  29571. protected _normalBias: number;
  29572. /**
  29573. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29574. */
  29575. get normalBias(): number;
  29576. /**
  29577. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  29578. */
  29579. set normalBias(normalBias: number);
  29580. protected _blurBoxOffset: number;
  29581. /**
  29582. * Gets the blur box offset: offset applied during the blur pass.
  29583. * Only useful if useKernelBlur = false
  29584. */
  29585. get blurBoxOffset(): number;
  29586. /**
  29587. * Sets the blur box offset: offset applied during the blur pass.
  29588. * Only useful if useKernelBlur = false
  29589. */
  29590. set blurBoxOffset(value: number);
  29591. protected _blurScale: number;
  29592. /**
  29593. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  29594. * 2 means half of the size.
  29595. */
  29596. get blurScale(): number;
  29597. /**
  29598. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  29599. * 2 means half of the size.
  29600. */
  29601. set blurScale(value: number);
  29602. protected _blurKernel: number;
  29603. /**
  29604. * Gets the blur kernel: kernel size of the blur pass.
  29605. * Only useful if useKernelBlur = true
  29606. */
  29607. get blurKernel(): number;
  29608. /**
  29609. * Sets the blur kernel: kernel size of the blur pass.
  29610. * Only useful if useKernelBlur = true
  29611. */
  29612. set blurKernel(value: number);
  29613. protected _useKernelBlur: boolean;
  29614. /**
  29615. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  29616. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29617. */
  29618. get useKernelBlur(): boolean;
  29619. /**
  29620. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  29621. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  29622. */
  29623. set useKernelBlur(value: boolean);
  29624. protected _depthScale: number;
  29625. /**
  29626. * Gets the depth scale used in ESM mode.
  29627. */
  29628. get depthScale(): number;
  29629. /**
  29630. * Sets the depth scale used in ESM mode.
  29631. * This can override the scale stored on the light.
  29632. */
  29633. set depthScale(value: number);
  29634. protected _validateFilter(filter: number): number;
  29635. protected _filter: number;
  29636. /**
  29637. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  29638. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29639. */
  29640. get filter(): number;
  29641. /**
  29642. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  29643. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  29644. */
  29645. set filter(value: number);
  29646. /**
  29647. * Gets if the current filter is set to Poisson Sampling.
  29648. */
  29649. get usePoissonSampling(): boolean;
  29650. /**
  29651. * Sets the current filter to Poisson Sampling.
  29652. */
  29653. set usePoissonSampling(value: boolean);
  29654. /**
  29655. * Gets if the current filter is set to ESM.
  29656. */
  29657. get useExponentialShadowMap(): boolean;
  29658. /**
  29659. * Sets the current filter is to ESM.
  29660. */
  29661. set useExponentialShadowMap(value: boolean);
  29662. /**
  29663. * Gets if the current filter is set to filtered ESM.
  29664. */
  29665. get useBlurExponentialShadowMap(): boolean;
  29666. /**
  29667. * Gets if the current filter is set to filtered ESM.
  29668. */
  29669. set useBlurExponentialShadowMap(value: boolean);
  29670. /**
  29671. * Gets if the current filter is set to "close ESM" (using the inverse of the
  29672. * exponential to prevent steep falloff artifacts).
  29673. */
  29674. get useCloseExponentialShadowMap(): boolean;
  29675. /**
  29676. * Sets the current filter to "close ESM" (using the inverse of the
  29677. * exponential to prevent steep falloff artifacts).
  29678. */
  29679. set useCloseExponentialShadowMap(value: boolean);
  29680. /**
  29681. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  29682. * exponential to prevent steep falloff artifacts).
  29683. */
  29684. get useBlurCloseExponentialShadowMap(): boolean;
  29685. /**
  29686. * Sets the current filter to filtered "close ESM" (using the inverse of the
  29687. * exponential to prevent steep falloff artifacts).
  29688. */
  29689. set useBlurCloseExponentialShadowMap(value: boolean);
  29690. /**
  29691. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  29692. */
  29693. get usePercentageCloserFiltering(): boolean;
  29694. /**
  29695. * Sets the current filter to "PCF" (percentage closer filtering).
  29696. */
  29697. set usePercentageCloserFiltering(value: boolean);
  29698. protected _filteringQuality: number;
  29699. /**
  29700. * Gets the PCF or PCSS Quality.
  29701. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29702. */
  29703. get filteringQuality(): number;
  29704. /**
  29705. * Sets the PCF or PCSS Quality.
  29706. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  29707. */
  29708. set filteringQuality(filteringQuality: number);
  29709. /**
  29710. * Gets if the current filter is set to "PCSS" (contact hardening).
  29711. */
  29712. get useContactHardeningShadow(): boolean;
  29713. /**
  29714. * Sets the current filter to "PCSS" (contact hardening).
  29715. */
  29716. set useContactHardeningShadow(value: boolean);
  29717. protected _contactHardeningLightSizeUVRatio: number;
  29718. /**
  29719. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29720. * Using a ratio helps keeping shape stability independently of the map size.
  29721. *
  29722. * It does not account for the light projection as it was having too much
  29723. * instability during the light setup or during light position changes.
  29724. *
  29725. * Only valid if useContactHardeningShadow is true.
  29726. */
  29727. get contactHardeningLightSizeUVRatio(): number;
  29728. /**
  29729. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  29730. * Using a ratio helps keeping shape stability independently of the map size.
  29731. *
  29732. * It does not account for the light projection as it was having too much
  29733. * instability during the light setup or during light position changes.
  29734. *
  29735. * Only valid if useContactHardeningShadow is true.
  29736. */
  29737. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  29738. protected _darkness: number;
  29739. /** Gets or sets the actual darkness of a shadow */
  29740. get darkness(): number;
  29741. set darkness(value: number);
  29742. /**
  29743. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  29744. * 0 means strongest and 1 would means no shadow.
  29745. * @returns the darkness.
  29746. */
  29747. getDarkness(): number;
  29748. /**
  29749. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  29750. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  29751. * @returns the shadow generator allowing fluent coding.
  29752. */
  29753. setDarkness(darkness: number): ShadowGenerator;
  29754. protected _transparencyShadow: boolean;
  29755. /** Gets or sets the ability to have transparent shadow */
  29756. get transparencyShadow(): boolean;
  29757. set transparencyShadow(value: boolean);
  29758. /**
  29759. * Sets the ability to have transparent shadow (boolean).
  29760. * @param transparent True if transparent else False
  29761. * @returns the shadow generator allowing fluent coding
  29762. */
  29763. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  29764. /**
  29765. * Enables or disables shadows with varying strength based on the transparency
  29766. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  29767. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  29768. * mesh.visibility * alphaTexture.a
  29769. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  29770. */
  29771. enableSoftTransparentShadow: boolean;
  29772. protected _shadowMap: Nullable<RenderTargetTexture>;
  29773. protected _shadowMap2: Nullable<RenderTargetTexture>;
  29774. /**
  29775. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  29776. * @returns The render target texture if present otherwise, null
  29777. */
  29778. getShadowMap(): Nullable<RenderTargetTexture>;
  29779. /**
  29780. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  29781. * @returns The render target texture if the shadow map is present otherwise, null
  29782. */
  29783. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  29784. /**
  29785. * Gets the class name of that object
  29786. * @returns "ShadowGenerator"
  29787. */
  29788. getClassName(): string;
  29789. /**
  29790. * Helper function to add a mesh and its descendants to the list of shadow casters.
  29791. * @param mesh Mesh to add
  29792. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  29793. * @returns the Shadow Generator itself
  29794. */
  29795. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29796. /**
  29797. * Helper function to remove a mesh and its descendants from the list of shadow casters
  29798. * @param mesh Mesh to remove
  29799. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  29800. * @returns the Shadow Generator itself
  29801. */
  29802. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  29803. /**
  29804. * Controls the extent to which the shadows fade out at the edge of the frustum
  29805. */
  29806. frustumEdgeFalloff: number;
  29807. protected _light: IShadowLight;
  29808. /**
  29809. * Returns the associated light object.
  29810. * @returns the light generating the shadow
  29811. */
  29812. getLight(): IShadowLight;
  29813. /**
  29814. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  29815. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  29816. * It might on the other hand introduce peter panning.
  29817. */
  29818. forceBackFacesOnly: boolean;
  29819. protected _scene: Scene;
  29820. protected _lightDirection: Vector3;
  29821. protected _viewMatrix: Matrix;
  29822. protected _projectionMatrix: Matrix;
  29823. protected _transformMatrix: Matrix;
  29824. protected _cachedPosition: Vector3;
  29825. protected _cachedDirection: Vector3;
  29826. protected _cachedDefines: string;
  29827. protected _currentRenderID: number;
  29828. protected _boxBlurPostprocess: Nullable<PostProcess>;
  29829. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  29830. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  29831. protected _blurPostProcesses: PostProcess[];
  29832. protected _mapSize: number;
  29833. protected _currentFaceIndex: number;
  29834. protected _currentFaceIndexCache: number;
  29835. protected _textureType: number;
  29836. protected _defaultTextureMatrix: Matrix;
  29837. protected _storedUniqueId: Nullable<number>;
  29838. protected _nameForCustomEffect: string;
  29839. /** @hidden */
  29840. static _SceneComponentInitialization: (scene: Scene) => void;
  29841. /**
  29842. * Gets or sets the size of the texture what stores the shadows
  29843. */
  29844. get mapSize(): number;
  29845. set mapSize(size: number);
  29846. /**
  29847. * Creates a ShadowGenerator object.
  29848. * A ShadowGenerator is the required tool to use the shadows.
  29849. * Each light casting shadows needs to use its own ShadowGenerator.
  29850. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  29851. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  29852. * @param light The light object generating the shadows.
  29853. * @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.
  29854. */
  29855. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  29856. protected _initializeGenerator(): void;
  29857. protected _createTargetRenderTexture(): void;
  29858. protected _initializeShadowMap(): void;
  29859. protected _initializeBlurRTTAndPostProcesses(): void;
  29860. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  29861. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  29862. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  29863. protected _applyFilterValues(): void;
  29864. /**
  29865. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29866. * @param onCompiled Callback triggered at the and of the effects compilation
  29867. * @param options Sets of optional options forcing the compilation with different modes
  29868. */
  29869. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  29870. useInstances: boolean;
  29871. }>): void;
  29872. /**
  29873. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  29874. * @param options Sets of optional options forcing the compilation with different modes
  29875. * @returns A promise that resolves when the compilation completes
  29876. */
  29877. forceCompilationAsync(options?: Partial<{
  29878. useInstances: boolean;
  29879. }>): Promise<void>;
  29880. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  29881. private _prepareShadowDefines;
  29882. /**
  29883. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  29884. * @param subMesh The submesh we want to render in the shadow map
  29885. * @param useInstances Defines wether will draw in the map using instances
  29886. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  29887. * @returns true if ready otherwise, false
  29888. */
  29889. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  29890. /**
  29891. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  29892. * @param defines Defines of the material we want to update
  29893. * @param lightIndex Index of the light in the enabled light list of the material
  29894. */
  29895. prepareDefines(defines: any, lightIndex: number): void;
  29896. /**
  29897. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  29898. * defined in the generator but impacting the effect).
  29899. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  29900. * @param effect The effect we are binfing the information for
  29901. */
  29902. bindShadowLight(lightIndex: string, effect: Effect): void;
  29903. /**
  29904. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  29905. * (eq to shadow prjection matrix * light transform matrix)
  29906. * @returns The transform matrix used to create the shadow map
  29907. */
  29908. getTransformMatrix(): Matrix;
  29909. /**
  29910. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  29911. * Cube and 2D textures for instance.
  29912. */
  29913. recreateShadowMap(): void;
  29914. protected _disposeBlurPostProcesses(): void;
  29915. protected _disposeRTTandPostProcesses(): void;
  29916. /**
  29917. * Disposes the ShadowGenerator.
  29918. * Returns nothing.
  29919. */
  29920. dispose(): void;
  29921. /**
  29922. * Serializes the shadow generator setup to a json object.
  29923. * @returns The serialized JSON object
  29924. */
  29925. serialize(): any;
  29926. /**
  29927. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  29928. * @param parsedShadowGenerator The JSON object to parse
  29929. * @param scene The scene to create the shadow map for
  29930. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  29931. * @returns The parsed shadow generator
  29932. */
  29933. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  29934. }
  29935. }
  29936. declare module BABYLON {
  29937. /**
  29938. * Options to be used when creating a shadow depth material
  29939. */
  29940. export interface IIOptionShadowDepthMaterial {
  29941. /** Variables in the vertex shader code that need to have their names remapped.
  29942. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  29943. * "var_name" should be either: worldPos or vNormalW
  29944. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  29945. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  29946. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  29947. */
  29948. remappedVariables?: string[];
  29949. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  29950. standalone?: boolean;
  29951. }
  29952. /**
  29953. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  29954. */
  29955. export class ShadowDepthWrapper {
  29956. private _scene;
  29957. private _options?;
  29958. private _baseMaterial;
  29959. private _onEffectCreatedObserver;
  29960. private _subMeshToEffect;
  29961. private _subMeshToDepthEffect;
  29962. private _meshes;
  29963. /** @hidden */
  29964. _matriceNames: any;
  29965. /** Gets the standalone status of the wrapper */
  29966. get standalone(): boolean;
  29967. /** Gets the base material the wrapper is built upon */
  29968. get baseMaterial(): Material;
  29969. /**
  29970. * Instantiate a new shadow depth wrapper.
  29971. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  29972. * generate the shadow depth map. For more information, please refer to the documentation:
  29973. * https://doc.babylonjs.com/babylon101/shadows
  29974. * @param baseMaterial Material to wrap
  29975. * @param scene Define the scene the material belongs to
  29976. * @param options Options used to create the wrapper
  29977. */
  29978. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  29979. /**
  29980. * Gets the effect to use to generate the depth map
  29981. * @param subMesh subMesh to get the effect for
  29982. * @param shadowGenerator shadow generator to get the effect for
  29983. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  29984. */
  29985. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  29986. /**
  29987. * Specifies that the submesh is ready to be used for depth rendering
  29988. * @param subMesh submesh to check
  29989. * @param defines the list of defines to take into account when checking the effect
  29990. * @param shadowGenerator combined with subMesh, it defines the effect to check
  29991. * @param useInstances specifies that instances should be used
  29992. * @returns a boolean indicating that the submesh is ready or not
  29993. */
  29994. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  29995. /**
  29996. * Disposes the resources
  29997. */
  29998. dispose(): void;
  29999. private _makeEffect;
  30000. }
  30001. }
  30002. declare module BABYLON {
  30003. /**
  30004. * Options for compiling materials.
  30005. */
  30006. export interface IMaterialCompilationOptions {
  30007. /**
  30008. * Defines whether clip planes are enabled.
  30009. */
  30010. clipPlane: boolean;
  30011. /**
  30012. * Defines whether instances are enabled.
  30013. */
  30014. useInstances: boolean;
  30015. }
  30016. /**
  30017. * Options passed when calling customShaderNameResolve
  30018. */
  30019. export interface ICustomShaderNameResolveOptions {
  30020. /**
  30021. * 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
  30022. */
  30023. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30024. }
  30025. /**
  30026. * Base class for the main features of a material in Babylon.js
  30027. */
  30028. export class Material implements IAnimatable {
  30029. /**
  30030. * Returns the triangle fill mode
  30031. */
  30032. static readonly TriangleFillMode: number;
  30033. /**
  30034. * Returns the wireframe mode
  30035. */
  30036. static readonly WireFrameFillMode: number;
  30037. /**
  30038. * Returns the point fill mode
  30039. */
  30040. static readonly PointFillMode: number;
  30041. /**
  30042. * Returns the point list draw mode
  30043. */
  30044. static readonly PointListDrawMode: number;
  30045. /**
  30046. * Returns the line list draw mode
  30047. */
  30048. static readonly LineListDrawMode: number;
  30049. /**
  30050. * Returns the line loop draw mode
  30051. */
  30052. static readonly LineLoopDrawMode: number;
  30053. /**
  30054. * Returns the line strip draw mode
  30055. */
  30056. static readonly LineStripDrawMode: number;
  30057. /**
  30058. * Returns the triangle strip draw mode
  30059. */
  30060. static readonly TriangleStripDrawMode: number;
  30061. /**
  30062. * Returns the triangle fan draw mode
  30063. */
  30064. static readonly TriangleFanDrawMode: number;
  30065. /**
  30066. * Stores the clock-wise side orientation
  30067. */
  30068. static readonly ClockWiseSideOrientation: number;
  30069. /**
  30070. * Stores the counter clock-wise side orientation
  30071. */
  30072. static readonly CounterClockWiseSideOrientation: number;
  30073. /**
  30074. * The dirty texture flag value
  30075. */
  30076. static readonly TextureDirtyFlag: number;
  30077. /**
  30078. * The dirty light flag value
  30079. */
  30080. static readonly LightDirtyFlag: number;
  30081. /**
  30082. * The dirty fresnel flag value
  30083. */
  30084. static readonly FresnelDirtyFlag: number;
  30085. /**
  30086. * The dirty attribute flag value
  30087. */
  30088. static readonly AttributesDirtyFlag: number;
  30089. /**
  30090. * The dirty misc flag value
  30091. */
  30092. static readonly MiscDirtyFlag: number;
  30093. /**
  30094. * The dirty prepass flag value
  30095. */
  30096. static readonly PrePassDirtyFlag: number;
  30097. /**
  30098. * The all dirty flag value
  30099. */
  30100. static readonly AllDirtyFlag: number;
  30101. /**
  30102. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30103. */
  30104. static readonly MATERIAL_OPAQUE: number;
  30105. /**
  30106. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30107. */
  30108. static readonly MATERIAL_ALPHATEST: number;
  30109. /**
  30110. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30111. */
  30112. static readonly MATERIAL_ALPHABLEND: number;
  30113. /**
  30114. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30115. * They are also discarded below the alpha cutoff threshold to improve performances.
  30116. */
  30117. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30118. /**
  30119. * The Whiteout method is used to blend normals.
  30120. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30121. */
  30122. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30123. /**
  30124. * The Reoriented Normal Mapping method is used to blend normals.
  30125. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30126. */
  30127. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30128. /**
  30129. * Custom callback helping to override the default shader used in the material.
  30130. */
  30131. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30132. /**
  30133. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30134. */
  30135. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30136. /**
  30137. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30138. * This means that the material can keep using a previous shader while a new one is being compiled.
  30139. * This is mostly used when shader parallel compilation is supported (true by default)
  30140. */
  30141. allowShaderHotSwapping: boolean;
  30142. /**
  30143. * The ID of the material
  30144. */
  30145. id: string;
  30146. /**
  30147. * Gets or sets the unique id of the material
  30148. */
  30149. uniqueId: number;
  30150. /**
  30151. * The name of the material
  30152. */
  30153. name: string;
  30154. /**
  30155. * Gets or sets user defined metadata
  30156. */
  30157. metadata: any;
  30158. /**
  30159. * For internal use only. Please do not use.
  30160. */
  30161. reservedDataStore: any;
  30162. /**
  30163. * Specifies if the ready state should be checked on each call
  30164. */
  30165. checkReadyOnEveryCall: boolean;
  30166. /**
  30167. * Specifies if the ready state should be checked once
  30168. */
  30169. checkReadyOnlyOnce: boolean;
  30170. /**
  30171. * The state of the material
  30172. */
  30173. state: string;
  30174. /**
  30175. * If the material can be rendered to several textures with MRT extension
  30176. */
  30177. get canRenderToMRT(): boolean;
  30178. /**
  30179. * The alpha value of the material
  30180. */
  30181. protected _alpha: number;
  30182. /**
  30183. * List of inspectable custom properties (used by the Inspector)
  30184. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30185. */
  30186. inspectableCustomProperties: IInspectable[];
  30187. /**
  30188. * Sets the alpha value of the material
  30189. */
  30190. set alpha(value: number);
  30191. /**
  30192. * Gets the alpha value of the material
  30193. */
  30194. get alpha(): number;
  30195. /**
  30196. * Specifies if back face culling is enabled
  30197. */
  30198. protected _backFaceCulling: boolean;
  30199. /**
  30200. * Sets the back-face culling state
  30201. */
  30202. set backFaceCulling(value: boolean);
  30203. /**
  30204. * Gets the back-face culling state
  30205. */
  30206. get backFaceCulling(): boolean;
  30207. /**
  30208. * Stores the value for side orientation
  30209. */
  30210. sideOrientation: number;
  30211. /**
  30212. * Callback triggered when the material is compiled
  30213. */
  30214. onCompiled: Nullable<(effect: Effect) => void>;
  30215. /**
  30216. * Callback triggered when an error occurs
  30217. */
  30218. onError: Nullable<(effect: Effect, errors: string) => void>;
  30219. /**
  30220. * Callback triggered to get the render target textures
  30221. */
  30222. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30223. /**
  30224. * Gets a boolean indicating that current material needs to register RTT
  30225. */
  30226. get hasRenderTargetTextures(): boolean;
  30227. /**
  30228. * Specifies if the material should be serialized
  30229. */
  30230. doNotSerialize: boolean;
  30231. /**
  30232. * @hidden
  30233. */
  30234. _storeEffectOnSubMeshes: boolean;
  30235. /**
  30236. * Stores the animations for the material
  30237. */
  30238. animations: Nullable<Array<Animation>>;
  30239. /**
  30240. * An event triggered when the material is disposed
  30241. */
  30242. onDisposeObservable: Observable<Material>;
  30243. /**
  30244. * An observer which watches for dispose events
  30245. */
  30246. private _onDisposeObserver;
  30247. private _onUnBindObservable;
  30248. /**
  30249. * Called during a dispose event
  30250. */
  30251. set onDispose(callback: () => void);
  30252. private _onBindObservable;
  30253. /**
  30254. * An event triggered when the material is bound
  30255. */
  30256. get onBindObservable(): Observable<AbstractMesh>;
  30257. /**
  30258. * An observer which watches for bind events
  30259. */
  30260. private _onBindObserver;
  30261. /**
  30262. * Called during a bind event
  30263. */
  30264. set onBind(callback: (Mesh: AbstractMesh) => void);
  30265. /**
  30266. * An event triggered when the material is unbound
  30267. */
  30268. get onUnBindObservable(): Observable<Material>;
  30269. protected _onEffectCreatedObservable: Nullable<Observable<{
  30270. effect: Effect;
  30271. subMesh: Nullable<SubMesh>;
  30272. }>>;
  30273. /**
  30274. * An event triggered when the effect is (re)created
  30275. */
  30276. get onEffectCreatedObservable(): Observable<{
  30277. effect: Effect;
  30278. subMesh: Nullable<SubMesh>;
  30279. }>;
  30280. /**
  30281. * Stores the value of the alpha mode
  30282. */
  30283. private _alphaMode;
  30284. /**
  30285. * Sets the value of the alpha mode.
  30286. *
  30287. * | Value | Type | Description |
  30288. * | --- | --- | --- |
  30289. * | 0 | ALPHA_DISABLE | |
  30290. * | 1 | ALPHA_ADD | |
  30291. * | 2 | ALPHA_COMBINE | |
  30292. * | 3 | ALPHA_SUBTRACT | |
  30293. * | 4 | ALPHA_MULTIPLY | |
  30294. * | 5 | ALPHA_MAXIMIZED | |
  30295. * | 6 | ALPHA_ONEONE | |
  30296. * | 7 | ALPHA_PREMULTIPLIED | |
  30297. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30298. * | 9 | ALPHA_INTERPOLATE | |
  30299. * | 10 | ALPHA_SCREENMODE | |
  30300. *
  30301. */
  30302. set alphaMode(value: number);
  30303. /**
  30304. * Gets the value of the alpha mode
  30305. */
  30306. get alphaMode(): number;
  30307. /**
  30308. * Stores the state of the need depth pre-pass value
  30309. */
  30310. private _needDepthPrePass;
  30311. /**
  30312. * Sets the need depth pre-pass value
  30313. */
  30314. set needDepthPrePass(value: boolean);
  30315. /**
  30316. * Gets the depth pre-pass value
  30317. */
  30318. get needDepthPrePass(): boolean;
  30319. /**
  30320. * Specifies if depth writing should be disabled
  30321. */
  30322. disableDepthWrite: boolean;
  30323. /**
  30324. * Specifies if color writing should be disabled
  30325. */
  30326. disableColorWrite: boolean;
  30327. /**
  30328. * Specifies if depth writing should be forced
  30329. */
  30330. forceDepthWrite: boolean;
  30331. /**
  30332. * Specifies the depth function that should be used. 0 means the default engine function
  30333. */
  30334. depthFunction: number;
  30335. /**
  30336. * Specifies if there should be a separate pass for culling
  30337. */
  30338. separateCullingPass: boolean;
  30339. /**
  30340. * Stores the state specifing if fog should be enabled
  30341. */
  30342. private _fogEnabled;
  30343. /**
  30344. * Sets the state for enabling fog
  30345. */
  30346. set fogEnabled(value: boolean);
  30347. /**
  30348. * Gets the value of the fog enabled state
  30349. */
  30350. get fogEnabled(): boolean;
  30351. /**
  30352. * Stores the size of points
  30353. */
  30354. pointSize: number;
  30355. /**
  30356. * Stores the z offset value
  30357. */
  30358. zOffset: number;
  30359. get wireframe(): boolean;
  30360. /**
  30361. * Sets the state of wireframe mode
  30362. */
  30363. set wireframe(value: boolean);
  30364. /**
  30365. * Gets the value specifying if point clouds are enabled
  30366. */
  30367. get pointsCloud(): boolean;
  30368. /**
  30369. * Sets the state of point cloud mode
  30370. */
  30371. set pointsCloud(value: boolean);
  30372. /**
  30373. * Gets the material fill mode
  30374. */
  30375. get fillMode(): number;
  30376. /**
  30377. * Sets the material fill mode
  30378. */
  30379. set fillMode(value: number);
  30380. /**
  30381. * @hidden
  30382. * Stores the effects for the material
  30383. */
  30384. _effect: Nullable<Effect>;
  30385. /**
  30386. * Specifies if uniform buffers should be used
  30387. */
  30388. private _useUBO;
  30389. /**
  30390. * Stores a reference to the scene
  30391. */
  30392. private _scene;
  30393. private _needToBindSceneUbo;
  30394. /**
  30395. * Stores the fill mode state
  30396. */
  30397. private _fillMode;
  30398. /**
  30399. * Specifies if the depth write state should be cached
  30400. */
  30401. private _cachedDepthWriteState;
  30402. /**
  30403. * Specifies if the color write state should be cached
  30404. */
  30405. private _cachedColorWriteState;
  30406. /**
  30407. * Specifies if the depth function state should be cached
  30408. */
  30409. private _cachedDepthFunctionState;
  30410. /**
  30411. * Stores the uniform buffer
  30412. */
  30413. protected _uniformBuffer: UniformBuffer;
  30414. /** @hidden */
  30415. _indexInSceneMaterialArray: number;
  30416. /** @hidden */
  30417. meshMap: Nullable<{
  30418. [id: string]: AbstractMesh | undefined;
  30419. }>;
  30420. /**
  30421. * Creates a material instance
  30422. * @param name defines the name of the material
  30423. * @param scene defines the scene to reference
  30424. * @param doNotAdd specifies if the material should be added to the scene
  30425. */
  30426. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30427. /**
  30428. * Returns a string representation of the current material
  30429. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30430. * @returns a string with material information
  30431. */
  30432. toString(fullDetails?: boolean): string;
  30433. /**
  30434. * Gets the class name of the material
  30435. * @returns a string with the class name of the material
  30436. */
  30437. getClassName(): string;
  30438. /**
  30439. * Specifies if updates for the material been locked
  30440. */
  30441. get isFrozen(): boolean;
  30442. /**
  30443. * Locks updates for the material
  30444. */
  30445. freeze(): void;
  30446. /**
  30447. * Unlocks updates for the material
  30448. */
  30449. unfreeze(): void;
  30450. /**
  30451. * Specifies if the material is ready to be used
  30452. * @param mesh defines the mesh to check
  30453. * @param useInstances specifies if instances should be used
  30454. * @returns a boolean indicating if the material is ready to be used
  30455. */
  30456. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30457. /**
  30458. * Specifies that the submesh is ready to be used
  30459. * @param mesh defines the mesh to check
  30460. * @param subMesh defines which submesh to check
  30461. * @param useInstances specifies that instances should be used
  30462. * @returns a boolean indicating that the submesh is ready or not
  30463. */
  30464. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30465. /**
  30466. * Returns the material effect
  30467. * @returns the effect associated with the material
  30468. */
  30469. getEffect(): Nullable<Effect>;
  30470. /**
  30471. * Returns the current scene
  30472. * @returns a Scene
  30473. */
  30474. getScene(): Scene;
  30475. /**
  30476. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30477. */
  30478. protected _forceAlphaTest: boolean;
  30479. /**
  30480. * The transparency mode of the material.
  30481. */
  30482. protected _transparencyMode: Nullable<number>;
  30483. /**
  30484. * Gets the current transparency mode.
  30485. */
  30486. get transparencyMode(): Nullable<number>;
  30487. /**
  30488. * Sets the transparency mode of the material.
  30489. *
  30490. * | Value | Type | Description |
  30491. * | ----- | ----------------------------------- | ----------- |
  30492. * | 0 | OPAQUE | |
  30493. * | 1 | ALPHATEST | |
  30494. * | 2 | ALPHABLEND | |
  30495. * | 3 | ALPHATESTANDBLEND | |
  30496. *
  30497. */
  30498. set transparencyMode(value: Nullable<number>);
  30499. /**
  30500. * Returns true if alpha blending should be disabled.
  30501. */
  30502. protected get _disableAlphaBlending(): boolean;
  30503. /**
  30504. * Specifies whether or not this material should be rendered in alpha blend mode.
  30505. * @returns a boolean specifying if alpha blending is needed
  30506. */
  30507. needAlphaBlending(): boolean;
  30508. /**
  30509. * Specifies if the mesh will require alpha blending
  30510. * @param mesh defines the mesh to check
  30511. * @returns a boolean specifying if alpha blending is needed for the mesh
  30512. */
  30513. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30514. /**
  30515. * Specifies whether or not this material should be rendered in alpha test mode.
  30516. * @returns a boolean specifying if an alpha test is needed.
  30517. */
  30518. needAlphaTesting(): boolean;
  30519. /**
  30520. * Specifies if material alpha testing should be turned on for the mesh
  30521. * @param mesh defines the mesh to check
  30522. */
  30523. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30524. /**
  30525. * Gets the texture used for the alpha test
  30526. * @returns the texture to use for alpha testing
  30527. */
  30528. getAlphaTestTexture(): Nullable<BaseTexture>;
  30529. /**
  30530. * Marks the material to indicate that it needs to be re-calculated
  30531. */
  30532. markDirty(): void;
  30533. /** @hidden */
  30534. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30535. /**
  30536. * Binds the material to the mesh
  30537. * @param world defines the world transformation matrix
  30538. * @param mesh defines the mesh to bind the material to
  30539. */
  30540. bind(world: Matrix, mesh?: Mesh): void;
  30541. /**
  30542. * Binds the submesh to the material
  30543. * @param world defines the world transformation matrix
  30544. * @param mesh defines the mesh containing the submesh
  30545. * @param subMesh defines the submesh to bind the material to
  30546. */
  30547. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30548. /**
  30549. * Binds the world matrix to the material
  30550. * @param world defines the world transformation matrix
  30551. */
  30552. bindOnlyWorldMatrix(world: Matrix): void;
  30553. /**
  30554. * Update the scene ubo before it can be used in rendering processing
  30555. * @param scene the scene to retrieve the ubo from
  30556. * @returns the scene UniformBuffer
  30557. */
  30558. finalizeSceneUbo(scene: Scene): UniformBuffer;
  30559. /**
  30560. * Binds the scene's uniform buffer to the effect.
  30561. * @param effect defines the effect to bind to the scene uniform buffer
  30562. * @param sceneUbo defines the uniform buffer storing scene data
  30563. */
  30564. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30565. /**
  30566. * Binds the view matrix to the effect
  30567. * @param effect defines the effect to bind the view matrix to
  30568. */
  30569. bindView(effect: Effect): void;
  30570. /**
  30571. * Binds the view projection and projection matrices to the effect
  30572. * @param effect defines the effect to bind the view projection and projection matrices to
  30573. */
  30574. bindViewProjection(effect: Effect): void;
  30575. /**
  30576. * Binds the view matrix to the effect
  30577. * @param effect defines the effect to bind the view matrix to
  30578. * @param variableName name of the shader variable that will hold the eye position
  30579. */
  30580. bindEyePosition(effect: Effect, variableName?: string): void;
  30581. /**
  30582. * Processes to execute after binding the material to a mesh
  30583. * @param mesh defines the rendered mesh
  30584. */
  30585. protected _afterBind(mesh?: Mesh, effect?: Nullable<Effect>): void;
  30586. /**
  30587. * Unbinds the material from the mesh
  30588. */
  30589. unbind(): void;
  30590. /**
  30591. * Gets the active textures from the material
  30592. * @returns an array of textures
  30593. */
  30594. getActiveTextures(): BaseTexture[];
  30595. /**
  30596. * Specifies if the material uses a texture
  30597. * @param texture defines the texture to check against the material
  30598. * @returns a boolean specifying if the material uses the texture
  30599. */
  30600. hasTexture(texture: BaseTexture): boolean;
  30601. /**
  30602. * Makes a duplicate of the material, and gives it a new name
  30603. * @param name defines the new name for the duplicated material
  30604. * @returns the cloned material
  30605. */
  30606. clone(name: string): Nullable<Material>;
  30607. /**
  30608. * Gets the meshes bound to the material
  30609. * @returns an array of meshes bound to the material
  30610. */
  30611. getBindedMeshes(): AbstractMesh[];
  30612. /**
  30613. * Force shader compilation
  30614. * @param mesh defines the mesh associated with this material
  30615. * @param onCompiled defines a function to execute once the material is compiled
  30616. * @param options defines the options to configure the compilation
  30617. * @param onError defines a function to execute if the material fails compiling
  30618. */
  30619. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30620. /**
  30621. * Force shader compilation
  30622. * @param mesh defines the mesh that will use this material
  30623. * @param options defines additional options for compiling the shaders
  30624. * @returns a promise that resolves when the compilation completes
  30625. */
  30626. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30627. private static readonly _AllDirtyCallBack;
  30628. private static readonly _ImageProcessingDirtyCallBack;
  30629. private static readonly _TextureDirtyCallBack;
  30630. private static readonly _FresnelDirtyCallBack;
  30631. private static readonly _MiscDirtyCallBack;
  30632. private static readonly _PrePassDirtyCallBack;
  30633. private static readonly _LightsDirtyCallBack;
  30634. private static readonly _AttributeDirtyCallBack;
  30635. private static _FresnelAndMiscDirtyCallBack;
  30636. private static _TextureAndMiscDirtyCallBack;
  30637. private static readonly _DirtyCallbackArray;
  30638. private static readonly _RunDirtyCallBacks;
  30639. /**
  30640. * Marks a define in the material to indicate that it needs to be re-computed
  30641. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30642. */
  30643. markAsDirty(flag: number): void;
  30644. /**
  30645. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30646. * @param func defines a function which checks material defines against the submeshes
  30647. */
  30648. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30649. /**
  30650. * Indicates that the scene should check if the rendering now needs a prepass
  30651. */
  30652. protected _markScenePrePassDirty(): void;
  30653. /**
  30654. * Indicates that we need to re-calculated for all submeshes
  30655. */
  30656. protected _markAllSubMeshesAsAllDirty(): void;
  30657. /**
  30658. * Indicates that image processing needs to be re-calculated for all submeshes
  30659. */
  30660. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30661. /**
  30662. * Indicates that textures need to be re-calculated for all submeshes
  30663. */
  30664. protected _markAllSubMeshesAsTexturesDirty(): void;
  30665. /**
  30666. * Indicates that fresnel needs to be re-calculated for all submeshes
  30667. */
  30668. protected _markAllSubMeshesAsFresnelDirty(): void;
  30669. /**
  30670. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30671. */
  30672. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30673. /**
  30674. * Indicates that lights need to be re-calculated for all submeshes
  30675. */
  30676. protected _markAllSubMeshesAsLightsDirty(): void;
  30677. /**
  30678. * Indicates that attributes need to be re-calculated for all submeshes
  30679. */
  30680. protected _markAllSubMeshesAsAttributesDirty(): void;
  30681. /**
  30682. * Indicates that misc needs to be re-calculated for all submeshes
  30683. */
  30684. protected _markAllSubMeshesAsMiscDirty(): void;
  30685. /**
  30686. * Indicates that prepass needs to be re-calculated for all submeshes
  30687. */
  30688. protected _markAllSubMeshesAsPrePassDirty(): void;
  30689. /**
  30690. * Indicates that textures and misc need to be re-calculated for all submeshes
  30691. */
  30692. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30693. /**
  30694. * Sets the required values to the prepass renderer.
  30695. * @param prePassRenderer defines the prepass renderer to setup.
  30696. * @returns true if the pre pass is needed.
  30697. */
  30698. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30699. /**
  30700. * Disposes the material
  30701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30704. */
  30705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30706. /** @hidden */
  30707. private releaseVertexArrayObject;
  30708. /**
  30709. * Serializes this material
  30710. * @returns the serialized material object
  30711. */
  30712. serialize(): any;
  30713. /**
  30714. * Creates a material from parsed material data
  30715. * @param parsedMaterial defines parsed material data
  30716. * @param scene defines the hosting scene
  30717. * @param rootUrl defines the root URL to use to load textures
  30718. * @returns a new material
  30719. */
  30720. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30721. }
  30722. }
  30723. declare module BABYLON {
  30724. /**
  30725. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30726. * separate meshes. This can be use to improve performances.
  30727. * @see https://doc.babylonjs.com/how_to/multi_materials
  30728. */
  30729. export class MultiMaterial extends Material {
  30730. private _subMaterials;
  30731. /**
  30732. * Gets or Sets the list of Materials used within the multi material.
  30733. * They need to be ordered according to the submeshes order in the associated mesh
  30734. */
  30735. get subMaterials(): Nullable<Material>[];
  30736. set subMaterials(value: Nullable<Material>[]);
  30737. /**
  30738. * Function used to align with Node.getChildren()
  30739. * @returns the list of Materials used within the multi material
  30740. */
  30741. getChildren(): Nullable<Material>[];
  30742. /**
  30743. * Instantiates a new Multi Material
  30744. * A multi-material is used to apply different materials to different parts of the same object without the need of
  30745. * separate meshes. This can be use to improve performances.
  30746. * @see https://doc.babylonjs.com/how_to/multi_materials
  30747. * @param name Define the name in the scene
  30748. * @param scene Define the scene the material belongs to
  30749. */
  30750. constructor(name: string, scene: Scene);
  30751. private _hookArray;
  30752. /**
  30753. * Get one of the submaterial by its index in the submaterials array
  30754. * @param index The index to look the sub material at
  30755. * @returns The Material if the index has been defined
  30756. */
  30757. getSubMaterial(index: number): Nullable<Material>;
  30758. /**
  30759. * Get the list of active textures for the whole sub materials list.
  30760. * @returns All the textures that will be used during the rendering
  30761. */
  30762. getActiveTextures(): BaseTexture[];
  30763. /**
  30764. * Specifies if any sub-materials of this multi-material use a given texture.
  30765. * @param texture Defines the texture to check against this multi-material's sub-materials.
  30766. * @returns A boolean specifying if any sub-material of this multi-material uses the texture.
  30767. */
  30768. hasTexture(texture: BaseTexture): boolean;
  30769. /**
  30770. * Gets the current class name of the material e.g. "MultiMaterial"
  30771. * Mainly use in serialization.
  30772. * @returns the class name
  30773. */
  30774. getClassName(): string;
  30775. /**
  30776. * Checks if the material is ready to render the requested sub mesh
  30777. * @param mesh Define the mesh the submesh belongs to
  30778. * @param subMesh Define the sub mesh to look readyness for
  30779. * @param useInstances Define whether or not the material is used with instances
  30780. * @returns true if ready, otherwise false
  30781. */
  30782. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30783. /**
  30784. * Clones the current material and its related sub materials
  30785. * @param name Define the name of the newly cloned material
  30786. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  30787. * @returns the cloned material
  30788. */
  30789. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  30790. /**
  30791. * Serializes the materials into a JSON representation.
  30792. * @returns the JSON representation
  30793. */
  30794. serialize(): any;
  30795. /**
  30796. * Dispose the material and release its associated resources
  30797. * @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)
  30798. * @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)
  30799. * @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)
  30800. */
  30801. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  30802. /**
  30803. * Creates a MultiMaterial from parsed MultiMaterial data.
  30804. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  30805. * @param scene defines the hosting scene
  30806. * @returns a new MultiMaterial
  30807. */
  30808. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  30809. }
  30810. }
  30811. declare module BABYLON {
  30812. /** @hidden */
  30813. export interface ICustomEffect {
  30814. effect: Effect;
  30815. defines: string;
  30816. }
  30817. /**
  30818. * Defines a subdivision inside a mesh
  30819. */
  30820. export class SubMesh implements ICullable {
  30821. /** the material index to use */
  30822. materialIndex: number;
  30823. /** vertex index start */
  30824. verticesStart: number;
  30825. /** vertices count */
  30826. verticesCount: number;
  30827. /** index start */
  30828. indexStart: number;
  30829. /** indices count */
  30830. indexCount: number;
  30831. /** @hidden */
  30832. _materialDefines: Nullable<MaterialDefines>;
  30833. /** @hidden */
  30834. _materialEffect: Nullable<Effect>;
  30835. /** @hidden */
  30836. _effectOverride: Nullable<Effect>;
  30837. private _customEffects;
  30838. /**
  30839. * Gets material defines used by the effect associated to the sub mesh
  30840. */
  30841. get materialDefines(): Nullable<MaterialDefines>;
  30842. /**
  30843. * Sets material defines used by the effect associated to the sub mesh
  30844. */
  30845. set materialDefines(defines: Nullable<MaterialDefines>);
  30846. /** @hidden */
  30847. _getCustomEffect(name: string, createIfNotExisting?: boolean): Nullable<ICustomEffect>;
  30848. /** @hidden */
  30849. _removeCustomEffect(name: string): void;
  30850. /**
  30851. * Gets associated effect
  30852. */
  30853. get effect(): Nullable<Effect>;
  30854. /**
  30855. * Sets associated effect (effect used to render this submesh)
  30856. * @param effect defines the effect to associate with
  30857. * @param defines defines the set of defines used to compile this effect
  30858. */
  30859. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  30860. /** @hidden */
  30861. _linesIndexCount: number;
  30862. private _mesh;
  30863. private _renderingMesh;
  30864. private _boundingInfo;
  30865. private _linesIndexBuffer;
  30866. /** @hidden */
  30867. _lastColliderWorldVertices: Nullable<Vector3[]>;
  30868. /** @hidden */
  30869. _trianglePlanes: Plane[];
  30870. /** @hidden */
  30871. _lastColliderTransformMatrix: Nullable<Matrix>;
  30872. /** @hidden */
  30873. _renderId: number;
  30874. /** @hidden */
  30875. _alphaIndex: number;
  30876. /** @hidden */
  30877. _distanceToCamera: number;
  30878. /** @hidden */
  30879. _id: number;
  30880. private _currentMaterial;
  30881. /**
  30882. * Add a new submesh to a mesh
  30883. * @param materialIndex defines the material index to use
  30884. * @param verticesStart defines vertex index start
  30885. * @param verticesCount defines vertices count
  30886. * @param indexStart defines index start
  30887. * @param indexCount defines indices count
  30888. * @param mesh defines the parent mesh
  30889. * @param renderingMesh defines an optional rendering mesh
  30890. * @param createBoundingBox defines if bounding box should be created for this submesh
  30891. * @returns the new submesh
  30892. */
  30893. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  30894. /**
  30895. * Creates a new submesh
  30896. * @param materialIndex defines the material index to use
  30897. * @param verticesStart defines vertex index start
  30898. * @param verticesCount defines vertices count
  30899. * @param indexStart defines index start
  30900. * @param indexCount defines indices count
  30901. * @param mesh defines the parent mesh
  30902. * @param renderingMesh defines an optional rendering mesh
  30903. * @param createBoundingBox defines if bounding box should be created for this submesh
  30904. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  30905. */
  30906. constructor(
  30907. /** the material index to use */
  30908. materialIndex: number,
  30909. /** vertex index start */
  30910. verticesStart: number,
  30911. /** vertices count */
  30912. verticesCount: number,
  30913. /** index start */
  30914. indexStart: number,
  30915. /** indices count */
  30916. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  30917. /**
  30918. * Returns true if this submesh covers the entire parent mesh
  30919. * @ignorenaming
  30920. */
  30921. get IsGlobal(): boolean;
  30922. /**
  30923. * Returns the submesh BoudingInfo object
  30924. * @returns current bounding info (or mesh's one if the submesh is global)
  30925. */
  30926. getBoundingInfo(): BoundingInfo;
  30927. /**
  30928. * Sets the submesh BoundingInfo
  30929. * @param boundingInfo defines the new bounding info to use
  30930. * @returns the SubMesh
  30931. */
  30932. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  30933. /**
  30934. * Returns the mesh of the current submesh
  30935. * @return the parent mesh
  30936. */
  30937. getMesh(): AbstractMesh;
  30938. /**
  30939. * Returns the rendering mesh of the submesh
  30940. * @returns the rendering mesh (could be different from parent mesh)
  30941. */
  30942. getRenderingMesh(): Mesh;
  30943. /**
  30944. * Returns the replacement mesh of the submesh
  30945. * @returns the replacement mesh (could be different from parent mesh)
  30946. */
  30947. getReplacementMesh(): Nullable<AbstractMesh>;
  30948. /**
  30949. * Returns the effective mesh of the submesh
  30950. * @returns the effective mesh (could be different from parent mesh)
  30951. */
  30952. getEffectiveMesh(): AbstractMesh;
  30953. /**
  30954. * Returns the submesh material
  30955. * @returns null or the current material
  30956. */
  30957. getMaterial(): Nullable<Material>;
  30958. private _IsMultiMaterial;
  30959. /**
  30960. * Sets a new updated BoundingInfo object to the submesh
  30961. * @param data defines an optional position array to use to determine the bounding info
  30962. * @returns the SubMesh
  30963. */
  30964. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  30965. /** @hidden */
  30966. _checkCollision(collider: Collider): boolean;
  30967. /**
  30968. * Updates the submesh BoundingInfo
  30969. * @param world defines the world matrix to use to update the bounding info
  30970. * @returns the submesh
  30971. */
  30972. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  30973. /**
  30974. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  30975. * @param frustumPlanes defines the frustum planes
  30976. * @returns true if the submesh is intersecting with the frustum
  30977. */
  30978. isInFrustum(frustumPlanes: Plane[]): boolean;
  30979. /**
  30980. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  30981. * @param frustumPlanes defines the frustum planes
  30982. * @returns true if the submesh is inside the frustum
  30983. */
  30984. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  30985. /**
  30986. * Renders the submesh
  30987. * @param enableAlphaMode defines if alpha needs to be used
  30988. * @returns the submesh
  30989. */
  30990. render(enableAlphaMode: boolean): SubMesh;
  30991. /**
  30992. * @hidden
  30993. */
  30994. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  30995. /**
  30996. * Checks if the submesh intersects with a ray
  30997. * @param ray defines the ray to test
  30998. * @returns true is the passed ray intersects the submesh bounding box
  30999. */
  31000. canIntersects(ray: Ray): boolean;
  31001. /**
  31002. * Intersects current submesh with a ray
  31003. * @param ray defines the ray to test
  31004. * @param positions defines mesh's positions array
  31005. * @param indices defines mesh's indices array
  31006. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31007. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31008. * @returns intersection info or null if no intersection
  31009. */
  31010. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31011. /** @hidden */
  31012. private _intersectLines;
  31013. /** @hidden */
  31014. private _intersectUnIndexedLines;
  31015. /** @hidden */
  31016. private _intersectTriangles;
  31017. /** @hidden */
  31018. private _intersectUnIndexedTriangles;
  31019. /** @hidden */
  31020. _rebuild(): void;
  31021. /**
  31022. * Creates a new submesh from the passed mesh
  31023. * @param newMesh defines the new hosting mesh
  31024. * @param newRenderingMesh defines an optional rendering mesh
  31025. * @returns the new submesh
  31026. */
  31027. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31028. /**
  31029. * Release associated resources
  31030. */
  31031. dispose(): void;
  31032. /**
  31033. * Gets the class name
  31034. * @returns the string "SubMesh".
  31035. */
  31036. getClassName(): string;
  31037. /**
  31038. * Creates a new submesh from indices data
  31039. * @param materialIndex the index of the main mesh material
  31040. * @param startIndex the index where to start the copy in the mesh indices array
  31041. * @param indexCount the number of indices to copy then from the startIndex
  31042. * @param mesh the main mesh to create the submesh from
  31043. * @param renderingMesh the optional rendering mesh
  31044. * @returns a new submesh
  31045. */
  31046. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31047. }
  31048. }
  31049. declare module BABYLON {
  31050. /**
  31051. * Class used to represent data loading progression
  31052. */
  31053. export class SceneLoaderFlags {
  31054. private static _ForceFullSceneLoadingForIncremental;
  31055. private static _ShowLoadingScreen;
  31056. private static _CleanBoneMatrixWeights;
  31057. private static _loggingLevel;
  31058. /**
  31059. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31060. */
  31061. static get ForceFullSceneLoadingForIncremental(): boolean;
  31062. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31063. /**
  31064. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31065. */
  31066. static get ShowLoadingScreen(): boolean;
  31067. static set ShowLoadingScreen(value: boolean);
  31068. /**
  31069. * Defines the current logging level (while loading the scene)
  31070. * @ignorenaming
  31071. */
  31072. static get loggingLevel(): number;
  31073. static set loggingLevel(value: number);
  31074. /**
  31075. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31076. */
  31077. static get CleanBoneMatrixWeights(): boolean;
  31078. static set CleanBoneMatrixWeights(value: boolean);
  31079. }
  31080. }
  31081. declare module BABYLON {
  31082. /**
  31083. * Class used to store geometry data (vertex buffers + index buffer)
  31084. */
  31085. export class Geometry implements IGetSetVerticesData {
  31086. /**
  31087. * Gets or sets the ID of the geometry
  31088. */
  31089. id: string;
  31090. /**
  31091. * Gets or sets the unique ID of the geometry
  31092. */
  31093. uniqueId: number;
  31094. /**
  31095. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31096. */
  31097. delayLoadState: number;
  31098. /**
  31099. * Gets the file containing the data to load when running in delay load state
  31100. */
  31101. delayLoadingFile: Nullable<string>;
  31102. /**
  31103. * Callback called when the geometry is updated
  31104. */
  31105. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31106. private _scene;
  31107. private _engine;
  31108. private _meshes;
  31109. private _totalVertices;
  31110. /** @hidden */
  31111. _indices: IndicesArray;
  31112. /** @hidden */
  31113. _vertexBuffers: {
  31114. [key: string]: VertexBuffer;
  31115. };
  31116. private _isDisposed;
  31117. private _extend;
  31118. private _boundingBias;
  31119. /** @hidden */
  31120. _delayInfo: Array<string>;
  31121. private _indexBuffer;
  31122. private _indexBufferIsUpdatable;
  31123. /** @hidden */
  31124. _boundingInfo: Nullable<BoundingInfo>;
  31125. /** @hidden */
  31126. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31127. /** @hidden */
  31128. _softwareSkinningFrameId: number;
  31129. private _vertexArrayObjects;
  31130. private _updatable;
  31131. /** @hidden */
  31132. _positions: Nullable<Vector3[]>;
  31133. private _positionsCache;
  31134. /**
  31135. * 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
  31136. */
  31137. get boundingBias(): Vector2;
  31138. /**
  31139. * 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
  31140. */
  31141. set boundingBias(value: Vector2);
  31142. /**
  31143. * Static function used to attach a new empty geometry to a mesh
  31144. * @param mesh defines the mesh to attach the geometry to
  31145. * @returns the new Geometry
  31146. */
  31147. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31148. /** Get the list of meshes using this geometry */
  31149. get meshes(): Mesh[];
  31150. /**
  31151. * If set to true (false by defaut), the bounding info applied to the meshes sharing this geometry will be the bounding info defined at the class level
  31152. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31153. */
  31154. useBoundingInfoFromGeometry: boolean;
  31155. /**
  31156. * Creates a new geometry
  31157. * @param id defines the unique ID
  31158. * @param scene defines the hosting scene
  31159. * @param vertexData defines the VertexData used to get geometry data
  31160. * @param updatable defines if geometry must be updatable (false by default)
  31161. * @param mesh defines the mesh that will be associated with the geometry
  31162. */
  31163. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31164. /**
  31165. * Gets the current extend of the geometry
  31166. */
  31167. get extend(): {
  31168. minimum: Vector3;
  31169. maximum: Vector3;
  31170. };
  31171. /**
  31172. * Gets the hosting scene
  31173. * @returns the hosting Scene
  31174. */
  31175. getScene(): Scene;
  31176. /**
  31177. * Gets the hosting engine
  31178. * @returns the hosting Engine
  31179. */
  31180. getEngine(): Engine;
  31181. /**
  31182. * Defines if the geometry is ready to use
  31183. * @returns true if the geometry is ready to be used
  31184. */
  31185. isReady(): boolean;
  31186. /**
  31187. * Gets a value indicating that the geometry should not be serialized
  31188. */
  31189. get doNotSerialize(): boolean;
  31190. /** @hidden */
  31191. _rebuild(): void;
  31192. /**
  31193. * Affects all geometry data in one call
  31194. * @param vertexData defines the geometry data
  31195. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31196. */
  31197. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31198. /**
  31199. * Set specific vertex data
  31200. * @param kind defines the data kind (Position, normal, etc...)
  31201. * @param data defines the vertex data to use
  31202. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31203. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31204. */
  31205. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31206. /**
  31207. * Removes a specific vertex data
  31208. * @param kind defines the data kind (Position, normal, etc...)
  31209. */
  31210. removeVerticesData(kind: string): void;
  31211. /**
  31212. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31213. * @param buffer defines the vertex buffer to use
  31214. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31215. */
  31216. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31217. /**
  31218. * Update a specific vertex buffer
  31219. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31220. * It will do nothing if the buffer is not updatable
  31221. * @param kind defines the data kind (Position, normal, etc...)
  31222. * @param data defines the data to use
  31223. * @param offset defines the offset in the target buffer where to store the data
  31224. * @param useBytes set to true if the offset is in bytes
  31225. */
  31226. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31227. /**
  31228. * Update a specific vertex buffer
  31229. * This function will create a new buffer if the current one is not updatable
  31230. * @param kind defines the data kind (Position, normal, etc...)
  31231. * @param data defines the data to use
  31232. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31233. */
  31234. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31235. private _updateBoundingInfo;
  31236. /** @hidden */
  31237. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31238. /**
  31239. * Gets total number of vertices
  31240. * @returns the total number of vertices
  31241. */
  31242. getTotalVertices(): number;
  31243. /**
  31244. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31245. * @param kind defines the data kind (Position, normal, etc...)
  31246. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31247. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31248. * @returns a float array containing vertex data
  31249. */
  31250. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31251. /**
  31252. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31253. * @param kind defines the data kind (Position, normal, etc...)
  31254. * @returns true if the vertex buffer with the specified kind is updatable
  31255. */
  31256. isVertexBufferUpdatable(kind: string): boolean;
  31257. /**
  31258. * Gets a specific vertex buffer
  31259. * @param kind defines the data kind (Position, normal, etc...)
  31260. * @returns a VertexBuffer
  31261. */
  31262. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31263. /**
  31264. * Returns all vertex buffers
  31265. * @return an object holding all vertex buffers indexed by kind
  31266. */
  31267. getVertexBuffers(): Nullable<{
  31268. [key: string]: VertexBuffer;
  31269. }>;
  31270. /**
  31271. * Gets a boolean indicating if specific vertex buffer is present
  31272. * @param kind defines the data kind (Position, normal, etc...)
  31273. * @returns true if data is present
  31274. */
  31275. isVerticesDataPresent(kind: string): boolean;
  31276. /**
  31277. * Gets a list of all attached data kinds (Position, normal, etc...)
  31278. * @returns a list of string containing all kinds
  31279. */
  31280. getVerticesDataKinds(): string[];
  31281. /**
  31282. * Update index buffer
  31283. * @param indices defines the indices to store in the index buffer
  31284. * @param offset defines the offset in the target buffer where to store the data
  31285. * @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)
  31286. */
  31287. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31288. /**
  31289. * Creates a new index buffer
  31290. * @param indices defines the indices to store in the index buffer
  31291. * @param totalVertices defines the total number of vertices (could be null)
  31292. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31293. */
  31294. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31295. /**
  31296. * Return the total number of indices
  31297. * @returns the total number of indices
  31298. */
  31299. getTotalIndices(): number;
  31300. /**
  31301. * Gets the index buffer array
  31302. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31303. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31304. * @returns the index buffer array
  31305. */
  31306. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31307. /**
  31308. * Gets the index buffer
  31309. * @return the index buffer
  31310. */
  31311. getIndexBuffer(): Nullable<DataBuffer>;
  31312. /** @hidden */
  31313. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31314. /**
  31315. * Release the associated resources for a specific mesh
  31316. * @param mesh defines the source mesh
  31317. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31318. */
  31319. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31320. /**
  31321. * Apply current geometry to a given mesh
  31322. * @param mesh defines the mesh to apply geometry to
  31323. */
  31324. applyToMesh(mesh: Mesh): void;
  31325. private _updateExtend;
  31326. private _applyToMesh;
  31327. private notifyUpdate;
  31328. /**
  31329. * Load the geometry if it was flagged as delay loaded
  31330. * @param scene defines the hosting scene
  31331. * @param onLoaded defines a callback called when the geometry is loaded
  31332. */
  31333. load(scene: Scene, onLoaded?: () => void): void;
  31334. private _queueLoad;
  31335. /**
  31336. * Invert the geometry to move from a right handed system to a left handed one.
  31337. */
  31338. toLeftHanded(): void;
  31339. /** @hidden */
  31340. _resetPointsArrayCache(): void;
  31341. /** @hidden */
  31342. _generatePointsArray(): boolean;
  31343. /**
  31344. * Gets a value indicating if the geometry is disposed
  31345. * @returns true if the geometry was disposed
  31346. */
  31347. isDisposed(): boolean;
  31348. private _disposeVertexArrayObjects;
  31349. /**
  31350. * Free all associated resources
  31351. */
  31352. dispose(): void;
  31353. /**
  31354. * Clone the current geometry into a new geometry
  31355. * @param id defines the unique ID of the new geometry
  31356. * @returns a new geometry object
  31357. */
  31358. copy(id: string): Geometry;
  31359. /**
  31360. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31361. * @return a JSON representation of the current geometry data (without the vertices data)
  31362. */
  31363. serialize(): any;
  31364. private toNumberArray;
  31365. /**
  31366. * Serialize all vertices data into a JSON oject
  31367. * @returns a JSON representation of the current geometry data
  31368. */
  31369. serializeVerticeData(): any;
  31370. /**
  31371. * Extracts a clone of a mesh geometry
  31372. * @param mesh defines the source mesh
  31373. * @param id defines the unique ID of the new geometry object
  31374. * @returns the new geometry object
  31375. */
  31376. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31377. /**
  31378. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31379. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31380. * Be aware Math.random() could cause collisions, but:
  31381. * "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"
  31382. * @returns a string containing a new GUID
  31383. */
  31384. static RandomId(): string;
  31385. /** @hidden */
  31386. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31387. private static _CleanMatricesWeights;
  31388. /**
  31389. * Create a new geometry from persisted data (Using .babylon file format)
  31390. * @param parsedVertexData defines the persisted data
  31391. * @param scene defines the hosting scene
  31392. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31393. * @returns the new geometry object
  31394. */
  31395. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31396. }
  31397. }
  31398. declare module BABYLON {
  31399. /**
  31400. * Defines a target to use with MorphTargetManager
  31401. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31402. */
  31403. export class MorphTarget implements IAnimatable {
  31404. /** defines the name of the target */
  31405. name: string;
  31406. /**
  31407. * Gets or sets the list of animations
  31408. */
  31409. animations: Animation[];
  31410. private _scene;
  31411. private _positions;
  31412. private _normals;
  31413. private _tangents;
  31414. private _uvs;
  31415. private _influence;
  31416. private _uniqueId;
  31417. /**
  31418. * Observable raised when the influence changes
  31419. */
  31420. onInfluenceChanged: Observable<boolean>;
  31421. /** @hidden */
  31422. _onDataLayoutChanged: Observable<void>;
  31423. /**
  31424. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  31425. */
  31426. get influence(): number;
  31427. set influence(influence: number);
  31428. /**
  31429. * Gets or sets the id of the morph Target
  31430. */
  31431. id: string;
  31432. private _animationPropertiesOverride;
  31433. /**
  31434. * Gets or sets the animation properties override
  31435. */
  31436. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  31437. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  31438. /**
  31439. * Creates a new MorphTarget
  31440. * @param name defines the name of the target
  31441. * @param influence defines the influence to use
  31442. * @param scene defines the scene the morphtarget belongs to
  31443. */
  31444. constructor(
  31445. /** defines the name of the target */
  31446. name: string, influence?: number, scene?: Nullable<Scene>);
  31447. /**
  31448. * Gets the unique ID of this manager
  31449. */
  31450. get uniqueId(): number;
  31451. /**
  31452. * Gets a boolean defining if the target contains position data
  31453. */
  31454. get hasPositions(): boolean;
  31455. /**
  31456. * Gets a boolean defining if the target contains normal data
  31457. */
  31458. get hasNormals(): boolean;
  31459. /**
  31460. * Gets a boolean defining if the target contains tangent data
  31461. */
  31462. get hasTangents(): boolean;
  31463. /**
  31464. * Gets a boolean defining if the target contains texture coordinates data
  31465. */
  31466. get hasUVs(): boolean;
  31467. /**
  31468. * Affects position data to this target
  31469. * @param data defines the position data to use
  31470. */
  31471. setPositions(data: Nullable<FloatArray>): void;
  31472. /**
  31473. * Gets the position data stored in this target
  31474. * @returns a FloatArray containing the position data (or null if not present)
  31475. */
  31476. getPositions(): Nullable<FloatArray>;
  31477. /**
  31478. * Affects normal data to this target
  31479. * @param data defines the normal data to use
  31480. */
  31481. setNormals(data: Nullable<FloatArray>): void;
  31482. /**
  31483. * Gets the normal data stored in this target
  31484. * @returns a FloatArray containing the normal data (or null if not present)
  31485. */
  31486. getNormals(): Nullable<FloatArray>;
  31487. /**
  31488. * Affects tangent data to this target
  31489. * @param data defines the tangent data to use
  31490. */
  31491. setTangents(data: Nullable<FloatArray>): void;
  31492. /**
  31493. * Gets the tangent data stored in this target
  31494. * @returns a FloatArray containing the tangent data (or null if not present)
  31495. */
  31496. getTangents(): Nullable<FloatArray>;
  31497. /**
  31498. * Affects texture coordinates data to this target
  31499. * @param data defines the texture coordinates data to use
  31500. */
  31501. setUVs(data: Nullable<FloatArray>): void;
  31502. /**
  31503. * Gets the texture coordinates data stored in this target
  31504. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  31505. */
  31506. getUVs(): Nullable<FloatArray>;
  31507. /**
  31508. * Clone the current target
  31509. * @returns a new MorphTarget
  31510. */
  31511. clone(): MorphTarget;
  31512. /**
  31513. * Serializes the current target into a Serialization object
  31514. * @returns the serialized object
  31515. */
  31516. serialize(): any;
  31517. /**
  31518. * Returns the string "MorphTarget"
  31519. * @returns "MorphTarget"
  31520. */
  31521. getClassName(): string;
  31522. /**
  31523. * Creates a new target from serialized data
  31524. * @param serializationObject defines the serialized data to use
  31525. * @returns a new MorphTarget
  31526. */
  31527. static Parse(serializationObject: any): MorphTarget;
  31528. /**
  31529. * Creates a MorphTarget from mesh data
  31530. * @param mesh defines the source mesh
  31531. * @param name defines the name to use for the new target
  31532. * @param influence defines the influence to attach to the target
  31533. * @returns a new MorphTarget
  31534. */
  31535. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  31536. }
  31537. }
  31538. declare module BABYLON {
  31539. /**
  31540. * This class is used to deform meshes using morphing between different targets
  31541. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  31542. */
  31543. export class MorphTargetManager {
  31544. private _targets;
  31545. private _targetInfluenceChangedObservers;
  31546. private _targetDataLayoutChangedObservers;
  31547. private _activeTargets;
  31548. private _scene;
  31549. private _influences;
  31550. private _supportsNormals;
  31551. private _supportsTangents;
  31552. private _supportsUVs;
  31553. private _vertexCount;
  31554. private _uniqueId;
  31555. private _tempInfluences;
  31556. /**
  31557. * Gets or sets a boolean indicating if normals must be morphed
  31558. */
  31559. enableNormalMorphing: boolean;
  31560. /**
  31561. * Gets or sets a boolean indicating if tangents must be morphed
  31562. */
  31563. enableTangentMorphing: boolean;
  31564. /**
  31565. * Gets or sets a boolean indicating if UV must be morphed
  31566. */
  31567. enableUVMorphing: boolean;
  31568. /**
  31569. * Creates a new MorphTargetManager
  31570. * @param scene defines the current scene
  31571. */
  31572. constructor(scene?: Nullable<Scene>);
  31573. /**
  31574. * Gets the unique ID of this manager
  31575. */
  31576. get uniqueId(): number;
  31577. /**
  31578. * Gets the number of vertices handled by this manager
  31579. */
  31580. get vertexCount(): number;
  31581. /**
  31582. * Gets a boolean indicating if this manager supports morphing of normals
  31583. */
  31584. get supportsNormals(): boolean;
  31585. /**
  31586. * Gets a boolean indicating if this manager supports morphing of tangents
  31587. */
  31588. get supportsTangents(): boolean;
  31589. /**
  31590. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  31591. */
  31592. get supportsUVs(): boolean;
  31593. /**
  31594. * Gets the number of targets stored in this manager
  31595. */
  31596. get numTargets(): number;
  31597. /**
  31598. * Gets the number of influencers (ie. the number of targets with influences > 0)
  31599. */
  31600. get numInfluencers(): number;
  31601. /**
  31602. * Gets the list of influences (one per target)
  31603. */
  31604. get influences(): Float32Array;
  31605. /**
  31606. * Gets the active target at specified index. An active target is a target with an influence > 0
  31607. * @param index defines the index to check
  31608. * @returns the requested target
  31609. */
  31610. getActiveTarget(index: number): MorphTarget;
  31611. /**
  31612. * Gets the target at specified index
  31613. * @param index defines the index to check
  31614. * @returns the requested target
  31615. */
  31616. getTarget(index: number): MorphTarget;
  31617. /**
  31618. * Add a new target to this manager
  31619. * @param target defines the target to add
  31620. */
  31621. addTarget(target: MorphTarget): void;
  31622. /**
  31623. * Removes a target from the manager
  31624. * @param target defines the target to remove
  31625. */
  31626. removeTarget(target: MorphTarget): void;
  31627. /**
  31628. * Clone the current manager
  31629. * @returns a new MorphTargetManager
  31630. */
  31631. clone(): MorphTargetManager;
  31632. /**
  31633. * Serializes the current manager into a Serialization object
  31634. * @returns the serialized object
  31635. */
  31636. serialize(): any;
  31637. private _syncActiveTargets;
  31638. /**
  31639. * Syncrhonize the targets with all the meshes using this morph target manager
  31640. */
  31641. synchronize(): void;
  31642. /**
  31643. * Creates a new MorphTargetManager from serialized data
  31644. * @param serializationObject defines the serialized data
  31645. * @param scene defines the hosting scene
  31646. * @returns the new MorphTargetManager
  31647. */
  31648. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31649. }
  31650. }
  31651. declare module BABYLON {
  31652. /**
  31653. * Class used to represent a specific level of detail of a mesh
  31654. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31655. */
  31656. export class MeshLODLevel {
  31657. /** Defines the distance where this level should start being displayed */
  31658. distance: number;
  31659. /** Defines the mesh to use to render this level */
  31660. mesh: Nullable<Mesh>;
  31661. /**
  31662. * Creates a new LOD level
  31663. * @param distance defines the distance where this level should star being displayed
  31664. * @param mesh defines the mesh to use to render this level
  31665. */
  31666. constructor(
  31667. /** Defines the distance where this level should start being displayed */
  31668. distance: number,
  31669. /** Defines the mesh to use to render this level */
  31670. mesh: Nullable<Mesh>);
  31671. }
  31672. }
  31673. declare module BABYLON {
  31674. /**
  31675. * Helper class used to generate a canvas to manipulate images
  31676. */
  31677. export class CanvasGenerator {
  31678. /**
  31679. * Create a new canvas (or offscreen canvas depending on the context)
  31680. * @param width defines the expected width
  31681. * @param height defines the expected height
  31682. * @return a new canvas or offscreen canvas
  31683. */
  31684. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31685. }
  31686. }
  31687. declare module BABYLON {
  31688. /**
  31689. * Mesh representing the gorund
  31690. */
  31691. export class GroundMesh extends Mesh {
  31692. /** If octree should be generated */
  31693. generateOctree: boolean;
  31694. private _heightQuads;
  31695. /** @hidden */
  31696. _subdivisionsX: number;
  31697. /** @hidden */
  31698. _subdivisionsY: number;
  31699. /** @hidden */
  31700. _width: number;
  31701. /** @hidden */
  31702. _height: number;
  31703. /** @hidden */
  31704. _minX: number;
  31705. /** @hidden */
  31706. _maxX: number;
  31707. /** @hidden */
  31708. _minZ: number;
  31709. /** @hidden */
  31710. _maxZ: number;
  31711. constructor(name: string, scene: Scene);
  31712. /**
  31713. * "GroundMesh"
  31714. * @returns "GroundMesh"
  31715. */
  31716. getClassName(): string;
  31717. /**
  31718. * The minimum of x and y subdivisions
  31719. */
  31720. get subdivisions(): number;
  31721. /**
  31722. * X subdivisions
  31723. */
  31724. get subdivisionsX(): number;
  31725. /**
  31726. * Y subdivisions
  31727. */
  31728. get subdivisionsY(): number;
  31729. /**
  31730. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31731. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31732. * @param chunksCount the number of subdivisions for x and y
  31733. * @param octreeBlocksSize (Default: 32)
  31734. */
  31735. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31736. /**
  31737. * Returns a height (y) value in the Worl system :
  31738. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31739. * @param x x coordinate
  31740. * @param z z coordinate
  31741. * @returns the ground y position if (x, z) are outside the ground surface.
  31742. */
  31743. getHeightAtCoordinates(x: number, z: number): number;
  31744. /**
  31745. * Returns a normalized vector (Vector3) orthogonal to the ground
  31746. * at the ground coordinates (x, z) expressed in the World system.
  31747. * @param x x coordinate
  31748. * @param z z coordinate
  31749. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31750. */
  31751. getNormalAtCoordinates(x: number, z: number): Vector3;
  31752. /**
  31753. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31754. * at the ground coordinates (x, z) expressed in the World system.
  31755. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31756. * @param x x coordinate
  31757. * @param z z coordinate
  31758. * @param ref vector to store the result
  31759. * @returns the GroundMesh.
  31760. */
  31761. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31762. /**
  31763. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31764. * if the ground has been updated.
  31765. * This can be used in the render loop.
  31766. * @returns the GroundMesh.
  31767. */
  31768. updateCoordinateHeights(): GroundMesh;
  31769. private _getFacetAt;
  31770. private _initHeightQuads;
  31771. private _computeHeightQuads;
  31772. /**
  31773. * Serializes this ground mesh
  31774. * @param serializationObject object to write serialization to
  31775. */
  31776. serialize(serializationObject: any): void;
  31777. /**
  31778. * Parses a serialized ground mesh
  31779. * @param parsedMesh the serialized mesh
  31780. * @param scene the scene to create the ground mesh in
  31781. * @returns the created ground mesh
  31782. */
  31783. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31784. }
  31785. }
  31786. declare module BABYLON {
  31787. /**
  31788. * Interface for Physics-Joint data
  31789. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31790. */
  31791. export interface PhysicsJointData {
  31792. /**
  31793. * The main pivot of the joint
  31794. */
  31795. mainPivot?: Vector3;
  31796. /**
  31797. * The connected pivot of the joint
  31798. */
  31799. connectedPivot?: Vector3;
  31800. /**
  31801. * The main axis of the joint
  31802. */
  31803. mainAxis?: Vector3;
  31804. /**
  31805. * The connected axis of the joint
  31806. */
  31807. connectedAxis?: Vector3;
  31808. /**
  31809. * The collision of the joint
  31810. */
  31811. collision?: boolean;
  31812. /**
  31813. * Native Oimo/Cannon/Energy data
  31814. */
  31815. nativeParams?: any;
  31816. }
  31817. /**
  31818. * This is a holder class for the physics joint created by the physics plugin
  31819. * It holds a set of functions to control the underlying joint
  31820. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31821. */
  31822. export class PhysicsJoint {
  31823. /**
  31824. * The type of the physics joint
  31825. */
  31826. type: number;
  31827. /**
  31828. * The data for the physics joint
  31829. */
  31830. jointData: PhysicsJointData;
  31831. private _physicsJoint;
  31832. protected _physicsPlugin: IPhysicsEnginePlugin;
  31833. /**
  31834. * Initializes the physics joint
  31835. * @param type The type of the physics joint
  31836. * @param jointData The data for the physics joint
  31837. */
  31838. constructor(
  31839. /**
  31840. * The type of the physics joint
  31841. */
  31842. type: number,
  31843. /**
  31844. * The data for the physics joint
  31845. */
  31846. jointData: PhysicsJointData);
  31847. /**
  31848. * Gets the physics joint
  31849. */
  31850. get physicsJoint(): any;
  31851. /**
  31852. * Sets the physics joint
  31853. */
  31854. set physicsJoint(newJoint: any);
  31855. /**
  31856. * Sets the physics plugin
  31857. */
  31858. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31859. /**
  31860. * Execute a function that is physics-plugin specific.
  31861. * @param {Function} func the function that will be executed.
  31862. * It accepts two parameters: the physics world and the physics joint
  31863. */
  31864. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31865. /**
  31866. * Distance-Joint type
  31867. */
  31868. static DistanceJoint: number;
  31869. /**
  31870. * Hinge-Joint type
  31871. */
  31872. static HingeJoint: number;
  31873. /**
  31874. * Ball-and-Socket joint type
  31875. */
  31876. static BallAndSocketJoint: number;
  31877. /**
  31878. * Wheel-Joint type
  31879. */
  31880. static WheelJoint: number;
  31881. /**
  31882. * Slider-Joint type
  31883. */
  31884. static SliderJoint: number;
  31885. /**
  31886. * Prismatic-Joint type
  31887. */
  31888. static PrismaticJoint: number;
  31889. /**
  31890. * Universal-Joint type
  31891. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31892. */
  31893. static UniversalJoint: number;
  31894. /**
  31895. * Hinge-Joint 2 type
  31896. */
  31897. static Hinge2Joint: number;
  31898. /**
  31899. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31900. */
  31901. static PointToPointJoint: number;
  31902. /**
  31903. * Spring-Joint type
  31904. */
  31905. static SpringJoint: number;
  31906. /**
  31907. * Lock-Joint type
  31908. */
  31909. static LockJoint: number;
  31910. }
  31911. /**
  31912. * A class representing a physics distance joint
  31913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31914. */
  31915. export class DistanceJoint extends PhysicsJoint {
  31916. /**
  31917. *
  31918. * @param jointData The data for the Distance-Joint
  31919. */
  31920. constructor(jointData: DistanceJointData);
  31921. /**
  31922. * Update the predefined distance.
  31923. * @param maxDistance The maximum preferred distance
  31924. * @param minDistance The minimum preferred distance
  31925. */
  31926. updateDistance(maxDistance: number, minDistance?: number): void;
  31927. }
  31928. /**
  31929. * Represents a Motor-Enabled Joint
  31930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31931. */
  31932. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31933. /**
  31934. * Initializes the Motor-Enabled Joint
  31935. * @param type The type of the joint
  31936. * @param jointData The physica joint data for the joint
  31937. */
  31938. constructor(type: number, jointData: PhysicsJointData);
  31939. /**
  31940. * Set the motor values.
  31941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31942. * @param force the force to apply
  31943. * @param maxForce max force for this motor.
  31944. */
  31945. setMotor(force?: number, maxForce?: number): void;
  31946. /**
  31947. * Set the motor's limits.
  31948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31949. * @param upperLimit The upper limit of the motor
  31950. * @param lowerLimit The lower limit of the motor
  31951. */
  31952. setLimit(upperLimit: number, lowerLimit?: number): void;
  31953. }
  31954. /**
  31955. * This class represents a single physics Hinge-Joint
  31956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31957. */
  31958. export class HingeJoint extends MotorEnabledJoint {
  31959. /**
  31960. * Initializes the Hinge-Joint
  31961. * @param jointData The joint data for the Hinge-Joint
  31962. */
  31963. constructor(jointData: PhysicsJointData);
  31964. /**
  31965. * Set the motor values.
  31966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31967. * @param {number} force the force to apply
  31968. * @param {number} maxForce max force for this motor.
  31969. */
  31970. setMotor(force?: number, maxForce?: number): void;
  31971. /**
  31972. * Set the motor's limits.
  31973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31974. * @param upperLimit The upper limit of the motor
  31975. * @param lowerLimit The lower limit of the motor
  31976. */
  31977. setLimit(upperLimit: number, lowerLimit?: number): void;
  31978. }
  31979. /**
  31980. * This class represents a dual hinge physics joint (same as wheel joint)
  31981. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31982. */
  31983. export class Hinge2Joint extends MotorEnabledJoint {
  31984. /**
  31985. * Initializes the Hinge2-Joint
  31986. * @param jointData The joint data for the Hinge2-Joint
  31987. */
  31988. constructor(jointData: PhysicsJointData);
  31989. /**
  31990. * Set the motor values.
  31991. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31992. * @param {number} targetSpeed the speed the motor is to reach
  31993. * @param {number} maxForce max force for this motor.
  31994. * @param {motorIndex} the motor's index, 0 or 1.
  31995. */
  31996. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31997. /**
  31998. * Set the motor limits.
  31999. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32000. * @param {number} upperLimit the upper limit
  32001. * @param {number} lowerLimit lower limit
  32002. * @param {motorIndex} the motor's index, 0 or 1.
  32003. */
  32004. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32005. }
  32006. /**
  32007. * Interface for a motor enabled joint
  32008. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32009. */
  32010. export interface IMotorEnabledJoint {
  32011. /**
  32012. * Physics joint
  32013. */
  32014. physicsJoint: any;
  32015. /**
  32016. * Sets the motor of the motor-enabled joint
  32017. * @param force The force of the motor
  32018. * @param maxForce The maximum force of the motor
  32019. * @param motorIndex The index of the motor
  32020. */
  32021. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  32022. /**
  32023. * Sets the limit of the motor
  32024. * @param upperLimit The upper limit of the motor
  32025. * @param lowerLimit The lower limit of the motor
  32026. * @param motorIndex The index of the motor
  32027. */
  32028. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32029. }
  32030. /**
  32031. * Joint data for a Distance-Joint
  32032. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32033. */
  32034. export interface DistanceJointData extends PhysicsJointData {
  32035. /**
  32036. * Max distance the 2 joint objects can be apart
  32037. */
  32038. maxDistance: number;
  32039. }
  32040. /**
  32041. * Joint data from a spring joint
  32042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32043. */
  32044. export interface SpringJointData extends PhysicsJointData {
  32045. /**
  32046. * Length of the spring
  32047. */
  32048. length: number;
  32049. /**
  32050. * Stiffness of the spring
  32051. */
  32052. stiffness: number;
  32053. /**
  32054. * Damping of the spring
  32055. */
  32056. damping: number;
  32057. /** this callback will be called when applying the force to the impostors. */
  32058. forceApplicationCallback: () => void;
  32059. }
  32060. }
  32061. declare module BABYLON {
  32062. /**
  32063. * Holds the data for the raycast result
  32064. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32065. */
  32066. export class PhysicsRaycastResult {
  32067. private _hasHit;
  32068. private _hitDistance;
  32069. private _hitNormalWorld;
  32070. private _hitPointWorld;
  32071. private _rayFromWorld;
  32072. private _rayToWorld;
  32073. /**
  32074. * Gets if there was a hit
  32075. */
  32076. get hasHit(): boolean;
  32077. /**
  32078. * Gets the distance from the hit
  32079. */
  32080. get hitDistance(): number;
  32081. /**
  32082. * Gets the hit normal/direction in the world
  32083. */
  32084. get hitNormalWorld(): Vector3;
  32085. /**
  32086. * Gets the hit point in the world
  32087. */
  32088. get hitPointWorld(): Vector3;
  32089. /**
  32090. * Gets the ray "start point" of the ray in the world
  32091. */
  32092. get rayFromWorld(): Vector3;
  32093. /**
  32094. * Gets the ray "end point" of the ray in the world
  32095. */
  32096. get rayToWorld(): Vector3;
  32097. /**
  32098. * Sets the hit data (normal & point in world space)
  32099. * @param hitNormalWorld defines the normal in world space
  32100. * @param hitPointWorld defines the point in world space
  32101. */
  32102. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  32103. /**
  32104. * Sets the distance from the start point to the hit point
  32105. * @param distance
  32106. */
  32107. setHitDistance(distance: number): void;
  32108. /**
  32109. * Calculates the distance manually
  32110. */
  32111. calculateHitDistance(): void;
  32112. /**
  32113. * Resets all the values to default
  32114. * @param from The from point on world space
  32115. * @param to The to point on world space
  32116. */
  32117. reset(from?: Vector3, to?: Vector3): void;
  32118. }
  32119. /**
  32120. * Interface for the size containing width and height
  32121. */
  32122. interface IXYZ {
  32123. /**
  32124. * X
  32125. */
  32126. x: number;
  32127. /**
  32128. * Y
  32129. */
  32130. y: number;
  32131. /**
  32132. * Z
  32133. */
  32134. z: number;
  32135. }
  32136. }
  32137. declare module BABYLON {
  32138. /**
  32139. * Interface used to describe a physics joint
  32140. */
  32141. export interface PhysicsImpostorJoint {
  32142. /** Defines the main impostor to which the joint is linked */
  32143. mainImpostor: PhysicsImpostor;
  32144. /** Defines the impostor that is connected to the main impostor using this joint */
  32145. connectedImpostor: PhysicsImpostor;
  32146. /** Defines the joint itself */
  32147. joint: PhysicsJoint;
  32148. }
  32149. /** @hidden */
  32150. export interface IPhysicsEnginePlugin {
  32151. world: any;
  32152. name: string;
  32153. setGravity(gravity: Vector3): void;
  32154. setTimeStep(timeStep: number): void;
  32155. getTimeStep(): number;
  32156. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  32157. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32158. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  32159. generatePhysicsBody(impostor: PhysicsImpostor): void;
  32160. removePhysicsBody(impostor: PhysicsImpostor): void;
  32161. generateJoint(joint: PhysicsImpostorJoint): void;
  32162. removeJoint(joint: PhysicsImpostorJoint): void;
  32163. isSupported(): boolean;
  32164. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  32165. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  32166. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32167. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  32168. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32169. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  32170. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  32171. getBodyMass(impostor: PhysicsImpostor): number;
  32172. getBodyFriction(impostor: PhysicsImpostor): number;
  32173. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  32174. getBodyRestitution(impostor: PhysicsImpostor): number;
  32175. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  32176. getBodyPressure?(impostor: PhysicsImpostor): number;
  32177. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  32178. getBodyStiffness?(impostor: PhysicsImpostor): number;
  32179. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  32180. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  32181. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  32182. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  32183. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  32184. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32185. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  32186. sleepBody(impostor: PhysicsImpostor): void;
  32187. wakeUpBody(impostor: PhysicsImpostor): void;
  32188. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32189. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  32190. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  32191. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32192. getRadius(impostor: PhysicsImpostor): number;
  32193. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  32194. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  32195. dispose(): void;
  32196. }
  32197. /**
  32198. * Interface used to define a physics engine
  32199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32200. */
  32201. export interface IPhysicsEngine {
  32202. /**
  32203. * Gets the gravity vector used by the simulation
  32204. */
  32205. gravity: Vector3;
  32206. /**
  32207. * Sets the gravity vector used by the simulation
  32208. * @param gravity defines the gravity vector to use
  32209. */
  32210. setGravity(gravity: Vector3): void;
  32211. /**
  32212. * Set the time step of the physics engine.
  32213. * Default is 1/60.
  32214. * To slow it down, enter 1/600 for example.
  32215. * To speed it up, 1/30
  32216. * @param newTimeStep the new timestep to apply to this world.
  32217. */
  32218. setTimeStep(newTimeStep: number): void;
  32219. /**
  32220. * Get the time step of the physics engine.
  32221. * @returns the current time step
  32222. */
  32223. getTimeStep(): number;
  32224. /**
  32225. * Set the sub time step of the physics engine.
  32226. * Default is 0 meaning there is no sub steps
  32227. * To increase physics resolution precision, set a small value (like 1 ms)
  32228. * @param subTimeStep defines the new sub timestep used for physics resolution.
  32229. */
  32230. setSubTimeStep(subTimeStep: number): void;
  32231. /**
  32232. * Get the sub time step of the physics engine.
  32233. * @returns the current sub time step
  32234. */
  32235. getSubTimeStep(): number;
  32236. /**
  32237. * Release all resources
  32238. */
  32239. dispose(): void;
  32240. /**
  32241. * Gets the name of the current physics plugin
  32242. * @returns the name of the plugin
  32243. */
  32244. getPhysicsPluginName(): string;
  32245. /**
  32246. * Adding a new impostor for the impostor tracking.
  32247. * This will be done by the impostor itself.
  32248. * @param impostor the impostor to add
  32249. */
  32250. addImpostor(impostor: PhysicsImpostor): void;
  32251. /**
  32252. * Remove an impostor from the engine.
  32253. * This impostor and its mesh will not longer be updated by the physics engine.
  32254. * @param impostor the impostor to remove
  32255. */
  32256. removeImpostor(impostor: PhysicsImpostor): void;
  32257. /**
  32258. * Add a joint to the physics engine
  32259. * @param mainImpostor defines the main impostor to which the joint is added.
  32260. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  32261. * @param joint defines the joint that will connect both impostors.
  32262. */
  32263. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32264. /**
  32265. * Removes a joint from the simulation
  32266. * @param mainImpostor defines the impostor used with the joint
  32267. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  32268. * @param joint defines the joint to remove
  32269. */
  32270. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  32271. /**
  32272. * Gets the current plugin used to run the simulation
  32273. * @returns current plugin
  32274. */
  32275. getPhysicsPlugin(): IPhysicsEnginePlugin;
  32276. /**
  32277. * Gets the list of physic impostors
  32278. * @returns an array of PhysicsImpostor
  32279. */
  32280. getImpostors(): Array<PhysicsImpostor>;
  32281. /**
  32282. * Gets the impostor for a physics enabled object
  32283. * @param object defines the object impersonated by the impostor
  32284. * @returns the PhysicsImpostor or null if not found
  32285. */
  32286. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32287. /**
  32288. * Gets the impostor for a physics body object
  32289. * @param body defines physics body used by the impostor
  32290. * @returns the PhysicsImpostor or null if not found
  32291. */
  32292. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  32293. /**
  32294. * Does a raycast in the physics world
  32295. * @param from when should the ray start?
  32296. * @param to when should the ray end?
  32297. * @returns PhysicsRaycastResult
  32298. */
  32299. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  32300. /**
  32301. * Called by the scene. No need to call it.
  32302. * @param delta defines the timespam between frames
  32303. */
  32304. _step(delta: number): void;
  32305. }
  32306. }
  32307. declare module BABYLON {
  32308. /**
  32309. * The interface for the physics imposter parameters
  32310. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32311. */
  32312. export interface PhysicsImpostorParameters {
  32313. /**
  32314. * The mass of the physics imposter
  32315. */
  32316. mass: number;
  32317. /**
  32318. * The friction of the physics imposter
  32319. */
  32320. friction?: number;
  32321. /**
  32322. * The coefficient of restitution of the physics imposter
  32323. */
  32324. restitution?: number;
  32325. /**
  32326. * The native options of the physics imposter
  32327. */
  32328. nativeOptions?: any;
  32329. /**
  32330. * Specifies if the parent should be ignored
  32331. */
  32332. ignoreParent?: boolean;
  32333. /**
  32334. * Specifies if bi-directional transformations should be disabled
  32335. */
  32336. disableBidirectionalTransformation?: boolean;
  32337. /**
  32338. * The pressure inside the physics imposter, soft object only
  32339. */
  32340. pressure?: number;
  32341. /**
  32342. * The stiffness the physics imposter, soft object only
  32343. */
  32344. stiffness?: number;
  32345. /**
  32346. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  32347. */
  32348. velocityIterations?: number;
  32349. /**
  32350. * The number of iterations used in maintaining consistent vertex positions, soft object only
  32351. */
  32352. positionIterations?: number;
  32353. /**
  32354. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  32355. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  32356. * Add to fix multiple points
  32357. */
  32358. fixedPoints?: number;
  32359. /**
  32360. * The collision margin around a soft object
  32361. */
  32362. margin?: number;
  32363. /**
  32364. * The collision margin around a soft object
  32365. */
  32366. damping?: number;
  32367. /**
  32368. * The path for a rope based on an extrusion
  32369. */
  32370. path?: any;
  32371. /**
  32372. * The shape of an extrusion used for a rope based on an extrusion
  32373. */
  32374. shape?: any;
  32375. }
  32376. /**
  32377. * Interface for a physics-enabled object
  32378. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32379. */
  32380. export interface IPhysicsEnabledObject {
  32381. /**
  32382. * The position of the physics-enabled object
  32383. */
  32384. position: Vector3;
  32385. /**
  32386. * The rotation of the physics-enabled object
  32387. */
  32388. rotationQuaternion: Nullable<Quaternion>;
  32389. /**
  32390. * The scale of the physics-enabled object
  32391. */
  32392. scaling: Vector3;
  32393. /**
  32394. * The rotation of the physics-enabled object
  32395. */
  32396. rotation?: Vector3;
  32397. /**
  32398. * The parent of the physics-enabled object
  32399. */
  32400. parent?: any;
  32401. /**
  32402. * The bounding info of the physics-enabled object
  32403. * @returns The bounding info of the physics-enabled object
  32404. */
  32405. getBoundingInfo(): BoundingInfo;
  32406. /**
  32407. * Computes the world matrix
  32408. * @param force Specifies if the world matrix should be computed by force
  32409. * @returns A world matrix
  32410. */
  32411. computeWorldMatrix(force: boolean): Matrix;
  32412. /**
  32413. * Gets the world matrix
  32414. * @returns A world matrix
  32415. */
  32416. getWorldMatrix?(): Matrix;
  32417. /**
  32418. * Gets the child meshes
  32419. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  32420. * @returns An array of abstract meshes
  32421. */
  32422. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  32423. /**
  32424. * Gets the vertex data
  32425. * @param kind The type of vertex data
  32426. * @returns A nullable array of numbers, or a float32 array
  32427. */
  32428. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  32429. /**
  32430. * Gets the indices from the mesh
  32431. * @returns A nullable array of index arrays
  32432. */
  32433. getIndices?(): Nullable<IndicesArray>;
  32434. /**
  32435. * Gets the scene from the mesh
  32436. * @returns the indices array or null
  32437. */
  32438. getScene?(): Scene;
  32439. /**
  32440. * Gets the absolute position from the mesh
  32441. * @returns the absolute position
  32442. */
  32443. getAbsolutePosition(): Vector3;
  32444. /**
  32445. * Gets the absolute pivot point from the mesh
  32446. * @returns the absolute pivot point
  32447. */
  32448. getAbsolutePivotPoint(): Vector3;
  32449. /**
  32450. * Rotates the mesh
  32451. * @param axis The axis of rotation
  32452. * @param amount The amount of rotation
  32453. * @param space The space of the rotation
  32454. * @returns The rotation transform node
  32455. */
  32456. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  32457. /**
  32458. * Translates the mesh
  32459. * @param axis The axis of translation
  32460. * @param distance The distance of translation
  32461. * @param space The space of the translation
  32462. * @returns The transform node
  32463. */
  32464. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  32465. /**
  32466. * Sets the absolute position of the mesh
  32467. * @param absolutePosition The absolute position of the mesh
  32468. * @returns The transform node
  32469. */
  32470. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  32471. /**
  32472. * Gets the class name of the mesh
  32473. * @returns The class name
  32474. */
  32475. getClassName(): string;
  32476. }
  32477. /**
  32478. * Represents a physics imposter
  32479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32480. */
  32481. export class PhysicsImpostor {
  32482. /**
  32483. * The physics-enabled object used as the physics imposter
  32484. */
  32485. object: IPhysicsEnabledObject;
  32486. /**
  32487. * The type of the physics imposter
  32488. */
  32489. type: number;
  32490. private _options;
  32491. private _scene?;
  32492. /**
  32493. * The default object size of the imposter
  32494. */
  32495. static DEFAULT_OBJECT_SIZE: Vector3;
  32496. /**
  32497. * The identity quaternion of the imposter
  32498. */
  32499. static IDENTITY_QUATERNION: Quaternion;
  32500. /** @hidden */
  32501. _pluginData: any;
  32502. private _physicsEngine;
  32503. private _physicsBody;
  32504. private _bodyUpdateRequired;
  32505. private _onBeforePhysicsStepCallbacks;
  32506. private _onAfterPhysicsStepCallbacks;
  32507. /** @hidden */
  32508. _onPhysicsCollideCallbacks: Array<{
  32509. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  32510. otherImpostors: Array<PhysicsImpostor>;
  32511. }>;
  32512. private _deltaPosition;
  32513. private _deltaRotation;
  32514. private _deltaRotationConjugated;
  32515. /** @hidden */
  32516. _isFromLine: boolean;
  32517. private _parent;
  32518. private _isDisposed;
  32519. private static _tmpVecs;
  32520. private static _tmpQuat;
  32521. /**
  32522. * Specifies if the physics imposter is disposed
  32523. */
  32524. get isDisposed(): boolean;
  32525. /**
  32526. * Gets the mass of the physics imposter
  32527. */
  32528. get mass(): number;
  32529. set mass(value: number);
  32530. /**
  32531. * Gets the coefficient of friction
  32532. */
  32533. get friction(): number;
  32534. /**
  32535. * Sets the coefficient of friction
  32536. */
  32537. set friction(value: number);
  32538. /**
  32539. * Gets the coefficient of restitution
  32540. */
  32541. get restitution(): number;
  32542. /**
  32543. * Sets the coefficient of restitution
  32544. */
  32545. set restitution(value: number);
  32546. /**
  32547. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  32548. */
  32549. get pressure(): number;
  32550. /**
  32551. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  32552. */
  32553. set pressure(value: number);
  32554. /**
  32555. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32556. */
  32557. get stiffness(): number;
  32558. /**
  32559. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  32560. */
  32561. set stiffness(value: number);
  32562. /**
  32563. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32564. */
  32565. get velocityIterations(): number;
  32566. /**
  32567. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  32568. */
  32569. set velocityIterations(value: number);
  32570. /**
  32571. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32572. */
  32573. get positionIterations(): number;
  32574. /**
  32575. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  32576. */
  32577. set positionIterations(value: number);
  32578. /**
  32579. * The unique id of the physics imposter
  32580. * set by the physics engine when adding this impostor to the array
  32581. */
  32582. uniqueId: number;
  32583. /**
  32584. * @hidden
  32585. */
  32586. soft: boolean;
  32587. /**
  32588. * @hidden
  32589. */
  32590. segments: number;
  32591. private _joints;
  32592. /**
  32593. * Initializes the physics imposter
  32594. * @param object The physics-enabled object used as the physics imposter
  32595. * @param type The type of the physics imposter
  32596. * @param _options The options for the physics imposter
  32597. * @param _scene The Babylon scene
  32598. */
  32599. constructor(
  32600. /**
  32601. * The physics-enabled object used as the physics imposter
  32602. */
  32603. object: IPhysicsEnabledObject,
  32604. /**
  32605. * The type of the physics imposter
  32606. */
  32607. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  32608. /**
  32609. * This function will completly initialize this impostor.
  32610. * It will create a new body - but only if this mesh has no parent.
  32611. * If it has, this impostor will not be used other than to define the impostor
  32612. * of the child mesh.
  32613. * @hidden
  32614. */
  32615. _init(): void;
  32616. private _getPhysicsParent;
  32617. /**
  32618. * Should a new body be generated.
  32619. * @returns boolean specifying if body initialization is required
  32620. */
  32621. isBodyInitRequired(): boolean;
  32622. /**
  32623. * Sets the updated scaling
  32624. * @param updated Specifies if the scaling is updated
  32625. */
  32626. setScalingUpdated(): void;
  32627. /**
  32628. * Force a regeneration of this or the parent's impostor's body.
  32629. * Use under cautious - This will remove all joints already implemented.
  32630. */
  32631. forceUpdate(): void;
  32632. /**
  32633. * Gets the body that holds this impostor. Either its own, or its parent.
  32634. */
  32635. get physicsBody(): any;
  32636. /**
  32637. * Get the parent of the physics imposter
  32638. * @returns Physics imposter or null
  32639. */
  32640. get parent(): Nullable<PhysicsImpostor>;
  32641. /**
  32642. * Sets the parent of the physics imposter
  32643. */
  32644. set parent(value: Nullable<PhysicsImpostor>);
  32645. /**
  32646. * Set the physics body. Used mainly by the physics engine/plugin
  32647. */
  32648. set physicsBody(physicsBody: any);
  32649. /**
  32650. * Resets the update flags
  32651. */
  32652. resetUpdateFlags(): void;
  32653. /**
  32654. * Gets the object extend size
  32655. * @returns the object extend size
  32656. */
  32657. getObjectExtendSize(): Vector3;
  32658. /**
  32659. * Gets the object center
  32660. * @returns The object center
  32661. */
  32662. getObjectCenter(): Vector3;
  32663. /**
  32664. * Get a specific parameter from the options parameters
  32665. * @param paramName The object parameter name
  32666. * @returns The object parameter
  32667. */
  32668. getParam(paramName: string): any;
  32669. /**
  32670. * Sets a specific parameter in the options given to the physics plugin
  32671. * @param paramName The parameter name
  32672. * @param value The value of the parameter
  32673. */
  32674. setParam(paramName: string, value: number): void;
  32675. /**
  32676. * Specifically change the body's mass option. Won't recreate the physics body object
  32677. * @param mass The mass of the physics imposter
  32678. */
  32679. setMass(mass: number): void;
  32680. /**
  32681. * Gets the linear velocity
  32682. * @returns linear velocity or null
  32683. */
  32684. getLinearVelocity(): Nullable<Vector3>;
  32685. /**
  32686. * Sets the linear velocity
  32687. * @param velocity linear velocity or null
  32688. */
  32689. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32690. /**
  32691. * Gets the angular velocity
  32692. * @returns angular velocity or null
  32693. */
  32694. getAngularVelocity(): Nullable<Vector3>;
  32695. /**
  32696. * Sets the angular velocity
  32697. * @param velocity The velocity or null
  32698. */
  32699. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32700. /**
  32701. * Execute a function with the physics plugin native code
  32702. * Provide a function the will have two variables - the world object and the physics body object
  32703. * @param func The function to execute with the physics plugin native code
  32704. */
  32705. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32706. /**
  32707. * Register a function that will be executed before the physics world is stepping forward
  32708. * @param func The function to execute before the physics world is stepped forward
  32709. */
  32710. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32711. /**
  32712. * Unregister a function that will be executed before the physics world is stepping forward
  32713. * @param func The function to execute before the physics world is stepped forward
  32714. */
  32715. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32716. /**
  32717. * Register a function that will be executed after the physics step
  32718. * @param func The function to execute after physics step
  32719. */
  32720. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32721. /**
  32722. * Unregisters a function that will be executed after the physics step
  32723. * @param func The function to execute after physics step
  32724. */
  32725. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32726. /**
  32727. * register a function that will be executed when this impostor collides against a different body
  32728. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32729. * @param func Callback that is executed on collision
  32730. */
  32731. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32732. /**
  32733. * Unregisters the physics imposter on contact
  32734. * @param collideAgainst The physics object to collide against
  32735. * @param func Callback to execute on collision
  32736. */
  32737. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32738. private _tmpQuat;
  32739. private _tmpQuat2;
  32740. /**
  32741. * Get the parent rotation
  32742. * @returns The parent rotation
  32743. */
  32744. getParentsRotation(): Quaternion;
  32745. /**
  32746. * this function is executed by the physics engine.
  32747. */
  32748. beforeStep: () => void;
  32749. /**
  32750. * this function is executed by the physics engine
  32751. */
  32752. afterStep: () => void;
  32753. /**
  32754. * Legacy collision detection event support
  32755. */
  32756. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32757. /**
  32758. * event and body object due to cannon's event-based architecture.
  32759. */
  32760. onCollide: (e: {
  32761. body: any;
  32762. point: Nullable<Vector3>;
  32763. }) => void;
  32764. /**
  32765. * Apply a force
  32766. * @param force The force to apply
  32767. * @param contactPoint The contact point for the force
  32768. * @returns The physics imposter
  32769. */
  32770. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32771. /**
  32772. * Apply an impulse
  32773. * @param force The impulse force
  32774. * @param contactPoint The contact point for the impulse force
  32775. * @returns The physics imposter
  32776. */
  32777. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32778. /**
  32779. * A help function to create a joint
  32780. * @param otherImpostor A physics imposter used to create a joint
  32781. * @param jointType The type of joint
  32782. * @param jointData The data for the joint
  32783. * @returns The physics imposter
  32784. */
  32785. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32786. /**
  32787. * Add a joint to this impostor with a different impostor
  32788. * @param otherImpostor A physics imposter used to add a joint
  32789. * @param joint The joint to add
  32790. * @returns The physics imposter
  32791. */
  32792. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32793. /**
  32794. * Add an anchor to a cloth impostor
  32795. * @param otherImpostor rigid impostor to anchor to
  32796. * @param width ratio across width from 0 to 1
  32797. * @param height ratio up height from 0 to 1
  32798. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32799. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32800. * @returns impostor the soft imposter
  32801. */
  32802. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32803. /**
  32804. * Add a hook to a rope impostor
  32805. * @param otherImpostor rigid impostor to anchor to
  32806. * @param length ratio across rope from 0 to 1
  32807. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32808. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32809. * @returns impostor the rope imposter
  32810. */
  32811. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32812. /**
  32813. * Will keep this body still, in a sleep mode.
  32814. * @returns the physics imposter
  32815. */
  32816. sleep(): PhysicsImpostor;
  32817. /**
  32818. * Wake the body up.
  32819. * @returns The physics imposter
  32820. */
  32821. wakeUp(): PhysicsImpostor;
  32822. /**
  32823. * Clones the physics imposter
  32824. * @param newObject The physics imposter clones to this physics-enabled object
  32825. * @returns A nullable physics imposter
  32826. */
  32827. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32828. /**
  32829. * Disposes the physics imposter
  32830. */
  32831. dispose(): void;
  32832. /**
  32833. * Sets the delta position
  32834. * @param position The delta position amount
  32835. */
  32836. setDeltaPosition(position: Vector3): void;
  32837. /**
  32838. * Sets the delta rotation
  32839. * @param rotation The delta rotation amount
  32840. */
  32841. setDeltaRotation(rotation: Quaternion): void;
  32842. /**
  32843. * Gets the box size of the physics imposter and stores the result in the input parameter
  32844. * @param result Stores the box size
  32845. * @returns The physics imposter
  32846. */
  32847. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32848. /**
  32849. * Gets the radius of the physics imposter
  32850. * @returns Radius of the physics imposter
  32851. */
  32852. getRadius(): number;
  32853. /**
  32854. * Sync a bone with this impostor
  32855. * @param bone The bone to sync to the impostor.
  32856. * @param boneMesh The mesh that the bone is influencing.
  32857. * @param jointPivot The pivot of the joint / bone in local space.
  32858. * @param distToJoint Optional distance from the impostor to the joint.
  32859. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32860. */
  32861. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32862. /**
  32863. * Sync impostor to a bone
  32864. * @param bone The bone that the impostor will be synced to.
  32865. * @param boneMesh The mesh that the bone is influencing.
  32866. * @param jointPivot The pivot of the joint / bone in local space.
  32867. * @param distToJoint Optional distance from the impostor to the joint.
  32868. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32869. * @param boneAxis Optional vector3 axis the bone is aligned with
  32870. */
  32871. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32872. /**
  32873. * No-Imposter type
  32874. */
  32875. static NoImpostor: number;
  32876. /**
  32877. * Sphere-Imposter type
  32878. */
  32879. static SphereImpostor: number;
  32880. /**
  32881. * Box-Imposter type
  32882. */
  32883. static BoxImpostor: number;
  32884. /**
  32885. * Plane-Imposter type
  32886. */
  32887. static PlaneImpostor: number;
  32888. /**
  32889. * Mesh-imposter type
  32890. */
  32891. static MeshImpostor: number;
  32892. /**
  32893. * Capsule-Impostor type (Ammo.js plugin only)
  32894. */
  32895. static CapsuleImpostor: number;
  32896. /**
  32897. * Cylinder-Imposter type
  32898. */
  32899. static CylinderImpostor: number;
  32900. /**
  32901. * Particle-Imposter type
  32902. */
  32903. static ParticleImpostor: number;
  32904. /**
  32905. * Heightmap-Imposter type
  32906. */
  32907. static HeightmapImpostor: number;
  32908. /**
  32909. * ConvexHull-Impostor type (Ammo.js plugin only)
  32910. */
  32911. static ConvexHullImpostor: number;
  32912. /**
  32913. * Custom-Imposter type (Ammo.js plugin only)
  32914. */
  32915. static CustomImpostor: number;
  32916. /**
  32917. * Rope-Imposter type
  32918. */
  32919. static RopeImpostor: number;
  32920. /**
  32921. * Cloth-Imposter type
  32922. */
  32923. static ClothImpostor: number;
  32924. /**
  32925. * Softbody-Imposter type
  32926. */
  32927. static SoftbodyImpostor: number;
  32928. }
  32929. }
  32930. declare module BABYLON {
  32931. /**
  32932. * @hidden
  32933. **/
  32934. export class _CreationDataStorage {
  32935. closePath?: boolean;
  32936. closeArray?: boolean;
  32937. idx: number[];
  32938. dashSize: number;
  32939. gapSize: number;
  32940. path3D: Path3D;
  32941. pathArray: Vector3[][];
  32942. arc: number;
  32943. radius: number;
  32944. cap: number;
  32945. tessellation: number;
  32946. }
  32947. /**
  32948. * @hidden
  32949. **/
  32950. class _InstanceDataStorage {
  32951. visibleInstances: any;
  32952. batchCache: _InstancesBatch;
  32953. instancesBufferSize: number;
  32954. instancesBuffer: Nullable<Buffer>;
  32955. instancesData: Float32Array;
  32956. overridenInstanceCount: number;
  32957. isFrozen: boolean;
  32958. previousBatch: Nullable<_InstancesBatch>;
  32959. hardwareInstancedRendering: boolean;
  32960. sideOrientation: number;
  32961. manualUpdate: boolean;
  32962. previousRenderId: number;
  32963. }
  32964. /**
  32965. * @hidden
  32966. **/
  32967. export class _InstancesBatch {
  32968. mustReturn: boolean;
  32969. visibleInstances: Nullable<InstancedMesh[]>[];
  32970. renderSelf: boolean[];
  32971. hardwareInstancedRendering: boolean[];
  32972. }
  32973. /**
  32974. * @hidden
  32975. **/
  32976. class _ThinInstanceDataStorage {
  32977. instancesCount: number;
  32978. matrixBuffer: Nullable<Buffer>;
  32979. matrixBufferSize: number;
  32980. matrixData: Nullable<Float32Array>;
  32981. boundingVectors: Array<Vector3>;
  32982. worldMatrices: Nullable<Matrix[]>;
  32983. }
  32984. /**
  32985. * Class used to represent renderable models
  32986. */
  32987. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32988. /**
  32989. * Mesh side orientation : usually the external or front surface
  32990. */
  32991. static readonly FRONTSIDE: number;
  32992. /**
  32993. * Mesh side orientation : usually the internal or back surface
  32994. */
  32995. static readonly BACKSIDE: number;
  32996. /**
  32997. * Mesh side orientation : both internal and external or front and back surfaces
  32998. */
  32999. static readonly DOUBLESIDE: number;
  33000. /**
  33001. * Mesh side orientation : by default, `FRONTSIDE`
  33002. */
  33003. static readonly DEFAULTSIDE: number;
  33004. /**
  33005. * Mesh cap setting : no cap
  33006. */
  33007. static readonly NO_CAP: number;
  33008. /**
  33009. * Mesh cap setting : one cap at the beginning of the mesh
  33010. */
  33011. static readonly CAP_START: number;
  33012. /**
  33013. * Mesh cap setting : one cap at the end of the mesh
  33014. */
  33015. static readonly CAP_END: number;
  33016. /**
  33017. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  33018. */
  33019. static readonly CAP_ALL: number;
  33020. /**
  33021. * Mesh pattern setting : no flip or rotate
  33022. */
  33023. static readonly NO_FLIP: number;
  33024. /**
  33025. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  33026. */
  33027. static readonly FLIP_TILE: number;
  33028. /**
  33029. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  33030. */
  33031. static readonly ROTATE_TILE: number;
  33032. /**
  33033. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  33034. */
  33035. static readonly FLIP_ROW: number;
  33036. /**
  33037. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  33038. */
  33039. static readonly ROTATE_ROW: number;
  33040. /**
  33041. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  33042. */
  33043. static readonly FLIP_N_ROTATE_TILE: number;
  33044. /**
  33045. * Mesh pattern setting : rotate pattern and rotate
  33046. */
  33047. static readonly FLIP_N_ROTATE_ROW: number;
  33048. /**
  33049. * Mesh tile positioning : part tiles same on left/right or top/bottom
  33050. */
  33051. static readonly CENTER: number;
  33052. /**
  33053. * Mesh tile positioning : part tiles on left
  33054. */
  33055. static readonly LEFT: number;
  33056. /**
  33057. * Mesh tile positioning : part tiles on right
  33058. */
  33059. static readonly RIGHT: number;
  33060. /**
  33061. * Mesh tile positioning : part tiles on top
  33062. */
  33063. static readonly TOP: number;
  33064. /**
  33065. * Mesh tile positioning : part tiles on bottom
  33066. */
  33067. static readonly BOTTOM: number;
  33068. /**
  33069. * Gets the default side orientation.
  33070. * @param orientation the orientation to value to attempt to get
  33071. * @returns the default orientation
  33072. * @hidden
  33073. */
  33074. static _GetDefaultSideOrientation(orientation?: number): number;
  33075. private _internalMeshDataInfo;
  33076. get computeBonesUsingShaders(): boolean;
  33077. set computeBonesUsingShaders(value: boolean);
  33078. /**
  33079. * An event triggered before rendering the mesh
  33080. */
  33081. get onBeforeRenderObservable(): Observable<Mesh>;
  33082. /**
  33083. * An event triggered before binding the mesh
  33084. */
  33085. get onBeforeBindObservable(): Observable<Mesh>;
  33086. /**
  33087. * An event triggered after rendering the mesh
  33088. */
  33089. get onAfterRenderObservable(): Observable<Mesh>;
  33090. /**
  33091. * An event triggered before drawing the mesh
  33092. */
  33093. get onBeforeDrawObservable(): Observable<Mesh>;
  33094. private _onBeforeDrawObserver;
  33095. /**
  33096. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  33097. */
  33098. set onBeforeDraw(callback: () => void);
  33099. get hasInstances(): boolean;
  33100. get hasThinInstances(): boolean;
  33101. /**
  33102. * Gets the delay loading state of the mesh (when delay loading is turned on)
  33103. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  33104. */
  33105. delayLoadState: number;
  33106. /**
  33107. * Gets the list of instances created from this mesh
  33108. * it is not supposed to be modified manually.
  33109. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  33110. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33111. */
  33112. instances: InstancedMesh[];
  33113. /**
  33114. * Gets the file containing delay loading data for this mesh
  33115. */
  33116. delayLoadingFile: string;
  33117. /** @hidden */
  33118. _binaryInfo: any;
  33119. /**
  33120. * User defined function used to change how LOD level selection is done
  33121. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33122. */
  33123. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  33124. /**
  33125. * Gets or sets the morph target manager
  33126. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  33127. */
  33128. get morphTargetManager(): Nullable<MorphTargetManager>;
  33129. set morphTargetManager(value: Nullable<MorphTargetManager>);
  33130. /** @hidden */
  33131. _creationDataStorage: Nullable<_CreationDataStorage>;
  33132. /** @hidden */
  33133. _geometry: Nullable<Geometry>;
  33134. /** @hidden */
  33135. _delayInfo: Array<string>;
  33136. /** @hidden */
  33137. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  33138. /** @hidden */
  33139. _instanceDataStorage: _InstanceDataStorage;
  33140. /** @hidden */
  33141. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  33142. private _effectiveMaterial;
  33143. /** @hidden */
  33144. _shouldGenerateFlatShading: boolean;
  33145. /** @hidden */
  33146. _originalBuilderSideOrientation: number;
  33147. /**
  33148. * Use this property to change the original side orientation defined at construction time
  33149. */
  33150. overrideMaterialSideOrientation: Nullable<number>;
  33151. /**
  33152. * Gets or sets a boolean indicating whether to render ignoring the active camera's max z setting. (false by default)
  33153. * Note this will reduce performance when set to true.
  33154. */
  33155. ignoreCameraMaxZ: boolean;
  33156. /**
  33157. * Gets the source mesh (the one used to clone this one from)
  33158. */
  33159. get source(): Nullable<Mesh>;
  33160. /**
  33161. * Gets the list of clones of this mesh
  33162. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  33163. * Note that useClonedMeshMap=true is the default setting
  33164. */
  33165. get cloneMeshMap(): Nullable<{
  33166. [id: string]: Mesh | undefined;
  33167. }>;
  33168. /**
  33169. * Gets or sets a boolean indicating that this mesh does not use index buffer
  33170. */
  33171. get isUnIndexed(): boolean;
  33172. set isUnIndexed(value: boolean);
  33173. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  33174. get worldMatrixInstancedBuffer(): Float32Array;
  33175. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  33176. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  33177. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  33178. /**
  33179. * @constructor
  33180. * @param name The value used by scene.getMeshByName() to do a lookup.
  33181. * @param scene The scene to add this mesh to.
  33182. * @param parent The parent of this mesh, if it has one
  33183. * @param source An optional Mesh from which geometry is shared, cloned.
  33184. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  33185. * When false, achieved by calling a clone(), also passing False.
  33186. * This will make creation of children, recursive.
  33187. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  33188. */
  33189. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  33190. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  33191. doNotInstantiate: boolean;
  33192. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  33193. /**
  33194. * Gets the class name
  33195. * @returns the string "Mesh".
  33196. */
  33197. getClassName(): string;
  33198. /** @hidden */
  33199. get _isMesh(): boolean;
  33200. /**
  33201. * Returns a description of this mesh
  33202. * @param fullDetails define if full details about this mesh must be used
  33203. * @returns a descriptive string representing this mesh
  33204. */
  33205. toString(fullDetails?: boolean): string;
  33206. /** @hidden */
  33207. _unBindEffect(): void;
  33208. /**
  33209. * Gets a boolean indicating if this mesh has LOD
  33210. */
  33211. get hasLODLevels(): boolean;
  33212. /**
  33213. * Gets the list of MeshLODLevel associated with the current mesh
  33214. * @returns an array of MeshLODLevel
  33215. */
  33216. getLODLevels(): MeshLODLevel[];
  33217. private _sortLODLevels;
  33218. /**
  33219. * Add a mesh as LOD level triggered at the given distance.
  33220. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33221. * @param distance The distance from the center of the object to show this level
  33222. * @param mesh The mesh to be added as LOD level (can be null)
  33223. * @return This mesh (for chaining)
  33224. */
  33225. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  33226. /**
  33227. * Returns the LOD level mesh at the passed distance or null if not found.
  33228. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33229. * @param distance The distance from the center of the object to show this level
  33230. * @returns a Mesh or `null`
  33231. */
  33232. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  33233. /**
  33234. * Remove a mesh from the LOD array
  33235. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33236. * @param mesh defines the mesh to be removed
  33237. * @return This mesh (for chaining)
  33238. */
  33239. removeLODLevel(mesh: Mesh): Mesh;
  33240. /**
  33241. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  33242. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  33243. * @param camera defines the camera to use to compute distance
  33244. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  33245. * @return This mesh (for chaining)
  33246. */
  33247. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  33248. /**
  33249. * Gets the mesh internal Geometry object
  33250. */
  33251. get geometry(): Nullable<Geometry>;
  33252. /**
  33253. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  33254. * @returns the total number of vertices
  33255. */
  33256. getTotalVertices(): number;
  33257. /**
  33258. * Returns the content of an associated vertex buffer
  33259. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33260. * - VertexBuffer.PositionKind
  33261. * - VertexBuffer.UVKind
  33262. * - VertexBuffer.UV2Kind
  33263. * - VertexBuffer.UV3Kind
  33264. * - VertexBuffer.UV4Kind
  33265. * - VertexBuffer.UV5Kind
  33266. * - VertexBuffer.UV6Kind
  33267. * - VertexBuffer.ColorKind
  33268. * - VertexBuffer.MatricesIndicesKind
  33269. * - VertexBuffer.MatricesIndicesExtraKind
  33270. * - VertexBuffer.MatricesWeightsKind
  33271. * - VertexBuffer.MatricesWeightsExtraKind
  33272. * @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
  33273. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  33274. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  33275. */
  33276. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  33277. /**
  33278. * Returns the mesh VertexBuffer object from the requested `kind`
  33279. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33280. * - VertexBuffer.PositionKind
  33281. * - VertexBuffer.NormalKind
  33282. * - VertexBuffer.UVKind
  33283. * - VertexBuffer.UV2Kind
  33284. * - VertexBuffer.UV3Kind
  33285. * - VertexBuffer.UV4Kind
  33286. * - VertexBuffer.UV5Kind
  33287. * - VertexBuffer.UV6Kind
  33288. * - VertexBuffer.ColorKind
  33289. * - VertexBuffer.MatricesIndicesKind
  33290. * - VertexBuffer.MatricesIndicesExtraKind
  33291. * - VertexBuffer.MatricesWeightsKind
  33292. * - VertexBuffer.MatricesWeightsExtraKind
  33293. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  33294. */
  33295. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  33296. /**
  33297. * Tests if a specific vertex buffer is associated with this mesh
  33298. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33299. * - VertexBuffer.PositionKind
  33300. * - VertexBuffer.NormalKind
  33301. * - VertexBuffer.UVKind
  33302. * - VertexBuffer.UV2Kind
  33303. * - VertexBuffer.UV3Kind
  33304. * - VertexBuffer.UV4Kind
  33305. * - VertexBuffer.UV5Kind
  33306. * - VertexBuffer.UV6Kind
  33307. * - VertexBuffer.ColorKind
  33308. * - VertexBuffer.MatricesIndicesKind
  33309. * - VertexBuffer.MatricesIndicesExtraKind
  33310. * - VertexBuffer.MatricesWeightsKind
  33311. * - VertexBuffer.MatricesWeightsExtraKind
  33312. * @returns a boolean
  33313. */
  33314. isVerticesDataPresent(kind: string): boolean;
  33315. /**
  33316. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  33317. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  33318. * - VertexBuffer.PositionKind
  33319. * - VertexBuffer.UVKind
  33320. * - VertexBuffer.UV2Kind
  33321. * - VertexBuffer.UV3Kind
  33322. * - VertexBuffer.UV4Kind
  33323. * - VertexBuffer.UV5Kind
  33324. * - VertexBuffer.UV6Kind
  33325. * - VertexBuffer.ColorKind
  33326. * - VertexBuffer.MatricesIndicesKind
  33327. * - VertexBuffer.MatricesIndicesExtraKind
  33328. * - VertexBuffer.MatricesWeightsKind
  33329. * - VertexBuffer.MatricesWeightsExtraKind
  33330. * @returns a boolean
  33331. */
  33332. isVertexBufferUpdatable(kind: string): boolean;
  33333. /**
  33334. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  33335. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  33336. * - VertexBuffer.PositionKind
  33337. * - VertexBuffer.NormalKind
  33338. * - VertexBuffer.UVKind
  33339. * - VertexBuffer.UV2Kind
  33340. * - VertexBuffer.UV3Kind
  33341. * - VertexBuffer.UV4Kind
  33342. * - VertexBuffer.UV5Kind
  33343. * - VertexBuffer.UV6Kind
  33344. * - VertexBuffer.ColorKind
  33345. * - VertexBuffer.MatricesIndicesKind
  33346. * - VertexBuffer.MatricesIndicesExtraKind
  33347. * - VertexBuffer.MatricesWeightsKind
  33348. * - VertexBuffer.MatricesWeightsExtraKind
  33349. * @returns an array of strings
  33350. */
  33351. getVerticesDataKinds(): string[];
  33352. /**
  33353. * Returns a positive integer : the total number of indices in this mesh geometry.
  33354. * @returns the numner of indices or zero if the mesh has no geometry.
  33355. */
  33356. getTotalIndices(): number;
  33357. /**
  33358. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  33359. * @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.
  33360. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  33361. * @returns the indices array or an empty array if the mesh has no geometry
  33362. */
  33363. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  33364. get isBlocked(): boolean;
  33365. /**
  33366. * Determine if the current mesh is ready to be rendered
  33367. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33368. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  33369. * @returns true if all associated assets are ready (material, textures, shaders)
  33370. */
  33371. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  33372. /**
  33373. * 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.
  33374. */
  33375. get areNormalsFrozen(): boolean;
  33376. /**
  33377. * 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.
  33378. * @returns the current mesh
  33379. */
  33380. freezeNormals(): Mesh;
  33381. /**
  33382. * 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
  33383. * @returns the current mesh
  33384. */
  33385. unfreezeNormals(): Mesh;
  33386. /**
  33387. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  33388. */
  33389. set overridenInstanceCount(count: number);
  33390. /** @hidden */
  33391. _preActivate(): Mesh;
  33392. /** @hidden */
  33393. _preActivateForIntermediateRendering(renderId: number): Mesh;
  33394. /** @hidden */
  33395. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  33396. protected _afterComputeWorldMatrix(): void;
  33397. /** @hidden */
  33398. _postActivate(): void;
  33399. /**
  33400. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33401. * This means the mesh underlying bounding box and sphere are recomputed.
  33402. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33403. * @returns the current mesh
  33404. */
  33405. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  33406. /** @hidden */
  33407. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  33408. /**
  33409. * This function will subdivide the mesh into multiple submeshes
  33410. * @param count defines the expected number of submeshes
  33411. */
  33412. subdivide(count: number): void;
  33413. /**
  33414. * Copy a FloatArray into a specific associated vertex buffer
  33415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33416. * - VertexBuffer.PositionKind
  33417. * - VertexBuffer.UVKind
  33418. * - VertexBuffer.UV2Kind
  33419. * - VertexBuffer.UV3Kind
  33420. * - VertexBuffer.UV4Kind
  33421. * - VertexBuffer.UV5Kind
  33422. * - VertexBuffer.UV6Kind
  33423. * - VertexBuffer.ColorKind
  33424. * - VertexBuffer.MatricesIndicesKind
  33425. * - VertexBuffer.MatricesIndicesExtraKind
  33426. * - VertexBuffer.MatricesWeightsKind
  33427. * - VertexBuffer.MatricesWeightsExtraKind
  33428. * @param data defines the data source
  33429. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33430. * @param stride defines the data stride size (can be null)
  33431. * @returns the current mesh
  33432. */
  33433. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33434. /**
  33435. * Delete a vertex buffer associated with this mesh
  33436. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  33437. * - VertexBuffer.PositionKind
  33438. * - VertexBuffer.UVKind
  33439. * - VertexBuffer.UV2Kind
  33440. * - VertexBuffer.UV3Kind
  33441. * - VertexBuffer.UV4Kind
  33442. * - VertexBuffer.UV5Kind
  33443. * - VertexBuffer.UV6Kind
  33444. * - VertexBuffer.ColorKind
  33445. * - VertexBuffer.MatricesIndicesKind
  33446. * - VertexBuffer.MatricesIndicesExtraKind
  33447. * - VertexBuffer.MatricesWeightsKind
  33448. * - VertexBuffer.MatricesWeightsExtraKind
  33449. */
  33450. removeVerticesData(kind: string): void;
  33451. /**
  33452. * Flags an associated vertex buffer as updatable
  33453. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  33454. * - VertexBuffer.PositionKind
  33455. * - VertexBuffer.UVKind
  33456. * - VertexBuffer.UV2Kind
  33457. * - VertexBuffer.UV3Kind
  33458. * - VertexBuffer.UV4Kind
  33459. * - VertexBuffer.UV5Kind
  33460. * - VertexBuffer.UV6Kind
  33461. * - VertexBuffer.ColorKind
  33462. * - VertexBuffer.MatricesIndicesKind
  33463. * - VertexBuffer.MatricesIndicesExtraKind
  33464. * - VertexBuffer.MatricesWeightsKind
  33465. * - VertexBuffer.MatricesWeightsExtraKind
  33466. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  33467. */
  33468. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  33469. /**
  33470. * Sets the mesh global Vertex Buffer
  33471. * @param buffer defines the buffer to use
  33472. * @returns the current mesh
  33473. */
  33474. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  33475. /**
  33476. * Update a specific associated vertex buffer
  33477. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  33478. * - VertexBuffer.PositionKind
  33479. * - VertexBuffer.UVKind
  33480. * - VertexBuffer.UV2Kind
  33481. * - VertexBuffer.UV3Kind
  33482. * - VertexBuffer.UV4Kind
  33483. * - VertexBuffer.UV5Kind
  33484. * - VertexBuffer.UV6Kind
  33485. * - VertexBuffer.ColorKind
  33486. * - VertexBuffer.MatricesIndicesKind
  33487. * - VertexBuffer.MatricesIndicesExtraKind
  33488. * - VertexBuffer.MatricesWeightsKind
  33489. * - VertexBuffer.MatricesWeightsExtraKind
  33490. * @param data defines the data source
  33491. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  33492. * @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)
  33493. * @returns the current mesh
  33494. */
  33495. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33496. /**
  33497. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  33498. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  33499. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  33500. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  33501. * @returns the current mesh
  33502. */
  33503. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  33504. /**
  33505. * Creates a un-shared specific occurence of the geometry for the mesh.
  33506. * @returns the current mesh
  33507. */
  33508. makeGeometryUnique(): Mesh;
  33509. /**
  33510. * Set the index buffer of this mesh
  33511. * @param indices defines the source data
  33512. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  33513. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  33514. * @returns the current mesh
  33515. */
  33516. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  33517. /**
  33518. * Update the current index buffer
  33519. * @param indices defines the source data
  33520. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33521. * @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)
  33522. * @returns the current mesh
  33523. */
  33524. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33525. /**
  33526. * Invert the geometry to move from a right handed system to a left handed one.
  33527. * @returns the current mesh
  33528. */
  33529. toLeftHanded(): Mesh;
  33530. /** @hidden */
  33531. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  33532. /** @hidden */
  33533. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  33534. /**
  33535. * Registers for this mesh a javascript function called just before the rendering process
  33536. * @param func defines the function to call before rendering this mesh
  33537. * @returns the current mesh
  33538. */
  33539. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33540. /**
  33541. * Disposes a previously registered javascript function called before the rendering
  33542. * @param func defines the function to remove
  33543. * @returns the current mesh
  33544. */
  33545. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  33546. /**
  33547. * Registers for this mesh a javascript function called just after the rendering is complete
  33548. * @param func defines the function to call after rendering this mesh
  33549. * @returns the current mesh
  33550. */
  33551. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33552. /**
  33553. * Disposes a previously registered javascript function called after the rendering.
  33554. * @param func defines the function to remove
  33555. * @returns the current mesh
  33556. */
  33557. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  33558. /** @hidden */
  33559. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  33560. /** @hidden */
  33561. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  33562. /** @hidden */
  33563. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  33564. /** @hidden */
  33565. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  33566. /** @hidden */
  33567. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  33568. /** @hidden */
  33569. _rebuild(): void;
  33570. /** @hidden */
  33571. _freeze(): void;
  33572. /** @hidden */
  33573. _unFreeze(): void;
  33574. /**
  33575. * 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
  33576. * @param subMesh defines the subMesh to render
  33577. * @param enableAlphaMode defines if alpha mode can be changed
  33578. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  33579. * @returns the current mesh
  33580. */
  33581. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  33582. private _onBeforeDraw;
  33583. /**
  33584. * Renormalize the mesh and patch it up if there are no weights
  33585. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  33586. * However in the case of zero weights then we set just a single influence to 1.
  33587. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  33588. */
  33589. cleanMatrixWeights(): void;
  33590. private normalizeSkinFourWeights;
  33591. private normalizeSkinWeightsAndExtra;
  33592. /**
  33593. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  33594. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  33595. * the user know there was an issue with importing the mesh
  33596. * @returns a validation object with skinned, valid and report string
  33597. */
  33598. validateSkinning(): {
  33599. skinned: boolean;
  33600. valid: boolean;
  33601. report: string;
  33602. };
  33603. /** @hidden */
  33604. _checkDelayState(): Mesh;
  33605. private _queueLoad;
  33606. /**
  33607. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33608. * A mesh is in the frustum if its bounding box intersects the frustum
  33609. * @param frustumPlanes defines the frustum to test
  33610. * @returns true if the mesh is in the frustum planes
  33611. */
  33612. isInFrustum(frustumPlanes: Plane[]): boolean;
  33613. /**
  33614. * Sets the mesh material by the material or multiMaterial `id` property
  33615. * @param id is a string identifying the material or the multiMaterial
  33616. * @returns the current mesh
  33617. */
  33618. setMaterialByID(id: string): Mesh;
  33619. /**
  33620. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  33621. * @returns an array of IAnimatable
  33622. */
  33623. getAnimatables(): IAnimatable[];
  33624. /**
  33625. * Modifies the mesh geometry according to the passed transformation matrix.
  33626. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33627. * The mesh normals are modified using the same transformation.
  33628. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33629. * @param transform defines the transform matrix to use
  33630. * @see https://doc.babylonjs.com/resources/baking_transformations
  33631. * @returns the current mesh
  33632. */
  33633. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33634. /**
  33635. * Modifies the mesh geometry according to its own current World Matrix.
  33636. * The mesh World Matrix is then reset.
  33637. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33638. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33639. * @see https://doc.babylonjs.com/resources/baking_transformations
  33640. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33641. * @returns the current mesh
  33642. */
  33643. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33644. /** @hidden */
  33645. get _positions(): Nullable<Vector3[]>;
  33646. /** @hidden */
  33647. _resetPointsArrayCache(): Mesh;
  33648. /** @hidden */
  33649. _generatePointsArray(): boolean;
  33650. /**
  33651. * Returns a new Mesh object generated from the current mesh properties.
  33652. * This method must not get confused with createInstance()
  33653. * @param name is a string, the name given to the new mesh
  33654. * @param newParent can be any Node object (default `null`)
  33655. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33656. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33657. * @returns a new mesh
  33658. */
  33659. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33660. /**
  33661. * Releases resources associated with this mesh.
  33662. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33663. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33664. */
  33665. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33666. /** @hidden */
  33667. _disposeInstanceSpecificData(): void;
  33668. /** @hidden */
  33669. _disposeThinInstanceSpecificData(): void;
  33670. /**
  33671. * Modifies the mesh geometry according to a displacement map.
  33672. * 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.
  33673. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33674. * @param url is a string, the URL from the image file is to be downloaded.
  33675. * @param minHeight is the lower limit of the displacement.
  33676. * @param maxHeight is the upper limit of the displacement.
  33677. * @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.
  33678. * @param uvOffset is an optional vector2 used to offset UV.
  33679. * @param uvScale is an optional vector2 used to scale UV.
  33680. * @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.
  33681. * @returns the Mesh.
  33682. */
  33683. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33684. /**
  33685. * Modifies the mesh geometry according to a displacementMap buffer.
  33686. * 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.
  33687. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33688. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33689. * @param heightMapWidth is the width of the buffer image.
  33690. * @param heightMapHeight is the height of the buffer image.
  33691. * @param minHeight is the lower limit of the displacement.
  33692. * @param maxHeight is the upper limit of the displacement.
  33693. * @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.
  33694. * @param uvOffset is an optional vector2 used to offset UV.
  33695. * @param uvScale is an optional vector2 used to scale UV.
  33696. * @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.
  33697. * @returns the Mesh.
  33698. */
  33699. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33700. /**
  33701. * Modify the mesh to get a flat shading rendering.
  33702. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33703. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33704. * @returns current mesh
  33705. */
  33706. convertToFlatShadedMesh(): Mesh;
  33707. /**
  33708. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33709. * In other words, more vertices, no more indices and a single bigger VBO.
  33710. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33711. * @returns current mesh
  33712. */
  33713. convertToUnIndexedMesh(): Mesh;
  33714. /**
  33715. * Inverses facet orientations.
  33716. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33717. * @param flipNormals will also inverts the normals
  33718. * @returns current mesh
  33719. */
  33720. flipFaces(flipNormals?: boolean): Mesh;
  33721. /**
  33722. * Increase the number of facets and hence vertices in a mesh
  33723. * Vertex normals are interpolated from existing vertex normals
  33724. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33725. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33726. */
  33727. increaseVertices(numberPerEdge: number): void;
  33728. /**
  33729. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33730. * This will undo any application of covertToFlatShadedMesh
  33731. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33732. */
  33733. forceSharedVertices(): void;
  33734. /** @hidden */
  33735. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33736. /** @hidden */
  33737. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33738. /**
  33739. * Creates a new InstancedMesh object from the mesh model.
  33740. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33741. * @param name defines the name of the new instance
  33742. * @returns a new InstancedMesh
  33743. */
  33744. createInstance(name: string): InstancedMesh;
  33745. /**
  33746. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33747. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33748. * @returns the current mesh
  33749. */
  33750. synchronizeInstances(): Mesh;
  33751. /**
  33752. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33753. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33754. * This should be used together with the simplification to avoid disappearing triangles.
  33755. * @param successCallback an optional success callback to be called after the optimization finished.
  33756. * @returns the current mesh
  33757. */
  33758. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33759. /**
  33760. * Serialize current mesh
  33761. * @param serializationObject defines the object which will receive the serialization data
  33762. */
  33763. serialize(serializationObject: any): void;
  33764. /** @hidden */
  33765. _syncGeometryWithMorphTargetManager(): void;
  33766. /** @hidden */
  33767. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33768. /**
  33769. * Returns a new Mesh object parsed from the source provided.
  33770. * @param parsedMesh is the source
  33771. * @param scene defines the hosting scene
  33772. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33773. * @returns a new Mesh
  33774. */
  33775. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33776. /**
  33777. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33778. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33779. * @param name defines the name of the mesh to create
  33780. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33781. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33782. * @param closePath creates a seam between the first and the last points of each path of the path array
  33783. * @param offset is taken in account only if the `pathArray` is containing a single path
  33784. * @param scene defines the hosting scene
  33785. * @param updatable defines if the mesh must be flagged as updatable
  33786. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33787. * @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)
  33788. * @returns a new Mesh
  33789. */
  33790. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33791. /**
  33792. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33793. * @param name defines the name of the mesh to create
  33794. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33795. * @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
  33796. * @param scene defines the hosting scene
  33797. * @param updatable defines if the mesh must be flagged as updatable
  33798. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33799. * @returns a new Mesh
  33800. */
  33801. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33802. /**
  33803. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33804. * @param name defines the name of the mesh to create
  33805. * @param size sets the size (float) of each box side (default 1)
  33806. * @param scene defines the hosting scene
  33807. * @param updatable defines if the mesh must be flagged as updatable
  33808. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33809. * @returns a new Mesh
  33810. */
  33811. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33812. /**
  33813. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33814. * @param name defines the name of the mesh to create
  33815. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33816. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33817. * @param scene defines the hosting scene
  33818. * @param updatable defines if the mesh must be flagged as updatable
  33819. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33820. * @returns a new Mesh
  33821. */
  33822. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33823. /**
  33824. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33825. * @param name defines the name of the mesh to create
  33826. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33827. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33828. * @param scene defines the hosting scene
  33829. * @returns a new Mesh
  33830. */
  33831. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33832. /**
  33833. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33834. * @param name defines the name of the mesh to create
  33835. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33836. * @param diameterTop set the top cap diameter (floats, default 1)
  33837. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33838. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33839. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33840. * @param scene defines the hosting scene
  33841. * @param updatable defines if the mesh must be flagged as updatable
  33842. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33843. * @returns a new Mesh
  33844. */
  33845. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33846. /**
  33847. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33848. * @param name defines the name of the mesh to create
  33849. * @param diameter sets the diameter size (float) of the torus (default 1)
  33850. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33851. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33852. * @param scene defines the hosting scene
  33853. * @param updatable defines if the mesh must be flagged as updatable
  33854. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33855. * @returns a new Mesh
  33856. */
  33857. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33858. /**
  33859. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33860. * @param name defines the name of the mesh to create
  33861. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33862. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33863. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33864. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33865. * @param p the number of windings on X axis (positive integers, default 2)
  33866. * @param q the number of windings on Y axis (positive integers, default 3)
  33867. * @param scene defines the hosting scene
  33868. * @param updatable defines if the mesh must be flagged as updatable
  33869. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33870. * @returns a new Mesh
  33871. */
  33872. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33873. /**
  33874. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33875. * @param name defines the name of the mesh to create
  33876. * @param points is an array successive Vector3
  33877. * @param scene defines the hosting scene
  33878. * @param updatable defines if the mesh must be flagged as updatable
  33879. * @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).
  33880. * @returns a new Mesh
  33881. */
  33882. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33883. /**
  33884. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33885. * @param name defines the name of the mesh to create
  33886. * @param points is an array successive Vector3
  33887. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33888. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33889. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33890. * @param scene defines the hosting scene
  33891. * @param updatable defines if the mesh must be flagged as updatable
  33892. * @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)
  33893. * @returns a new Mesh
  33894. */
  33895. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33896. /**
  33897. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33898. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33899. * 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.
  33900. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33901. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33902. * Remember you can only change the shape positions, not their number when updating a polygon.
  33903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33904. * @param name defines the name of the mesh to create
  33905. * @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
  33906. * @param scene defines the hosting scene
  33907. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33908. * @param updatable defines if the mesh must be flagged as updatable
  33909. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33910. * @param earcutInjection can be used to inject your own earcut reference
  33911. * @returns a new Mesh
  33912. */
  33913. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33914. /**
  33915. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33917. * @param name defines the name of the mesh to create
  33918. * @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
  33919. * @param depth defines the height of extrusion
  33920. * @param scene defines the hosting scene
  33921. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33922. * @param updatable defines if the mesh must be flagged as updatable
  33923. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33924. * @param earcutInjection can be used to inject your own earcut reference
  33925. * @returns a new Mesh
  33926. */
  33927. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33928. /**
  33929. * Creates an extruded shape mesh.
  33930. * 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
  33931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33933. * @param name defines the name of the mesh to create
  33934. * @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
  33935. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33936. * @param scale is the value to scale the shape
  33937. * @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
  33938. * @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
  33939. * @param scene defines the hosting scene
  33940. * @param updatable defines if the mesh must be flagged as updatable
  33941. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33942. * @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)
  33943. * @returns a new Mesh
  33944. */
  33945. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33946. /**
  33947. * Creates an custom extruded shape mesh.
  33948. * The custom extrusion is a parametric shape.
  33949. * It has no predefined shape. Its final shape will depend on the input parameters.
  33950. * Please consider using the same method from the MeshBuilder class instead
  33951. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33952. * @param name defines the name of the mesh to create
  33953. * @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
  33954. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33955. * @param scaleFunction is a custom Javascript function called on each path point
  33956. * @param rotationFunction is a custom Javascript function called on each path point
  33957. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33958. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33959. * @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
  33960. * @param scene defines the hosting scene
  33961. * @param updatable defines if the mesh must be flagged as updatable
  33962. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33963. * @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)
  33964. * @returns a new Mesh
  33965. */
  33966. 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;
  33967. /**
  33968. * Creates lathe mesh.
  33969. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33970. * Please consider using the same method from the MeshBuilder class instead
  33971. * @param name defines the name of the mesh to create
  33972. * @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
  33973. * @param radius is the radius value of the lathe
  33974. * @param tessellation is the side number of the lathe.
  33975. * @param scene defines the hosting scene
  33976. * @param updatable defines if the mesh must be flagged as updatable
  33977. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33978. * @returns a new Mesh
  33979. */
  33980. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33981. /**
  33982. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33983. * @param name defines the name of the mesh to create
  33984. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33985. * @param scene defines the hosting scene
  33986. * @param updatable defines if the mesh must be flagged as updatable
  33987. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33988. * @returns a new Mesh
  33989. */
  33990. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33991. /**
  33992. * Creates a ground mesh.
  33993. * Please consider using the same method from the MeshBuilder class instead
  33994. * @param name defines the name of the mesh to create
  33995. * @param width set the width of the ground
  33996. * @param height set the height of the ground
  33997. * @param subdivisions sets the number of subdivisions per side
  33998. * @param scene defines the hosting scene
  33999. * @param updatable defines if the mesh must be flagged as updatable
  34000. * @returns a new Mesh
  34001. */
  34002. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  34003. /**
  34004. * Creates a tiled ground mesh.
  34005. * Please consider using the same method from the MeshBuilder class instead
  34006. * @param name defines the name of the mesh to create
  34007. * @param xmin set the ground minimum X coordinate
  34008. * @param zmin set the ground minimum Y coordinate
  34009. * @param xmax set the ground maximum X coordinate
  34010. * @param zmax set the ground maximum Z coordinate
  34011. * @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
  34012. * @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
  34013. * @param scene defines the hosting scene
  34014. * @param updatable defines if the mesh must be flagged as updatable
  34015. * @returns a new Mesh
  34016. */
  34017. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  34018. w: number;
  34019. h: number;
  34020. }, precision: {
  34021. w: number;
  34022. h: number;
  34023. }, scene: Scene, updatable?: boolean): Mesh;
  34024. /**
  34025. * Creates a ground mesh from a height map.
  34026. * Please consider using the same method from the MeshBuilder class instead
  34027. * @see https://doc.babylonjs.com/babylon101/height_map
  34028. * @param name defines the name of the mesh to create
  34029. * @param url sets the URL of the height map image resource
  34030. * @param width set the ground width size
  34031. * @param height set the ground height size
  34032. * @param subdivisions sets the number of subdivision per side
  34033. * @param minHeight is the minimum altitude on the ground
  34034. * @param maxHeight is the maximum altitude on the ground
  34035. * @param scene defines the hosting scene
  34036. * @param updatable defines if the mesh must be flagged as updatable
  34037. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  34038. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  34039. * @returns a new Mesh
  34040. */
  34041. 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;
  34042. /**
  34043. * Creates a tube mesh.
  34044. * The tube is a parametric shape.
  34045. * It has no predefined shape. Its final shape will depend on the input parameters.
  34046. * Please consider using the same method from the MeshBuilder class instead
  34047. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34048. * @param name defines the name of the mesh to create
  34049. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  34050. * @param radius sets the tube radius size
  34051. * @param tessellation is the number of sides on the tubular surface
  34052. * @param radiusFunction is a custom function. If it is not null, it overwrittes 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
  34053. * @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
  34054. * @param scene defines the hosting scene
  34055. * @param updatable defines if the mesh must be flagged as updatable
  34056. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34057. * @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)
  34058. * @returns a new Mesh
  34059. */
  34060. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  34061. (i: number, distance: number): number;
  34062. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34063. /**
  34064. * Creates a polyhedron mesh.
  34065. * Please consider using the same method from the MeshBuilder class instead.
  34066. * * 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
  34067. * * The parameter `size` (positive float, default 1) sets the polygon size
  34068. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  34069. * * 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`
  34070. * * 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
  34071. * * 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)`)
  34072. * * 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
  34073. * * 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
  34074. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34075. * * 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
  34076. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34077. * @param name defines the name of the mesh to create
  34078. * @param options defines the options used to create the mesh
  34079. * @param scene defines the hosting scene
  34080. * @returns a new Mesh
  34081. */
  34082. static CreatePolyhedron(name: string, options: {
  34083. type?: number;
  34084. size?: number;
  34085. sizeX?: number;
  34086. sizeY?: number;
  34087. sizeZ?: number;
  34088. custom?: any;
  34089. faceUV?: Vector4[];
  34090. faceColors?: Color4[];
  34091. updatable?: boolean;
  34092. sideOrientation?: number;
  34093. }, scene: Scene): Mesh;
  34094. /**
  34095. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  34096. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  34097. * * 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`)
  34098. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  34099. * * 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
  34100. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34101. * * 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
  34102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34103. * @param name defines the name of the mesh
  34104. * @param options defines the options used to create the mesh
  34105. * @param scene defines the hosting scene
  34106. * @returns a new Mesh
  34107. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  34108. */
  34109. static CreateIcoSphere(name: string, options: {
  34110. radius?: number;
  34111. flat?: boolean;
  34112. subdivisions?: number;
  34113. sideOrientation?: number;
  34114. updatable?: boolean;
  34115. }, scene: Scene): Mesh;
  34116. /**
  34117. * Creates a decal mesh.
  34118. * Please consider using the same method from the MeshBuilder class instead.
  34119. * A decal is a mesh usually applied as a model onto the surface of another mesh
  34120. * @param name defines the name of the mesh
  34121. * @param sourceMesh defines the mesh receiving the decal
  34122. * @param position sets the position of the decal in world coordinates
  34123. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  34124. * @param size sets the decal scaling
  34125. * @param angle sets the angle to rotate the decal
  34126. * @returns a new Mesh
  34127. */
  34128. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  34129. /** Creates a Capsule Mesh
  34130. * @param name defines the name of the mesh.
  34131. * @param options the constructors options used to shape the mesh.
  34132. * @param scene defines the scene the mesh is scoped to.
  34133. * @returns the capsule mesh
  34134. * @see https://doc.babylonjs.com/how_to/capsule_shape
  34135. */
  34136. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  34137. /**
  34138. * Prepare internal position array for software CPU skinning
  34139. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  34140. */
  34141. setPositionsForCPUSkinning(): Float32Array;
  34142. /**
  34143. * Prepare internal normal array for software CPU skinning
  34144. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  34145. */
  34146. setNormalsForCPUSkinning(): Float32Array;
  34147. /**
  34148. * Updates the vertex buffer by applying transformation from the bones
  34149. * @param skeleton defines the skeleton to apply to current mesh
  34150. * @returns the current mesh
  34151. */
  34152. applySkeleton(skeleton: Skeleton): Mesh;
  34153. /**
  34154. * 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
  34155. * @param meshes defines the list of meshes to scan
  34156. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  34157. */
  34158. static MinMax(meshes: AbstractMesh[]): {
  34159. min: Vector3;
  34160. max: Vector3;
  34161. };
  34162. /**
  34163. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  34164. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  34165. * @returns a vector3
  34166. */
  34167. static Center(meshesOrMinMaxVector: {
  34168. min: Vector3;
  34169. max: Vector3;
  34170. } | AbstractMesh[]): Vector3;
  34171. /**
  34172. * Merge the array of meshes into a single mesh for performance reasons.
  34173. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  34174. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  34175. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  34176. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  34177. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  34178. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  34179. * @returns a new mesh
  34180. */
  34181. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  34182. /** @hidden */
  34183. addInstance(instance: InstancedMesh): void;
  34184. /** @hidden */
  34185. removeInstance(instance: InstancedMesh): void;
  34186. }
  34187. }
  34188. declare module BABYLON {
  34189. /**
  34190. * The options Interface for creating a Capsule Mesh
  34191. */
  34192. export interface ICreateCapsuleOptions {
  34193. /** The Orientation of the capsule. Default : Vector3.Up() */
  34194. orientation?: Vector3;
  34195. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  34196. subdivisions: number;
  34197. /** Number of cylindrical segments on the capsule. */
  34198. tessellation: number;
  34199. /** Height or Length of the capsule. */
  34200. height: number;
  34201. /** Radius of the capsule. */
  34202. radius: number;
  34203. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  34204. capSubdivisions: number;
  34205. /** Overwrite for the top radius. */
  34206. radiusTop?: number;
  34207. /** Overwrite for the bottom radius. */
  34208. radiusBottom?: number;
  34209. /** Overwrite for the top capSubdivisions. */
  34210. topCapSubdivisions?: number;
  34211. /** Overwrite for the bottom capSubdivisions. */
  34212. bottomCapSubdivisions?: number;
  34213. }
  34214. /**
  34215. * Class containing static functions to help procedurally build meshes
  34216. */
  34217. export class CapsuleBuilder {
  34218. /**
  34219. * Creates a capsule or a pill mesh
  34220. * @param name defines the name of the mesh
  34221. * @param options The constructors options.
  34222. * @param scene The scene the mesh is scoped to.
  34223. * @returns Capsule Mesh
  34224. */
  34225. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  34226. }
  34227. }
  34228. declare module BABYLON {
  34229. /**
  34230. * Define an interface for all classes that will get and set the data on vertices
  34231. */
  34232. export interface IGetSetVerticesData {
  34233. /**
  34234. * Gets a boolean indicating if specific vertex data is present
  34235. * @param kind defines the vertex data kind to use
  34236. * @returns true is data kind is present
  34237. */
  34238. isVerticesDataPresent(kind: string): boolean;
  34239. /**
  34240. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  34241. * @param kind defines the data kind (Position, normal, etc...)
  34242. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  34243. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34244. * @returns a float array containing vertex data
  34245. */
  34246. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34247. /**
  34248. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34249. * @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.
  34250. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34251. * @returns the indices array or an empty array if the mesh has no geometry
  34252. */
  34253. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34254. /**
  34255. * Set specific vertex data
  34256. * @param kind defines the data kind (Position, normal, etc...)
  34257. * @param data defines the vertex data to use
  34258. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  34259. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  34260. */
  34261. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  34262. /**
  34263. * Update a specific associated vertex buffer
  34264. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34265. * - VertexBuffer.PositionKind
  34266. * - VertexBuffer.UVKind
  34267. * - VertexBuffer.UV2Kind
  34268. * - VertexBuffer.UV3Kind
  34269. * - VertexBuffer.UV4Kind
  34270. * - VertexBuffer.UV5Kind
  34271. * - VertexBuffer.UV6Kind
  34272. * - VertexBuffer.ColorKind
  34273. * - VertexBuffer.MatricesIndicesKind
  34274. * - VertexBuffer.MatricesIndicesExtraKind
  34275. * - VertexBuffer.MatricesWeightsKind
  34276. * - VertexBuffer.MatricesWeightsExtraKind
  34277. * @param data defines the data source
  34278. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34279. * @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)
  34280. */
  34281. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  34282. /**
  34283. * Creates a new index buffer
  34284. * @param indices defines the indices to store in the index buffer
  34285. * @param totalVertices defines the total number of vertices (could be null)
  34286. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  34287. */
  34288. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  34289. }
  34290. /**
  34291. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  34292. */
  34293. export class VertexData {
  34294. /**
  34295. * Mesh side orientation : usually the external or front surface
  34296. */
  34297. static readonly FRONTSIDE: number;
  34298. /**
  34299. * Mesh side orientation : usually the internal or back surface
  34300. */
  34301. static readonly BACKSIDE: number;
  34302. /**
  34303. * Mesh side orientation : both internal and external or front and back surfaces
  34304. */
  34305. static readonly DOUBLESIDE: number;
  34306. /**
  34307. * Mesh side orientation : by default, `FRONTSIDE`
  34308. */
  34309. static readonly DEFAULTSIDE: number;
  34310. /**
  34311. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  34312. */
  34313. positions: Nullable<FloatArray>;
  34314. /**
  34315. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  34316. */
  34317. normals: Nullable<FloatArray>;
  34318. /**
  34319. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  34320. */
  34321. tangents: Nullable<FloatArray>;
  34322. /**
  34323. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34324. */
  34325. uvs: Nullable<FloatArray>;
  34326. /**
  34327. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34328. */
  34329. uvs2: Nullable<FloatArray>;
  34330. /**
  34331. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34332. */
  34333. uvs3: Nullable<FloatArray>;
  34334. /**
  34335. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34336. */
  34337. uvs4: Nullable<FloatArray>;
  34338. /**
  34339. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34340. */
  34341. uvs5: Nullable<FloatArray>;
  34342. /**
  34343. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  34344. */
  34345. uvs6: Nullable<FloatArray>;
  34346. /**
  34347. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  34348. */
  34349. colors: Nullable<FloatArray>;
  34350. /**
  34351. * 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).
  34352. */
  34353. matricesIndices: Nullable<FloatArray>;
  34354. /**
  34355. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  34356. */
  34357. matricesWeights: Nullable<FloatArray>;
  34358. /**
  34359. * An array extending the number of possible indices
  34360. */
  34361. matricesIndicesExtra: Nullable<FloatArray>;
  34362. /**
  34363. * An array extending the number of possible weights when the number of indices is extended
  34364. */
  34365. matricesWeightsExtra: Nullable<FloatArray>;
  34366. /**
  34367. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  34368. */
  34369. indices: Nullable<IndicesArray>;
  34370. /**
  34371. * Uses the passed data array to set the set the values for the specified kind of data
  34372. * @param data a linear array of floating numbers
  34373. * @param kind the type of data that is being set, eg positions, colors etc
  34374. */
  34375. set(data: FloatArray, kind: string): void;
  34376. /**
  34377. * Associates the vertexData to the passed Mesh.
  34378. * Sets it as updatable or not (default `false`)
  34379. * @param mesh the mesh the vertexData is applied to
  34380. * @param updatable when used and having the value true allows new data to update the vertexData
  34381. * @returns the VertexData
  34382. */
  34383. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  34384. /**
  34385. * Associates the vertexData to the passed Geometry.
  34386. * Sets it as updatable or not (default `false`)
  34387. * @param geometry the geometry the vertexData is applied to
  34388. * @param updatable when used and having the value true allows new data to update the vertexData
  34389. * @returns VertexData
  34390. */
  34391. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  34392. /**
  34393. * Updates the associated mesh
  34394. * @param mesh the mesh to be updated
  34395. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34396. * @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
  34397. * @returns VertexData
  34398. */
  34399. updateMesh(mesh: Mesh): VertexData;
  34400. /**
  34401. * Updates the associated geometry
  34402. * @param geometry the geometry to be updated
  34403. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  34404. * @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
  34405. * @returns VertexData.
  34406. */
  34407. updateGeometry(geometry: Geometry): VertexData;
  34408. private _applyTo;
  34409. private _update;
  34410. /**
  34411. * Transforms each position and each normal of the vertexData according to the passed Matrix
  34412. * @param matrix the transforming matrix
  34413. * @returns the VertexData
  34414. */
  34415. transform(matrix: Matrix): VertexData;
  34416. /**
  34417. * Merges the passed VertexData into the current one
  34418. * @param other the VertexData to be merged into the current one
  34419. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  34420. * @returns the modified VertexData
  34421. */
  34422. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  34423. private _mergeElement;
  34424. private _validate;
  34425. /**
  34426. * Serializes the VertexData
  34427. * @returns a serialized object
  34428. */
  34429. serialize(): any;
  34430. /**
  34431. * Extracts the vertexData from a mesh
  34432. * @param mesh the mesh from which to extract the VertexData
  34433. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  34434. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34435. * @returns the object VertexData associated to the passed mesh
  34436. */
  34437. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34438. /**
  34439. * Extracts the vertexData from the geometry
  34440. * @param geometry the geometry from which to extract the VertexData
  34441. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  34442. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  34443. * @returns the object VertexData associated to the passed mesh
  34444. */
  34445. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  34446. private static _ExtractFrom;
  34447. /**
  34448. * Creates the VertexData for a Ribbon
  34449. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  34450. * * pathArray array of paths, each of which an array of successive Vector3
  34451. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  34452. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  34453. * * 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
  34454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34455. * * 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)
  34456. * * 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)
  34457. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  34458. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  34459. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  34460. * @returns the VertexData of the ribbon
  34461. */
  34462. static CreateRibbon(options: {
  34463. pathArray: Vector3[][];
  34464. closeArray?: boolean;
  34465. closePath?: boolean;
  34466. offset?: number;
  34467. sideOrientation?: number;
  34468. frontUVs?: Vector4;
  34469. backUVs?: Vector4;
  34470. invertUV?: boolean;
  34471. uvs?: Vector2[];
  34472. colors?: Color4[];
  34473. }): VertexData;
  34474. /**
  34475. * Creates the VertexData for a box
  34476. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34477. * * size sets the width, height and depth of the box to the value of size, optional default 1
  34478. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  34479. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  34480. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  34481. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34482. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34484. * * 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)
  34485. * * 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)
  34486. * @returns the VertexData of the box
  34487. */
  34488. static CreateBox(options: {
  34489. size?: number;
  34490. width?: number;
  34491. height?: number;
  34492. depth?: number;
  34493. faceUV?: Vector4[];
  34494. faceColors?: Color4[];
  34495. sideOrientation?: number;
  34496. frontUVs?: Vector4;
  34497. backUVs?: Vector4;
  34498. }): VertexData;
  34499. /**
  34500. * Creates the VertexData for a tiled box
  34501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34502. * * faceTiles sets the pattern, tile size and number of tiles for a face
  34503. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  34504. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  34505. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34506. * @returns the VertexData of the box
  34507. */
  34508. static CreateTiledBox(options: {
  34509. pattern?: number;
  34510. width?: number;
  34511. height?: number;
  34512. depth?: number;
  34513. tileSize?: number;
  34514. tileWidth?: number;
  34515. tileHeight?: number;
  34516. alignHorizontal?: number;
  34517. alignVertical?: number;
  34518. faceUV?: Vector4[];
  34519. faceColors?: Color4[];
  34520. sideOrientation?: number;
  34521. }): VertexData;
  34522. /**
  34523. * Creates the VertexData for a tiled plane
  34524. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34525. * * pattern a limited pattern arrangement depending on the number
  34526. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  34527. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  34528. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  34529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34530. * * 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)
  34531. * * 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)
  34532. * @returns the VertexData of the tiled plane
  34533. */
  34534. static CreateTiledPlane(options: {
  34535. pattern?: number;
  34536. tileSize?: number;
  34537. tileWidth?: number;
  34538. tileHeight?: number;
  34539. size?: number;
  34540. width?: number;
  34541. height?: number;
  34542. alignHorizontal?: number;
  34543. alignVertical?: number;
  34544. sideOrientation?: number;
  34545. frontUVs?: Vector4;
  34546. backUVs?: Vector4;
  34547. }): VertexData;
  34548. /**
  34549. * Creates the VertexData for an ellipsoid, defaults to a sphere
  34550. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34551. * * segments sets the number of horizontal strips optional, default 32
  34552. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  34553. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  34554. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  34555. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  34556. * * 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
  34557. * * 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
  34558. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34559. * * 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)
  34560. * * 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)
  34561. * @returns the VertexData of the ellipsoid
  34562. */
  34563. static CreateSphere(options: {
  34564. segments?: number;
  34565. diameter?: number;
  34566. diameterX?: number;
  34567. diameterY?: number;
  34568. diameterZ?: number;
  34569. arc?: number;
  34570. slice?: number;
  34571. sideOrientation?: number;
  34572. frontUVs?: Vector4;
  34573. backUVs?: Vector4;
  34574. }): VertexData;
  34575. /**
  34576. * Creates the VertexData for a cylinder, cone or prism
  34577. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34578. * * height sets the height (y direction) of the cylinder, optional, default 2
  34579. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  34580. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  34581. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  34582. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34583. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  34584. * * 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
  34585. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34586. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34587. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  34588. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  34589. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34590. * * 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)
  34591. * * 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)
  34592. * @returns the VertexData of the cylinder, cone or prism
  34593. */
  34594. static CreateCylinder(options: {
  34595. height?: number;
  34596. diameterTop?: number;
  34597. diameterBottom?: number;
  34598. diameter?: number;
  34599. tessellation?: number;
  34600. subdivisions?: number;
  34601. arc?: number;
  34602. faceColors?: Color4[];
  34603. faceUV?: Vector4[];
  34604. hasRings?: boolean;
  34605. enclose?: boolean;
  34606. sideOrientation?: number;
  34607. frontUVs?: Vector4;
  34608. backUVs?: Vector4;
  34609. }): VertexData;
  34610. /**
  34611. * Creates the VertexData for a torus
  34612. * @param options an object used to set the following optional parameters for the box, required but can be empty
  34613. * * diameter the diameter of the torus, optional default 1
  34614. * * thickness the diameter of the tube forming the torus, optional default 0.5
  34615. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  34616. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34617. * * 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)
  34618. * * 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)
  34619. * @returns the VertexData of the torus
  34620. */
  34621. static CreateTorus(options: {
  34622. diameter?: number;
  34623. thickness?: number;
  34624. tessellation?: number;
  34625. sideOrientation?: number;
  34626. frontUVs?: Vector4;
  34627. backUVs?: Vector4;
  34628. }): VertexData;
  34629. /**
  34630. * Creates the VertexData of the LineSystem
  34631. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  34632. * - lines an array of lines, each line being an array of successive Vector3
  34633. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  34634. * @returns the VertexData of the LineSystem
  34635. */
  34636. static CreateLineSystem(options: {
  34637. lines: Vector3[][];
  34638. colors?: Nullable<Color4[][]>;
  34639. }): VertexData;
  34640. /**
  34641. * Create the VertexData for a DashedLines
  34642. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  34643. * - points an array successive Vector3
  34644. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  34645. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  34646. * - dashNb the intended total number of dashes, optional, default 200
  34647. * @returns the VertexData for the DashedLines
  34648. */
  34649. static CreateDashedLines(options: {
  34650. points: Vector3[];
  34651. dashSize?: number;
  34652. gapSize?: number;
  34653. dashNb?: number;
  34654. }): VertexData;
  34655. /**
  34656. * Creates the VertexData for a Ground
  34657. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34658. * - width the width (x direction) of the ground, optional, default 1
  34659. * - height the height (z direction) of the ground, optional, default 1
  34660. * - subdivisions the number of subdivisions per side, optional, default 1
  34661. * @returns the VertexData of the Ground
  34662. */
  34663. static CreateGround(options: {
  34664. width?: number;
  34665. height?: number;
  34666. subdivisions?: number;
  34667. subdivisionsX?: number;
  34668. subdivisionsY?: number;
  34669. }): VertexData;
  34670. /**
  34671. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  34672. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  34673. * * xmin the ground minimum X coordinate, optional, default -1
  34674. * * zmin the ground minimum Z coordinate, optional, default -1
  34675. * * xmax the ground maximum X coordinate, optional, default 1
  34676. * * zmax the ground maximum Z coordinate, optional, default 1
  34677. * * 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}
  34678. * * 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}
  34679. * @returns the VertexData of the TiledGround
  34680. */
  34681. static CreateTiledGround(options: {
  34682. xmin: number;
  34683. zmin: number;
  34684. xmax: number;
  34685. zmax: number;
  34686. subdivisions?: {
  34687. w: number;
  34688. h: number;
  34689. };
  34690. precision?: {
  34691. w: number;
  34692. h: number;
  34693. };
  34694. }): VertexData;
  34695. /**
  34696. * Creates the VertexData of the Ground designed from a heightmap
  34697. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  34698. * * width the width (x direction) of the ground
  34699. * * height the height (z direction) of the ground
  34700. * * subdivisions the number of subdivisions per side
  34701. * * minHeight the minimum altitude on the ground, optional, default 0
  34702. * * maxHeight the maximum altitude on the ground, optional default 1
  34703. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  34704. * * buffer the array holding the image color data
  34705. * * bufferWidth the width of image
  34706. * * bufferHeight the height of image
  34707. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  34708. * @returns the VertexData of the Ground designed from a heightmap
  34709. */
  34710. static CreateGroundFromHeightMap(options: {
  34711. width: number;
  34712. height: number;
  34713. subdivisions: number;
  34714. minHeight: number;
  34715. maxHeight: number;
  34716. colorFilter: Color3;
  34717. buffer: Uint8Array;
  34718. bufferWidth: number;
  34719. bufferHeight: number;
  34720. alphaFilter: number;
  34721. }): VertexData;
  34722. /**
  34723. * Creates the VertexData for a Plane
  34724. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  34725. * * size sets the width and height of the plane to the value of size, optional default 1
  34726. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  34727. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  34728. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34729. * * 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)
  34730. * * 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)
  34731. * @returns the VertexData of the box
  34732. */
  34733. static CreatePlane(options: {
  34734. size?: number;
  34735. width?: number;
  34736. height?: number;
  34737. sideOrientation?: number;
  34738. frontUVs?: Vector4;
  34739. backUVs?: Vector4;
  34740. }): VertexData;
  34741. /**
  34742. * Creates the VertexData of the Disc or regular Polygon
  34743. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  34744. * * radius the radius of the disc, optional default 0.5
  34745. * * tessellation the number of polygon sides, optional, default 64
  34746. * * 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
  34747. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34748. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  34749. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  34750. * @returns the VertexData of the box
  34751. */
  34752. static CreateDisc(options: {
  34753. radius?: number;
  34754. tessellation?: number;
  34755. arc?: number;
  34756. sideOrientation?: number;
  34757. frontUVs?: Vector4;
  34758. backUVs?: Vector4;
  34759. }): VertexData;
  34760. /**
  34761. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  34762. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  34763. * @param polygon a mesh built from polygonTriangulation.build()
  34764. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34765. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34766. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34767. * @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)
  34768. * @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)
  34769. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  34770. * @returns the VertexData of the Polygon
  34771. */
  34772. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  34773. /**
  34774. * Creates the VertexData of the IcoSphere
  34775. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  34776. * * radius the radius of the IcoSphere, optional default 1
  34777. * * radiusX allows stretching in the x direction, optional, default radius
  34778. * * radiusY allows stretching in the y direction, optional, default radius
  34779. * * radiusZ allows stretching in the z direction, optional, default radius
  34780. * * flat when true creates a flat shaded mesh, optional, default true
  34781. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34782. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34783. * * 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)
  34784. * * 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)
  34785. * @returns the VertexData of the IcoSphere
  34786. */
  34787. static CreateIcoSphere(options: {
  34788. radius?: number;
  34789. radiusX?: number;
  34790. radiusY?: number;
  34791. radiusZ?: number;
  34792. flat?: boolean;
  34793. subdivisions?: number;
  34794. sideOrientation?: number;
  34795. frontUVs?: Vector4;
  34796. backUVs?: Vector4;
  34797. }): VertexData;
  34798. /**
  34799. * Creates the VertexData for a Polyhedron
  34800. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  34801. * * type provided types are:
  34802. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  34803. * * 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)
  34804. * * size the size of the IcoSphere, optional default 1
  34805. * * sizeX allows stretching in the x direction, optional, default size
  34806. * * sizeY allows stretching in the y direction, optional, default size
  34807. * * sizeZ allows stretching in the z direction, optional, default size
  34808. * * 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
  34809. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  34810. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  34811. * * flat when true creates a flat shaded mesh, optional, default true
  34812. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  34813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34814. * * 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)
  34815. * * 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)
  34816. * @returns the VertexData of the Polyhedron
  34817. */
  34818. static CreatePolyhedron(options: {
  34819. type?: number;
  34820. size?: number;
  34821. sizeX?: number;
  34822. sizeY?: number;
  34823. sizeZ?: number;
  34824. custom?: any;
  34825. faceUV?: Vector4[];
  34826. faceColors?: Color4[];
  34827. flat?: boolean;
  34828. sideOrientation?: number;
  34829. frontUVs?: Vector4;
  34830. backUVs?: Vector4;
  34831. }): VertexData;
  34832. /**
  34833. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  34834. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  34835. * @returns the VertexData of the Capsule
  34836. */
  34837. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  34838. /**
  34839. * Creates the VertexData for a TorusKnot
  34840. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  34841. * * radius the radius of the torus knot, optional, default 2
  34842. * * tube the thickness of the tube, optional, default 0.5
  34843. * * radialSegments the number of sides on each tube segments, optional, default 32
  34844. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  34845. * * p the number of windings around the z axis, optional, default 2
  34846. * * q the number of windings around the x axis, optional, default 3
  34847. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34848. * * 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)
  34849. * * 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)
  34850. * @returns the VertexData of the Torus Knot
  34851. */
  34852. static CreateTorusKnot(options: {
  34853. radius?: number;
  34854. tube?: number;
  34855. radialSegments?: number;
  34856. tubularSegments?: number;
  34857. p?: number;
  34858. q?: number;
  34859. sideOrientation?: number;
  34860. frontUVs?: Vector4;
  34861. backUVs?: Vector4;
  34862. }): VertexData;
  34863. /**
  34864. * Compute normals for given positions and indices
  34865. * @param positions an array of vertex positions, [...., x, y, z, ......]
  34866. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  34867. * @param normals an array of vertex normals, [...., x, y, z, ......]
  34868. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  34869. * * facetNormals : optional array of facet normals (vector3)
  34870. * * facetPositions : optional array of facet positions (vector3)
  34871. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  34872. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  34873. * * bInfo : optional bounding info, required for facetPartitioning computation
  34874. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  34875. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  34876. * * useRightHandedSystem: optional boolean to for right handed system computation
  34877. * * depthSort : optional boolean to enable the facet depth sort computation
  34878. * * distanceTo : optional Vector3 to compute the facet depth from this location
  34879. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  34880. */
  34881. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  34882. facetNormals?: any;
  34883. facetPositions?: any;
  34884. facetPartitioning?: any;
  34885. ratio?: number;
  34886. bInfo?: any;
  34887. bbSize?: Vector3;
  34888. subDiv?: any;
  34889. useRightHandedSystem?: boolean;
  34890. depthSort?: boolean;
  34891. distanceTo?: Vector3;
  34892. depthSortedFacets?: any;
  34893. }): void;
  34894. /** @hidden */
  34895. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  34896. /**
  34897. * Applies VertexData created from the imported parameters to the geometry
  34898. * @param parsedVertexData the parsed data from an imported file
  34899. * @param geometry the geometry to apply the VertexData to
  34900. */
  34901. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  34902. }
  34903. }
  34904. declare module BABYLON {
  34905. /**
  34906. * Class containing static functions to help procedurally build meshes
  34907. */
  34908. export class DiscBuilder {
  34909. /**
  34910. * Creates a plane polygonal mesh. By default, this is a disc
  34911. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34912. * * 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
  34913. * * 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
  34914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34915. * * 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
  34916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34917. * @param name defines the name of the mesh
  34918. * @param options defines the options used to create the mesh
  34919. * @param scene defines the hosting scene
  34920. * @returns the plane polygonal mesh
  34921. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34922. */
  34923. static CreateDisc(name: string, options: {
  34924. radius?: number;
  34925. tessellation?: number;
  34926. arc?: number;
  34927. updatable?: boolean;
  34928. sideOrientation?: number;
  34929. frontUVs?: Vector4;
  34930. backUVs?: Vector4;
  34931. }, scene?: Nullable<Scene>): Mesh;
  34932. }
  34933. }
  34934. declare module BABYLON {
  34935. /**
  34936. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34937. *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.
  34938. * The SPS is also a particle system. It provides some methods to manage the particles.
  34939. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34940. *
  34941. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34942. */
  34943. export class SolidParticleSystem implements IDisposable {
  34944. /**
  34945. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34946. * Example : var p = SPS.particles[i];
  34947. */
  34948. particles: SolidParticle[];
  34949. /**
  34950. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34951. */
  34952. nbParticles: number;
  34953. /**
  34954. * If the particles must ever face the camera (default false). Useful for planar particles.
  34955. */
  34956. billboard: boolean;
  34957. /**
  34958. * Recompute normals when adding a shape
  34959. */
  34960. recomputeNormals: boolean;
  34961. /**
  34962. * This a counter ofr your own usage. It's not set by any SPS functions.
  34963. */
  34964. counter: number;
  34965. /**
  34966. * The SPS name. This name is also given to the underlying mesh.
  34967. */
  34968. name: string;
  34969. /**
  34970. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34971. */
  34972. mesh: Mesh;
  34973. /**
  34974. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34975. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34976. */
  34977. vars: any;
  34978. /**
  34979. * This array is populated when the SPS is set as 'pickable'.
  34980. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34981. * Each element of this array is an object `{idx: int, faceId: int}`.
  34982. * `idx` is the picked particle index in the `SPS.particles` array
  34983. * `faceId` is the picked face index counted within this particle.
  34984. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34985. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34986. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34987. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34988. */
  34989. pickedParticles: {
  34990. idx: number;
  34991. faceId: number;
  34992. }[];
  34993. /**
  34994. * This array is populated when the SPS is set as 'pickable'
  34995. * Each key of this array is a submesh index.
  34996. * Each element of this array is a second array defined like this :
  34997. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34998. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34999. * `idx` is the picked particle index in the `SPS.particles` array
  35000. * `faceId` is the picked face index counted within this particle.
  35001. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35002. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35003. */
  35004. pickedBySubMesh: {
  35005. idx: number;
  35006. faceId: number;
  35007. }[][];
  35008. /**
  35009. * This array is populated when `enableDepthSort` is set to true.
  35010. * Each element of this array is an instance of the class DepthSortedParticle.
  35011. */
  35012. depthSortedParticles: DepthSortedParticle[];
  35013. /**
  35014. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35015. * @hidden
  35016. */
  35017. _bSphereOnly: boolean;
  35018. /**
  35019. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35020. * @hidden
  35021. */
  35022. _bSphereRadiusFactor: number;
  35023. private _scene;
  35024. private _positions;
  35025. private _indices;
  35026. private _normals;
  35027. private _colors;
  35028. private _uvs;
  35029. private _indices32;
  35030. private _positions32;
  35031. private _normals32;
  35032. private _fixedNormal32;
  35033. private _colors32;
  35034. private _uvs32;
  35035. private _index;
  35036. private _updatable;
  35037. private _pickable;
  35038. private _isVisibilityBoxLocked;
  35039. private _alwaysVisible;
  35040. private _depthSort;
  35041. private _expandable;
  35042. private _shapeCounter;
  35043. private _copy;
  35044. private _color;
  35045. private _computeParticleColor;
  35046. private _computeParticleTexture;
  35047. private _computeParticleRotation;
  35048. private _computeParticleVertex;
  35049. private _computeBoundingBox;
  35050. private _depthSortParticles;
  35051. private _camera;
  35052. private _mustUnrotateFixedNormals;
  35053. private _particlesIntersect;
  35054. private _needs32Bits;
  35055. private _isNotBuilt;
  35056. private _lastParticleId;
  35057. private _idxOfId;
  35058. private _multimaterialEnabled;
  35059. private _useModelMaterial;
  35060. private _indicesByMaterial;
  35061. private _materialIndexes;
  35062. private _depthSortFunction;
  35063. private _materialSortFunction;
  35064. private _materials;
  35065. private _multimaterial;
  35066. private _materialIndexesById;
  35067. private _defaultMaterial;
  35068. private _autoUpdateSubMeshes;
  35069. private _tmpVertex;
  35070. /**
  35071. * Creates a SPS (Solid Particle System) object.
  35072. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35073. * @param scene (Scene) is the scene in which the SPS is added.
  35074. * @param options defines the options of the sps e.g.
  35075. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35076. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35077. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35078. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  35079. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35080. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35081. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35082. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35083. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35084. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35085. */
  35086. constructor(name: string, scene: Scene, options?: {
  35087. updatable?: boolean;
  35088. isPickable?: boolean;
  35089. enableDepthSort?: boolean;
  35090. particleIntersection?: boolean;
  35091. boundingSphereOnly?: boolean;
  35092. bSphereRadiusFactor?: number;
  35093. expandable?: boolean;
  35094. useModelMaterial?: boolean;
  35095. enableMultiMaterial?: boolean;
  35096. });
  35097. /**
  35098. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35099. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35100. * @returns the created mesh
  35101. */
  35102. buildMesh(): Mesh;
  35103. /**
  35104. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35105. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35106. * Thus the particles generated from `digest()` have their property `position` set yet.
  35107. * @param mesh ( Mesh ) is the mesh to be digested
  35108. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  35109. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35110. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35111. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35112. * @returns the current SPS
  35113. */
  35114. digest(mesh: Mesh, options?: {
  35115. facetNb?: number;
  35116. number?: number;
  35117. delta?: number;
  35118. storage?: [];
  35119. }): SolidParticleSystem;
  35120. /**
  35121. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35122. * @hidden
  35123. */
  35124. private _unrotateFixedNormals;
  35125. /**
  35126. * Resets the temporary working copy particle
  35127. * @hidden
  35128. */
  35129. private _resetCopy;
  35130. /**
  35131. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  35132. * @param p the current index in the positions array to be updated
  35133. * @param ind the current index in the indices array
  35134. * @param shape a Vector3 array, the shape geometry
  35135. * @param positions the positions array to be updated
  35136. * @param meshInd the shape indices array
  35137. * @param indices the indices array to be updated
  35138. * @param meshUV the shape uv array
  35139. * @param uvs the uv array to be updated
  35140. * @param meshCol the shape color array
  35141. * @param colors the color array to be updated
  35142. * @param meshNor the shape normals array
  35143. * @param normals the normals array to be updated
  35144. * @param idx the particle index
  35145. * @param idxInShape the particle index in its shape
  35146. * @param options the addShape() method passed options
  35147. * @model the particle model
  35148. * @hidden
  35149. */
  35150. private _meshBuilder;
  35151. /**
  35152. * Returns a shape Vector3 array from positions float array
  35153. * @param positions float array
  35154. * @returns a vector3 array
  35155. * @hidden
  35156. */
  35157. private _posToShape;
  35158. /**
  35159. * Returns a shapeUV array from a float uvs (array deep copy)
  35160. * @param uvs as a float array
  35161. * @returns a shapeUV array
  35162. * @hidden
  35163. */
  35164. private _uvsToShapeUV;
  35165. /**
  35166. * Adds a new particle object in the particles array
  35167. * @param idx particle index in particles array
  35168. * @param id particle id
  35169. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  35170. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  35171. * @param model particle ModelShape object
  35172. * @param shapeId model shape identifier
  35173. * @param idxInShape index of the particle in the current model
  35174. * @param bInfo model bounding info object
  35175. * @param storage target storage array, if any
  35176. * @hidden
  35177. */
  35178. private _addParticle;
  35179. /**
  35180. * Adds some particles to the SPS from the model shape. Returns the shape id.
  35181. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  35182. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  35183. * @param nb (positive integer) the number of particles to be created from this model
  35184. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  35185. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  35186. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35187. * @returns the number of shapes in the system
  35188. */
  35189. addShape(mesh: Mesh, nb: number, options?: {
  35190. positionFunction?: any;
  35191. vertexFunction?: any;
  35192. storage?: [];
  35193. }): number;
  35194. /**
  35195. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  35196. * @hidden
  35197. */
  35198. private _rebuildParticle;
  35199. /**
  35200. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  35201. * @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.
  35202. * @returns the SPS.
  35203. */
  35204. rebuildMesh(reset?: boolean): SolidParticleSystem;
  35205. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  35206. * Returns an array with the removed particles.
  35207. * 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.
  35208. * The SPS can't be empty so at least one particle needs to remain in place.
  35209. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  35210. * @param start index of the first particle to remove
  35211. * @param end index of the last particle to remove (included)
  35212. * @returns an array populated with the removed particles
  35213. */
  35214. removeParticles(start: number, end: number): SolidParticle[];
  35215. /**
  35216. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  35217. * @param solidParticleArray an array populated with Solid Particles objects
  35218. * @returns the SPS
  35219. */
  35220. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  35221. /**
  35222. * Creates a new particle and modifies the SPS mesh geometry :
  35223. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  35224. * - calls _addParticle() to populate the particle array
  35225. * factorized code from addShape() and insertParticlesFromArray()
  35226. * @param idx particle index in the particles array
  35227. * @param i particle index in its shape
  35228. * @param modelShape particle ModelShape object
  35229. * @param shape shape vertex array
  35230. * @param meshInd shape indices array
  35231. * @param meshUV shape uv array
  35232. * @param meshCol shape color array
  35233. * @param meshNor shape normals array
  35234. * @param bbInfo shape bounding info
  35235. * @param storage target particle storage
  35236. * @options addShape() passed options
  35237. * @hidden
  35238. */
  35239. private _insertNewParticle;
  35240. /**
  35241. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  35242. * This method calls `updateParticle()` for each particle of the SPS.
  35243. * For an animated SPS, it is usually called within the render loop.
  35244. * 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.
  35245. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  35246. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  35247. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  35248. * @returns the SPS.
  35249. */
  35250. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  35251. /**
  35252. * Disposes the SPS.
  35253. */
  35254. dispose(): void;
  35255. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  35256. * idx is the particle index in the SPS
  35257. * faceId is the picked face index counted within this particle.
  35258. * Returns null if the pickInfo can't identify a picked particle.
  35259. * @param pickingInfo (PickingInfo object)
  35260. * @returns {idx: number, faceId: number} or null
  35261. */
  35262. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  35263. idx: number;
  35264. faceId: number;
  35265. }>;
  35266. /**
  35267. * Returns a SolidParticle object from its identifier : particle.id
  35268. * @param id (integer) the particle Id
  35269. * @returns the searched particle or null if not found in the SPS.
  35270. */
  35271. getParticleById(id: number): Nullable<SolidParticle>;
  35272. /**
  35273. * Returns a new array populated with the particles having the passed shapeId.
  35274. * @param shapeId (integer) the shape identifier
  35275. * @returns a new solid particle array
  35276. */
  35277. getParticlesByShapeId(shapeId: number): SolidParticle[];
  35278. /**
  35279. * Populates the passed array "ref" with the particles having the passed shapeId.
  35280. * @param shapeId the shape identifier
  35281. * @returns the SPS
  35282. * @param ref
  35283. */
  35284. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  35285. /**
  35286. * Computes the required SubMeshes according the materials assigned to the particles.
  35287. * @returns the solid particle system.
  35288. * Does nothing if called before the SPS mesh is built.
  35289. */
  35290. computeSubMeshes(): SolidParticleSystem;
  35291. /**
  35292. * Sorts the solid particles by material when MultiMaterial is enabled.
  35293. * Updates the indices32 array.
  35294. * Updates the indicesByMaterial array.
  35295. * Updates the mesh indices array.
  35296. * @returns the SPS
  35297. * @hidden
  35298. */
  35299. private _sortParticlesByMaterial;
  35300. /**
  35301. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  35302. * @hidden
  35303. */
  35304. private _setMaterialIndexesById;
  35305. /**
  35306. * Returns an array with unique values of Materials from the passed array
  35307. * @param array the material array to be checked and filtered
  35308. * @hidden
  35309. */
  35310. private _filterUniqueMaterialId;
  35311. /**
  35312. * Sets a new Standard Material as _defaultMaterial if not already set.
  35313. * @hidden
  35314. */
  35315. private _setDefaultMaterial;
  35316. /**
  35317. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  35318. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35319. * @returns the SPS.
  35320. */
  35321. refreshVisibleSize(): SolidParticleSystem;
  35322. /**
  35323. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  35324. * @param size the size (float) of the visibility box
  35325. * note : this doesn't lock the SPS mesh bounding box.
  35326. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35327. */
  35328. setVisibilityBox(size: number): void;
  35329. /**
  35330. * Gets whether the SPS as always visible or not
  35331. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35332. */
  35333. get isAlwaysVisible(): boolean;
  35334. /**
  35335. * Sets the SPS as always visible or not
  35336. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35337. */
  35338. set isAlwaysVisible(val: boolean);
  35339. /**
  35340. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35341. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35342. */
  35343. set isVisibilityBoxLocked(val: boolean);
  35344. /**
  35345. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  35346. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  35347. */
  35348. get isVisibilityBoxLocked(): boolean;
  35349. /**
  35350. * Tells to `setParticles()` to compute the particle rotations or not.
  35351. * Default value : true. The SPS is faster when it's set to false.
  35352. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35353. */
  35354. set computeParticleRotation(val: boolean);
  35355. /**
  35356. * Tells to `setParticles()` to compute the particle colors or not.
  35357. * Default value : true. The SPS is faster when it's set to false.
  35358. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35359. */
  35360. set computeParticleColor(val: boolean);
  35361. set computeParticleTexture(val: boolean);
  35362. /**
  35363. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  35364. * Default value : false. The SPS is faster when it's set to false.
  35365. * Note : the particle custom vertex positions aren't stored values.
  35366. */
  35367. set computeParticleVertex(val: boolean);
  35368. /**
  35369. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  35370. */
  35371. set computeBoundingBox(val: boolean);
  35372. /**
  35373. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  35374. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35375. * Default : `true`
  35376. */
  35377. set depthSortParticles(val: boolean);
  35378. /**
  35379. * Gets if `setParticles()` computes the particle rotations or not.
  35380. * Default value : true. The SPS is faster when it's set to false.
  35381. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  35382. */
  35383. get computeParticleRotation(): boolean;
  35384. /**
  35385. * Gets if `setParticles()` computes the particle colors or not.
  35386. * Default value : true. The SPS is faster when it's set to false.
  35387. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  35388. */
  35389. get computeParticleColor(): boolean;
  35390. /**
  35391. * Gets if `setParticles()` computes the particle textures or not.
  35392. * Default value : true. The SPS is faster when it's set to false.
  35393. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  35394. */
  35395. get computeParticleTexture(): boolean;
  35396. /**
  35397. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  35398. * Default value : false. The SPS is faster when it's set to false.
  35399. * Note : the particle custom vertex positions aren't stored values.
  35400. */
  35401. get computeParticleVertex(): boolean;
  35402. /**
  35403. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  35404. */
  35405. get computeBoundingBox(): boolean;
  35406. /**
  35407. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  35408. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  35409. * Default : `true`
  35410. */
  35411. get depthSortParticles(): boolean;
  35412. /**
  35413. * Gets if the SPS is created as expandable at construction time.
  35414. * Default : `false`
  35415. */
  35416. get expandable(): boolean;
  35417. /**
  35418. * Gets if the SPS supports the Multi Materials
  35419. */
  35420. get multimaterialEnabled(): boolean;
  35421. /**
  35422. * Gets if the SPS uses the model materials for its own multimaterial.
  35423. */
  35424. get useModelMaterial(): boolean;
  35425. /**
  35426. * The SPS used material array.
  35427. */
  35428. get materials(): Material[];
  35429. /**
  35430. * Sets the SPS MultiMaterial from the passed materials.
  35431. * Note : the passed array is internally copied and not used then by reference.
  35432. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  35433. */
  35434. setMultiMaterial(materials: Material[]): void;
  35435. /**
  35436. * The SPS computed multimaterial object
  35437. */
  35438. get multimaterial(): MultiMaterial;
  35439. set multimaterial(mm: MultiMaterial);
  35440. /**
  35441. * If the subMeshes must be updated on the next call to setParticles()
  35442. */
  35443. get autoUpdateSubMeshes(): boolean;
  35444. set autoUpdateSubMeshes(val: boolean);
  35445. /**
  35446. * This function does nothing. It may be overwritten to set all the particle first values.
  35447. * The SPS doesn't call this function, you may have to call it by your own.
  35448. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35449. */
  35450. initParticles(): void;
  35451. /**
  35452. * This function does nothing. It may be overwritten to recycle a particle.
  35453. * The SPS doesn't call this function, you may have to call it by your own.
  35454. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35455. * @param particle The particle to recycle
  35456. * @returns the recycled particle
  35457. */
  35458. recycleParticle(particle: SolidParticle): SolidParticle;
  35459. /**
  35460. * Updates a particle : this function should be overwritten by the user.
  35461. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  35462. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  35463. * @example : just set a particle position or velocity and recycle conditions
  35464. * @param particle The particle to update
  35465. * @returns the updated particle
  35466. */
  35467. updateParticle(particle: SolidParticle): SolidParticle;
  35468. /**
  35469. * Updates a vertex of a particle : it can be overwritten by the user.
  35470. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  35471. * @param particle the current particle
  35472. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  35473. * @param pt the index of the current vertex in the particle shape
  35474. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  35475. * @example : just set a vertex particle position or color
  35476. * @returns the sps
  35477. */
  35478. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  35479. /**
  35480. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  35481. * This does nothing and may be overwritten by the user.
  35482. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35483. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35484. * @param update the boolean update value actually passed to setParticles()
  35485. */
  35486. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35487. /**
  35488. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  35489. * This will be passed three parameters.
  35490. * This does nothing and may be overwritten by the user.
  35491. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35492. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  35493. * @param update the boolean update value actually passed to setParticles()
  35494. */
  35495. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  35496. }
  35497. }
  35498. declare module BABYLON {
  35499. /**
  35500. * Represents one particle of a solid particle system.
  35501. */
  35502. export class SolidParticle {
  35503. /**
  35504. * particle global index
  35505. */
  35506. idx: number;
  35507. /**
  35508. * particle identifier
  35509. */
  35510. id: number;
  35511. /**
  35512. * The color of the particle
  35513. */
  35514. color: Nullable<Color4>;
  35515. /**
  35516. * The world space position of the particle.
  35517. */
  35518. position: Vector3;
  35519. /**
  35520. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  35521. */
  35522. rotation: Vector3;
  35523. /**
  35524. * The world space rotation quaternion of the particle.
  35525. */
  35526. rotationQuaternion: Nullable<Quaternion>;
  35527. /**
  35528. * The scaling of the particle.
  35529. */
  35530. scaling: Vector3;
  35531. /**
  35532. * The uvs of the particle.
  35533. */
  35534. uvs: Vector4;
  35535. /**
  35536. * The current speed of the particle.
  35537. */
  35538. velocity: Vector3;
  35539. /**
  35540. * The pivot point in the particle local space.
  35541. */
  35542. pivot: Vector3;
  35543. /**
  35544. * Must the particle be translated from its pivot point in its local space ?
  35545. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  35546. * Default : false
  35547. */
  35548. translateFromPivot: boolean;
  35549. /**
  35550. * Is the particle active or not ?
  35551. */
  35552. alive: boolean;
  35553. /**
  35554. * Is the particle visible or not ?
  35555. */
  35556. isVisible: boolean;
  35557. /**
  35558. * Index of this particle in the global "positions" array (Internal use)
  35559. * @hidden
  35560. */
  35561. _pos: number;
  35562. /**
  35563. * @hidden Index of this particle in the global "indices" array (Internal use)
  35564. */
  35565. _ind: number;
  35566. /**
  35567. * @hidden ModelShape of this particle (Internal use)
  35568. */
  35569. _model: ModelShape;
  35570. /**
  35571. * ModelShape id of this particle
  35572. */
  35573. shapeId: number;
  35574. /**
  35575. * Index of the particle in its shape id
  35576. */
  35577. idxInShape: number;
  35578. /**
  35579. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  35580. */
  35581. _modelBoundingInfo: BoundingInfo;
  35582. /**
  35583. * @hidden Particle BoundingInfo object (Internal use)
  35584. */
  35585. _boundingInfo: BoundingInfo;
  35586. /**
  35587. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  35588. */
  35589. _sps: SolidParticleSystem;
  35590. /**
  35591. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  35592. */
  35593. _stillInvisible: boolean;
  35594. /**
  35595. * @hidden Last computed particle rotation matrix
  35596. */
  35597. _rotationMatrix: number[];
  35598. /**
  35599. * Parent particle Id, if any.
  35600. * Default null.
  35601. */
  35602. parentId: Nullable<number>;
  35603. /**
  35604. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  35605. */
  35606. materialIndex: Nullable<number>;
  35607. /**
  35608. * Custom object or properties.
  35609. */
  35610. props: Nullable<any>;
  35611. /**
  35612. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  35613. * The possible values are :
  35614. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35615. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35616. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35617. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35618. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35619. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  35620. * */
  35621. cullingStrategy: number;
  35622. /**
  35623. * @hidden Internal global position in the SPS.
  35624. */
  35625. _globalPosition: Vector3;
  35626. /**
  35627. * Creates a Solid Particle object.
  35628. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  35629. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  35630. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  35631. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  35632. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  35633. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  35634. * @param shapeId (integer) is the model shape identifier in the SPS.
  35635. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  35636. * @param sps defines the sps it is associated to
  35637. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  35638. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  35639. */
  35640. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  35641. /**
  35642. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  35643. * @param target the particle target
  35644. * @returns the current particle
  35645. */
  35646. copyToRef(target: SolidParticle): SolidParticle;
  35647. /**
  35648. * Legacy support, changed scale to scaling
  35649. */
  35650. get scale(): Vector3;
  35651. /**
  35652. * Legacy support, changed scale to scaling
  35653. */
  35654. set scale(scale: Vector3);
  35655. /**
  35656. * Legacy support, changed quaternion to rotationQuaternion
  35657. */
  35658. get quaternion(): Nullable<Quaternion>;
  35659. /**
  35660. * Legacy support, changed quaternion to rotationQuaternion
  35661. */
  35662. set quaternion(q: Nullable<Quaternion>);
  35663. /**
  35664. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  35665. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  35666. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  35667. * @returns true if it intersects
  35668. */
  35669. intersectsMesh(target: Mesh | SolidParticle): boolean;
  35670. /**
  35671. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  35672. * A particle is in the frustum if its bounding box intersects the frustum
  35673. * @param frustumPlanes defines the frustum to test
  35674. * @returns true if the particle is in the frustum planes
  35675. */
  35676. isInFrustum(frustumPlanes: Plane[]): boolean;
  35677. /**
  35678. * get the rotation matrix of the particle
  35679. * @hidden
  35680. */
  35681. getRotationMatrix(m: Matrix): void;
  35682. }
  35683. /**
  35684. * Represents the shape of the model used by one particle of a solid particle system.
  35685. * SPS internal tool, don't use it manually.
  35686. */
  35687. export class ModelShape {
  35688. /**
  35689. * The shape id
  35690. * @hidden
  35691. */
  35692. shapeID: number;
  35693. /**
  35694. * flat array of model positions (internal use)
  35695. * @hidden
  35696. */
  35697. _shape: Vector3[];
  35698. /**
  35699. * flat array of model UVs (internal use)
  35700. * @hidden
  35701. */
  35702. _shapeUV: number[];
  35703. /**
  35704. * color array of the model
  35705. * @hidden
  35706. */
  35707. _shapeColors: number[];
  35708. /**
  35709. * indices array of the model
  35710. * @hidden
  35711. */
  35712. _indices: number[];
  35713. /**
  35714. * normals array of the model
  35715. * @hidden
  35716. */
  35717. _normals: number[];
  35718. /**
  35719. * length of the shape in the model indices array (internal use)
  35720. * @hidden
  35721. */
  35722. _indicesLength: number;
  35723. /**
  35724. * Custom position function (internal use)
  35725. * @hidden
  35726. */
  35727. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  35728. /**
  35729. * Custom vertex function (internal use)
  35730. * @hidden
  35731. */
  35732. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  35733. /**
  35734. * Model material (internal use)
  35735. * @hidden
  35736. */
  35737. _material: Nullable<Material>;
  35738. /**
  35739. * 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.
  35740. * SPS internal tool, don't use it manually.
  35741. * @hidden
  35742. */
  35743. 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>);
  35744. }
  35745. /**
  35746. * Represents a Depth Sorted Particle in the solid particle system.
  35747. * @hidden
  35748. */
  35749. export class DepthSortedParticle {
  35750. /**
  35751. * Particle index
  35752. */
  35753. idx: number;
  35754. /**
  35755. * Index of the particle in the "indices" array
  35756. */
  35757. ind: number;
  35758. /**
  35759. * Length of the particle shape in the "indices" array
  35760. */
  35761. indicesLength: number;
  35762. /**
  35763. * Squared distance from the particle to the camera
  35764. */
  35765. sqDistance: number;
  35766. /**
  35767. * Material index when used with MultiMaterials
  35768. */
  35769. materialIndex: number;
  35770. /**
  35771. * Creates a new sorted particle
  35772. * @param materialIndex
  35773. */
  35774. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  35775. }
  35776. /**
  35777. * Represents a solid particle vertex
  35778. */
  35779. export class SolidParticleVertex {
  35780. /**
  35781. * Vertex position
  35782. */
  35783. position: Vector3;
  35784. /**
  35785. * Vertex color
  35786. */
  35787. color: Color4;
  35788. /**
  35789. * Vertex UV
  35790. */
  35791. uv: Vector2;
  35792. /**
  35793. * Creates a new solid particle vertex
  35794. */
  35795. constructor();
  35796. /** Vertex x coordinate */
  35797. get x(): number;
  35798. set x(val: number);
  35799. /** Vertex y coordinate */
  35800. get y(): number;
  35801. set y(val: number);
  35802. /** Vertex z coordinate */
  35803. get z(): number;
  35804. set z(val: number);
  35805. }
  35806. }
  35807. declare module BABYLON {
  35808. /**
  35809. * @hidden
  35810. */
  35811. export class _MeshCollisionData {
  35812. _checkCollisions: boolean;
  35813. _collisionMask: number;
  35814. _collisionGroup: number;
  35815. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35816. _collider: Nullable<Collider>;
  35817. _oldPositionForCollisions: Vector3;
  35818. _diffPositionForCollisions: Vector3;
  35819. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35820. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35821. _collisionResponse: boolean;
  35822. }
  35823. }
  35824. declare module BABYLON {
  35825. /** @hidden */
  35826. class _FacetDataStorage {
  35827. facetPositions: Vector3[];
  35828. facetNormals: Vector3[];
  35829. facetPartitioning: number[][];
  35830. facetNb: number;
  35831. partitioningSubdivisions: number;
  35832. partitioningBBoxRatio: number;
  35833. facetDataEnabled: boolean;
  35834. facetParameters: any;
  35835. bbSize: Vector3;
  35836. subDiv: {
  35837. max: number;
  35838. X: number;
  35839. Y: number;
  35840. Z: number;
  35841. };
  35842. facetDepthSort: boolean;
  35843. facetDepthSortEnabled: boolean;
  35844. depthSortedIndices: IndicesArray;
  35845. depthSortedFacets: {
  35846. ind: number;
  35847. sqDistance: number;
  35848. }[];
  35849. facetDepthSortFunction: (f1: {
  35850. ind: number;
  35851. sqDistance: number;
  35852. }, f2: {
  35853. ind: number;
  35854. sqDistance: number;
  35855. }) => number;
  35856. facetDepthSortFrom: Vector3;
  35857. facetDepthSortOrigin: Vector3;
  35858. invertedMatrix: Matrix;
  35859. }
  35860. /**
  35861. * @hidden
  35862. **/
  35863. class _InternalAbstractMeshDataInfo {
  35864. _hasVertexAlpha: boolean;
  35865. _useVertexColors: boolean;
  35866. _numBoneInfluencers: number;
  35867. _applyFog: boolean;
  35868. _receiveShadows: boolean;
  35869. _facetData: _FacetDataStorage;
  35870. _visibility: number;
  35871. _skeleton: Nullable<Skeleton>;
  35872. _layerMask: number;
  35873. _computeBonesUsingShaders: boolean;
  35874. _isActive: boolean;
  35875. _onlyForInstances: boolean;
  35876. _isActiveIntermediate: boolean;
  35877. _onlyForInstancesIntermediate: boolean;
  35878. _actAsRegularMesh: boolean;
  35879. _currentLOD: Nullable<AbstractMesh>;
  35880. _currentLODIsUpToDate: boolean;
  35881. }
  35882. /**
  35883. * Class used to store all common mesh properties
  35884. */
  35885. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35886. /** No occlusion */
  35887. static OCCLUSION_TYPE_NONE: number;
  35888. /** Occlusion set to optimisitic */
  35889. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35890. /** Occlusion set to strict */
  35891. static OCCLUSION_TYPE_STRICT: number;
  35892. /** Use an accurante occlusion algorithm */
  35893. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35894. /** Use a conservative occlusion algorithm */
  35895. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35896. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35897. * Test order :
  35898. * Is the bounding sphere outside the frustum ?
  35899. * If not, are the bounding box vertices outside the frustum ?
  35900. * It not, then the cullable object is in the frustum.
  35901. */
  35902. static readonly CULLINGSTRATEGY_STANDARD: number;
  35903. /** Culling strategy : Bounding Sphere Only.
  35904. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35905. * It's also less accurate than the standard because some not visible objects can still be selected.
  35906. * Test : is the bounding sphere outside the frustum ?
  35907. * If not, then the cullable object is in the frustum.
  35908. */
  35909. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35910. /** Culling strategy : Optimistic Inclusion.
  35911. * This in an inclusion test first, then the standard exclusion test.
  35912. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35913. * 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.
  35914. * Anyway, it's as accurate as the standard strategy.
  35915. * Test :
  35916. * Is the cullable object bounding sphere center in the frustum ?
  35917. * If not, apply the default culling strategy.
  35918. */
  35919. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35920. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35921. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35922. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35923. * 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.
  35924. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35925. * Test :
  35926. * Is the cullable object bounding sphere center in the frustum ?
  35927. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35928. */
  35929. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35930. /**
  35931. * No billboard
  35932. */
  35933. static get BILLBOARDMODE_NONE(): number;
  35934. /** Billboard on X axis */
  35935. static get BILLBOARDMODE_X(): number;
  35936. /** Billboard on Y axis */
  35937. static get BILLBOARDMODE_Y(): number;
  35938. /** Billboard on Z axis */
  35939. static get BILLBOARDMODE_Z(): number;
  35940. /** Billboard on all axes */
  35941. static get BILLBOARDMODE_ALL(): number;
  35942. /** Billboard on using position instead of orientation */
  35943. static get BILLBOARDMODE_USE_POSITION(): number;
  35944. /** @hidden */
  35945. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35946. /**
  35947. * The culling strategy to use to check whether the mesh must be rendered or not.
  35948. * This value can be changed at any time and will be used on the next render mesh selection.
  35949. * The possible values are :
  35950. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35951. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35952. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35953. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35954. * Please read each static variable documentation to get details about the culling process.
  35955. * */
  35956. cullingStrategy: number;
  35957. /**
  35958. * Gets the number of facets in the mesh
  35959. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35960. */
  35961. get facetNb(): number;
  35962. /**
  35963. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35964. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35965. */
  35966. get partitioningSubdivisions(): number;
  35967. set partitioningSubdivisions(nb: number);
  35968. /**
  35969. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35970. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35971. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35972. */
  35973. get partitioningBBoxRatio(): number;
  35974. set partitioningBBoxRatio(ratio: number);
  35975. /**
  35976. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35977. * Works only for updatable meshes.
  35978. * Doesn't work with multi-materials
  35979. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35980. */
  35981. get mustDepthSortFacets(): boolean;
  35982. set mustDepthSortFacets(sort: boolean);
  35983. /**
  35984. * The location (Vector3) where the facet depth sort must be computed from.
  35985. * By default, the active camera position.
  35986. * Used only when facet depth sort is enabled
  35987. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35988. */
  35989. get facetDepthSortFrom(): Vector3;
  35990. set facetDepthSortFrom(location: Vector3);
  35991. /**
  35992. * gets a boolean indicating if facetData is enabled
  35993. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35994. */
  35995. get isFacetDataEnabled(): boolean;
  35996. /** @hidden */
  35997. _updateNonUniformScalingState(value: boolean): boolean;
  35998. /**
  35999. * An event triggered when this mesh collides with another one
  36000. */
  36001. onCollideObservable: Observable<AbstractMesh>;
  36002. /** Set a function to call when this mesh collides with another one */
  36003. set onCollide(callback: () => void);
  36004. /**
  36005. * An event triggered when the collision's position changes
  36006. */
  36007. onCollisionPositionChangeObservable: Observable<Vector3>;
  36008. /** Set a function to call when the collision's position changes */
  36009. set onCollisionPositionChange(callback: () => void);
  36010. /**
  36011. * An event triggered when material is changed
  36012. */
  36013. onMaterialChangedObservable: Observable<AbstractMesh>;
  36014. /**
  36015. * Gets or sets the orientation for POV movement & rotation
  36016. */
  36017. definedFacingForward: boolean;
  36018. /** @hidden */
  36019. _occlusionQuery: Nullable<WebGLQuery>;
  36020. /** @hidden */
  36021. _renderingGroup: Nullable<RenderingGroup>;
  36022. /**
  36023. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36024. */
  36025. get visibility(): number;
  36026. /**
  36027. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36028. */
  36029. set visibility(value: number);
  36030. /** Gets or sets the alpha index used to sort transparent meshes
  36031. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36032. */
  36033. alphaIndex: number;
  36034. /**
  36035. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36036. */
  36037. isVisible: boolean;
  36038. /**
  36039. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36040. */
  36041. isPickable: boolean;
  36042. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36043. showSubMeshesBoundingBox: boolean;
  36044. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36045. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36046. */
  36047. isBlocker: boolean;
  36048. /**
  36049. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36050. */
  36051. enablePointerMoveEvents: boolean;
  36052. private _renderingGroupId;
  36053. /**
  36054. * Specifies the rendering group id for this mesh (0 by default)
  36055. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36056. */
  36057. get renderingGroupId(): number;
  36058. set renderingGroupId(value: number);
  36059. private _material;
  36060. /** Gets or sets current material */
  36061. get material(): Nullable<Material>;
  36062. set material(value: Nullable<Material>);
  36063. /**
  36064. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36065. * @see https://doc.babylonjs.com/babylon101/shadows
  36066. */
  36067. get receiveShadows(): boolean;
  36068. set receiveShadows(value: boolean);
  36069. /** Defines color to use when rendering outline */
  36070. outlineColor: Color3;
  36071. /** Define width to use when rendering outline */
  36072. outlineWidth: number;
  36073. /** Defines color to use when rendering overlay */
  36074. overlayColor: Color3;
  36075. /** Defines alpha to use when rendering overlay */
  36076. overlayAlpha: number;
  36077. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36078. get hasVertexAlpha(): boolean;
  36079. set hasVertexAlpha(value: boolean);
  36080. /** 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) */
  36081. get useVertexColors(): boolean;
  36082. set useVertexColors(value: boolean);
  36083. /**
  36084. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36085. */
  36086. get computeBonesUsingShaders(): boolean;
  36087. set computeBonesUsingShaders(value: boolean);
  36088. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36089. get numBoneInfluencers(): number;
  36090. set numBoneInfluencers(value: number);
  36091. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36092. get applyFog(): boolean;
  36093. set applyFog(value: boolean);
  36094. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  36095. useOctreeForRenderingSelection: boolean;
  36096. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  36097. useOctreeForPicking: boolean;
  36098. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  36099. useOctreeForCollisions: boolean;
  36100. /**
  36101. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  36102. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  36103. */
  36104. get layerMask(): number;
  36105. set layerMask(value: number);
  36106. /**
  36107. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  36108. */
  36109. alwaysSelectAsActiveMesh: boolean;
  36110. /**
  36111. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  36112. */
  36113. doNotSyncBoundingInfo: boolean;
  36114. /**
  36115. * Gets or sets the current action manager
  36116. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36117. */
  36118. actionManager: Nullable<AbstractActionManager>;
  36119. private _meshCollisionData;
  36120. /**
  36121. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  36122. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36123. */
  36124. ellipsoid: Vector3;
  36125. /**
  36126. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  36127. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36128. */
  36129. ellipsoidOffset: Vector3;
  36130. /**
  36131. * Gets or sets a collision mask used to mask collisions (default is -1).
  36132. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36133. */
  36134. get collisionMask(): number;
  36135. set collisionMask(mask: number);
  36136. /**
  36137. * Gets or sets a collision response flag (default is true).
  36138. * when collisionResponse is false, events are still triggered but colliding entity has no response
  36139. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  36140. * to respond to the collision.
  36141. */
  36142. get collisionResponse(): boolean;
  36143. set collisionResponse(response: boolean);
  36144. /**
  36145. * Gets or sets the current collision group mask (-1 by default).
  36146. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  36147. */
  36148. get collisionGroup(): number;
  36149. set collisionGroup(mask: number);
  36150. /**
  36151. * Gets or sets current surrounding meshes (null by default).
  36152. *
  36153. * By default collision detection is tested against every mesh in the scene.
  36154. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  36155. * meshes will be tested for the collision.
  36156. *
  36157. * Note: if set to an empty array no collision will happen when this mesh is moved.
  36158. */
  36159. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  36160. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  36161. /**
  36162. * Defines edge width used when edgesRenderer is enabled
  36163. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36164. */
  36165. edgesWidth: number;
  36166. /**
  36167. * Defines edge color used when edgesRenderer is enabled
  36168. * @see https://www.babylonjs-playground.com/#10OJSG#13
  36169. */
  36170. edgesColor: Color4;
  36171. /** @hidden */
  36172. _edgesRenderer: Nullable<IEdgesRenderer>;
  36173. /** @hidden */
  36174. _masterMesh: Nullable<AbstractMesh>;
  36175. /** @hidden */
  36176. _boundingInfo: Nullable<BoundingInfo>;
  36177. /** @hidden */
  36178. _renderId: number;
  36179. /**
  36180. * Gets or sets the list of subMeshes
  36181. * @see https://doc.babylonjs.com/how_to/multi_materials
  36182. */
  36183. subMeshes: SubMesh[];
  36184. /** @hidden */
  36185. _intersectionsInProgress: AbstractMesh[];
  36186. /** @hidden */
  36187. _unIndexed: boolean;
  36188. /** @hidden */
  36189. _lightSources: Light[];
  36190. /** Gets the list of lights affecting that mesh */
  36191. get lightSources(): Light[];
  36192. /** @hidden */
  36193. get _positions(): Nullable<Vector3[]>;
  36194. /** @hidden */
  36195. _waitingData: {
  36196. lods: Nullable<any>;
  36197. actions: Nullable<any>;
  36198. freezeWorldMatrix: Nullable<boolean>;
  36199. };
  36200. /** @hidden */
  36201. _bonesTransformMatrices: Nullable<Float32Array>;
  36202. /** @hidden */
  36203. _transformMatrixTexture: Nullable<RawTexture>;
  36204. /**
  36205. * Gets or sets a skeleton to apply skining transformations
  36206. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  36207. */
  36208. set skeleton(value: Nullable<Skeleton>);
  36209. get skeleton(): Nullable<Skeleton>;
  36210. /**
  36211. * An event triggered when the mesh is rebuilt.
  36212. */
  36213. onRebuildObservable: Observable<AbstractMesh>;
  36214. /**
  36215. * The current mesh unifom buffer.
  36216. * @hidden Internal use only.
  36217. */
  36218. _uniformBuffer: UniformBuffer;
  36219. /**
  36220. * Creates a new AbstractMesh
  36221. * @param name defines the name of the mesh
  36222. * @param scene defines the hosting scene
  36223. */
  36224. constructor(name: string, scene?: Nullable<Scene>);
  36225. protected _buildUniformLayout(): void;
  36226. /**
  36227. * Transfer the mesh values to its UBO.
  36228. * @param world The world matrix associated with the mesh
  36229. */
  36230. transferToEffect(world: Matrix): void;
  36231. /**
  36232. * Gets the mesh uniform buffer.
  36233. * @return the uniform buffer of the mesh.
  36234. */
  36235. getMeshUniformBuffer(): UniformBuffer;
  36236. /**
  36237. * Returns the string "AbstractMesh"
  36238. * @returns "AbstractMesh"
  36239. */
  36240. getClassName(): string;
  36241. /**
  36242. * Gets a string representation of the current mesh
  36243. * @param fullDetails defines a boolean indicating if full details must be included
  36244. * @returns a string representation of the current mesh
  36245. */
  36246. toString(fullDetails?: boolean): string;
  36247. /**
  36248. * @hidden
  36249. */
  36250. protected _getEffectiveParent(): Nullable<Node>;
  36251. /** @hidden */
  36252. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36253. /** @hidden */
  36254. _rebuild(): void;
  36255. /** @hidden */
  36256. _resyncLightSources(): void;
  36257. /** @hidden */
  36258. _resyncLightSource(light: Light): void;
  36259. /** @hidden */
  36260. _unBindEffect(): void;
  36261. /** @hidden */
  36262. _removeLightSource(light: Light, dispose: boolean): void;
  36263. private _markSubMeshesAsDirty;
  36264. /** @hidden */
  36265. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  36266. /** @hidden */
  36267. _markSubMeshesAsAttributesDirty(): void;
  36268. /** @hidden */
  36269. _markSubMeshesAsMiscDirty(): void;
  36270. /**
  36271. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  36272. */
  36273. get scaling(): Vector3;
  36274. set scaling(newScaling: Vector3);
  36275. /**
  36276. * Returns true if the mesh is blocked. Implemented by child classes
  36277. */
  36278. get isBlocked(): boolean;
  36279. /**
  36280. * Returns the mesh itself by default. Implemented by child classes
  36281. * @param camera defines the camera to use to pick the right LOD level
  36282. * @returns the currentAbstractMesh
  36283. */
  36284. getLOD(camera: Camera): Nullable<AbstractMesh>;
  36285. /**
  36286. * Returns 0 by default. Implemented by child classes
  36287. * @returns an integer
  36288. */
  36289. getTotalVertices(): number;
  36290. /**
  36291. * Returns a positive integer : the total number of indices in this mesh geometry.
  36292. * @returns the numner of indices or zero if the mesh has no geometry.
  36293. */
  36294. getTotalIndices(): number;
  36295. /**
  36296. * Returns null by default. Implemented by child classes
  36297. * @returns null
  36298. */
  36299. getIndices(): Nullable<IndicesArray>;
  36300. /**
  36301. * Returns the array of the requested vertex data kind. Implemented by child classes
  36302. * @param kind defines the vertex data kind to use
  36303. * @returns null
  36304. */
  36305. getVerticesData(kind: string): Nullable<FloatArray>;
  36306. /**
  36307. * Sets the vertex data of the mesh geometry for the requested `kind`.
  36308. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  36309. * Note that a new underlying VertexBuffer object is created each call.
  36310. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  36311. * @param kind defines vertex data kind:
  36312. * * VertexBuffer.PositionKind
  36313. * * VertexBuffer.UVKind
  36314. * * VertexBuffer.UV2Kind
  36315. * * VertexBuffer.UV3Kind
  36316. * * VertexBuffer.UV4Kind
  36317. * * VertexBuffer.UV5Kind
  36318. * * VertexBuffer.UV6Kind
  36319. * * VertexBuffer.ColorKind
  36320. * * VertexBuffer.MatricesIndicesKind
  36321. * * VertexBuffer.MatricesIndicesExtraKind
  36322. * * VertexBuffer.MatricesWeightsKind
  36323. * * VertexBuffer.MatricesWeightsExtraKind
  36324. * @param data defines the data source
  36325. * @param updatable defines if the data must be flagged as updatable (or static)
  36326. * @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
  36327. * @returns the current mesh
  36328. */
  36329. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  36330. /**
  36331. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  36332. * If the mesh has no geometry, it is simply returned as it is.
  36333. * @param kind defines vertex data kind:
  36334. * * VertexBuffer.PositionKind
  36335. * * VertexBuffer.UVKind
  36336. * * VertexBuffer.UV2Kind
  36337. * * VertexBuffer.UV3Kind
  36338. * * VertexBuffer.UV4Kind
  36339. * * VertexBuffer.UV5Kind
  36340. * * VertexBuffer.UV6Kind
  36341. * * VertexBuffer.ColorKind
  36342. * * VertexBuffer.MatricesIndicesKind
  36343. * * VertexBuffer.MatricesIndicesExtraKind
  36344. * * VertexBuffer.MatricesWeightsKind
  36345. * * VertexBuffer.MatricesWeightsExtraKind
  36346. * @param data defines the data source
  36347. * @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
  36348. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  36349. * @returns the current mesh
  36350. */
  36351. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  36352. /**
  36353. * Sets the mesh indices,
  36354. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  36355. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  36356. * @param totalVertices Defines the total number of vertices
  36357. * @returns the current mesh
  36358. */
  36359. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  36360. /**
  36361. * Gets a boolean indicating if specific vertex data is present
  36362. * @param kind defines the vertex data kind to use
  36363. * @returns true is data kind is present
  36364. */
  36365. isVerticesDataPresent(kind: string): boolean;
  36366. /**
  36367. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  36368. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  36369. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  36370. * @returns a BoundingInfo
  36371. */
  36372. getBoundingInfo(): BoundingInfo;
  36373. /**
  36374. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  36375. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  36376. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  36377. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  36378. * @returns the current mesh
  36379. */
  36380. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  36381. /**
  36382. * Overwrite the current bounding info
  36383. * @param boundingInfo defines the new bounding info
  36384. * @returns the current mesh
  36385. */
  36386. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  36387. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  36388. get useBones(): boolean;
  36389. /** @hidden */
  36390. _preActivate(): void;
  36391. /** @hidden */
  36392. _preActivateForIntermediateRendering(renderId: number): void;
  36393. /** @hidden */
  36394. _activate(renderId: number, intermediateRendering: boolean): boolean;
  36395. /** @hidden */
  36396. _postActivate(): void;
  36397. /** @hidden */
  36398. _freeze(): void;
  36399. /** @hidden */
  36400. _unFreeze(): void;
  36401. /**
  36402. * Gets the current world matrix
  36403. * @returns a Matrix
  36404. */
  36405. getWorldMatrix(): Matrix;
  36406. /** @hidden */
  36407. _getWorldMatrixDeterminant(): number;
  36408. /**
  36409. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  36410. */
  36411. get isAnInstance(): boolean;
  36412. /**
  36413. * Gets a boolean indicating if this mesh has instances
  36414. */
  36415. get hasInstances(): boolean;
  36416. /**
  36417. * Gets a boolean indicating if this mesh has thin instances
  36418. */
  36419. get hasThinInstances(): boolean;
  36420. /**
  36421. * Perform relative position change from the point of view of behind the front of the mesh.
  36422. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36423. * Supports definition of mesh facing forward or backward
  36424. * @param amountRight defines the distance on the right axis
  36425. * @param amountUp defines the distance on the up axis
  36426. * @param amountForward defines the distance on the forward axis
  36427. * @returns the current mesh
  36428. */
  36429. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  36430. /**
  36431. * Calculate relative position change from the point of view of behind the front of the mesh.
  36432. * This is performed taking into account the meshes current rotation, so you do not have to care.
  36433. * Supports definition of mesh facing forward or backward
  36434. * @param amountRight defines the distance on the right axis
  36435. * @param amountUp defines the distance on the up axis
  36436. * @param amountForward defines the distance on the forward axis
  36437. * @returns the new displacement vector
  36438. */
  36439. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  36440. /**
  36441. * Perform relative rotation change from the point of view of behind the front of the mesh.
  36442. * Supports definition of mesh facing forward or backward
  36443. * @param flipBack defines the flip
  36444. * @param twirlClockwise defines the twirl
  36445. * @param tiltRight defines the tilt
  36446. * @returns the current mesh
  36447. */
  36448. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  36449. /**
  36450. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  36451. * Supports definition of mesh facing forward or backward.
  36452. * @param flipBack defines the flip
  36453. * @param twirlClockwise defines the twirl
  36454. * @param tiltRight defines the tilt
  36455. * @returns the new rotation vector
  36456. */
  36457. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  36458. /**
  36459. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  36460. * This means the mesh underlying bounding box and sphere are recomputed.
  36461. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  36462. * @returns the current mesh
  36463. */
  36464. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  36465. /** @hidden */
  36466. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  36467. /** @hidden */
  36468. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  36469. /** @hidden */
  36470. _updateBoundingInfo(): AbstractMesh;
  36471. /** @hidden */
  36472. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  36473. /** @hidden */
  36474. protected _afterComputeWorldMatrix(): void;
  36475. /** @hidden */
  36476. get _effectiveMesh(): AbstractMesh;
  36477. /**
  36478. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  36479. * A mesh is in the frustum if its bounding box intersects the frustum
  36480. * @param frustumPlanes defines the frustum to test
  36481. * @returns true if the mesh is in the frustum planes
  36482. */
  36483. isInFrustum(frustumPlanes: Plane[]): boolean;
  36484. /**
  36485. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  36486. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  36487. * @param frustumPlanes defines the frustum to test
  36488. * @returns true if the mesh is completely in the frustum planes
  36489. */
  36490. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  36491. /**
  36492. * True if the mesh intersects another mesh or a SolidParticle object
  36493. * @param mesh defines a target mesh or SolidParticle to test
  36494. * @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)
  36495. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  36496. * @returns true if there is an intersection
  36497. */
  36498. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  36499. /**
  36500. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  36501. * @param point defines the point to test
  36502. * @returns true if there is an intersection
  36503. */
  36504. intersectsPoint(point: Vector3): boolean;
  36505. /**
  36506. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  36507. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36508. */
  36509. get checkCollisions(): boolean;
  36510. set checkCollisions(collisionEnabled: boolean);
  36511. /**
  36512. * Gets Collider object used to compute collisions (not physics)
  36513. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36514. */
  36515. get collider(): Nullable<Collider>;
  36516. /**
  36517. * Move the mesh using collision engine
  36518. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36519. * @param displacement defines the requested displacement vector
  36520. * @returns the current mesh
  36521. */
  36522. moveWithCollisions(displacement: Vector3): AbstractMesh;
  36523. private _onCollisionPositionChange;
  36524. /** @hidden */
  36525. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  36526. /** @hidden */
  36527. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  36528. /** @hidden */
  36529. _checkCollision(collider: Collider): AbstractMesh;
  36530. /** @hidden */
  36531. _generatePointsArray(): boolean;
  36532. /**
  36533. * Checks if the passed Ray intersects with the mesh
  36534. * @param ray defines the ray to use
  36535. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  36536. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  36537. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  36538. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  36539. * @param skipBoundingInfo a boolean indicating if we should skip the bounding info check
  36540. * @returns the picking info
  36541. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  36542. */
  36543. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix, skipBoundingInfo?: boolean): PickingInfo;
  36544. /**
  36545. * Clones the current mesh
  36546. * @param name defines the mesh name
  36547. * @param newParent defines the new mesh parent
  36548. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  36549. * @returns the new mesh
  36550. */
  36551. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  36552. /**
  36553. * Disposes all the submeshes of the current meshnp
  36554. * @returns the current mesh
  36555. */
  36556. releaseSubMeshes(): AbstractMesh;
  36557. /**
  36558. * Releases resources associated with this abstract mesh.
  36559. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36560. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36561. */
  36562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36563. /**
  36564. * Adds the passed mesh as a child to the current mesh
  36565. * @param mesh defines the child mesh
  36566. * @returns the current mesh
  36567. */
  36568. addChild(mesh: AbstractMesh): AbstractMesh;
  36569. /**
  36570. * Removes the passed mesh from the current mesh children list
  36571. * @param mesh defines the child mesh
  36572. * @returns the current mesh
  36573. */
  36574. removeChild(mesh: AbstractMesh): AbstractMesh;
  36575. /** @hidden */
  36576. private _initFacetData;
  36577. /**
  36578. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  36579. * This method can be called within the render loop.
  36580. * 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
  36581. * @returns the current mesh
  36582. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36583. */
  36584. updateFacetData(): AbstractMesh;
  36585. /**
  36586. * Returns the facetLocalNormals array.
  36587. * The normals are expressed in the mesh local spac
  36588. * @returns an array of Vector3
  36589. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36590. */
  36591. getFacetLocalNormals(): Vector3[];
  36592. /**
  36593. * Returns the facetLocalPositions array.
  36594. * The facet positions are expressed in the mesh local space
  36595. * @returns an array of Vector3
  36596. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36597. */
  36598. getFacetLocalPositions(): Vector3[];
  36599. /**
  36600. * Returns the facetLocalPartioning array
  36601. * @returns an array of array of numbers
  36602. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36603. */
  36604. getFacetLocalPartitioning(): number[][];
  36605. /**
  36606. * Returns the i-th facet position in the world system.
  36607. * This method allocates a new Vector3 per call
  36608. * @param i defines the facet index
  36609. * @returns a new Vector3
  36610. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36611. */
  36612. getFacetPosition(i: number): Vector3;
  36613. /**
  36614. * Sets the reference Vector3 with the i-th facet position in the world system
  36615. * @param i defines the facet index
  36616. * @param ref defines the target vector
  36617. * @returns the current mesh
  36618. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36619. */
  36620. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  36621. /**
  36622. * Returns the i-th facet normal in the world system.
  36623. * This method allocates a new Vector3 per call
  36624. * @param i defines the facet index
  36625. * @returns a new Vector3
  36626. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36627. */
  36628. getFacetNormal(i: number): Vector3;
  36629. /**
  36630. * Sets the reference Vector3 with the i-th facet normal in the world system
  36631. * @param i defines the facet index
  36632. * @param ref defines the target vector
  36633. * @returns the current mesh
  36634. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36635. */
  36636. getFacetNormalToRef(i: number, ref: Vector3): this;
  36637. /**
  36638. * 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)
  36639. * @param x defines x coordinate
  36640. * @param y defines y coordinate
  36641. * @param z defines z coordinate
  36642. * @returns the array of facet indexes
  36643. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36644. */
  36645. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  36646. /**
  36647. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  36648. * @param projected sets as the (x,y,z) world projection on the facet
  36649. * @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
  36650. * @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
  36651. * @param x defines x coordinate
  36652. * @param y defines y coordinate
  36653. * @param z defines z coordinate
  36654. * @returns the face index if found (or null instead)
  36655. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36656. */
  36657. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36658. /**
  36659. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  36660. * @param projected sets as the (x,y,z) local projection on the facet
  36661. * @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
  36662. * @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
  36663. * @param x defines x coordinate
  36664. * @param y defines y coordinate
  36665. * @param z defines z coordinate
  36666. * @returns the face index if found (or null instead)
  36667. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36668. */
  36669. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  36670. /**
  36671. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  36672. * @returns the parameters
  36673. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36674. */
  36675. getFacetDataParameters(): any;
  36676. /**
  36677. * Disables the feature FacetData and frees the related memory
  36678. * @returns the current mesh
  36679. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  36680. */
  36681. disableFacetData(): AbstractMesh;
  36682. /**
  36683. * Updates the AbstractMesh indices array
  36684. * @param indices defines the data source
  36685. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  36686. * @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)
  36687. * @returns the current mesh
  36688. */
  36689. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  36690. /**
  36691. * Creates new normals data for the mesh
  36692. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  36693. * @returns the current mesh
  36694. */
  36695. createNormals(updatable: boolean): AbstractMesh;
  36696. /**
  36697. * Align the mesh with a normal
  36698. * @param normal defines the normal to use
  36699. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  36700. * @returns the current mesh
  36701. */
  36702. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  36703. /** @hidden */
  36704. _checkOcclusionQuery(): boolean;
  36705. /**
  36706. * Disables the mesh edge rendering mode
  36707. * @returns the currentAbstractMesh
  36708. */
  36709. disableEdgesRendering(): AbstractMesh;
  36710. /**
  36711. * Enables the edge rendering mode on the mesh.
  36712. * This mode makes the mesh edges visible
  36713. * @param epsilon defines the maximal distance between two angles to detect a face
  36714. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  36715. * @param options options to the edge renderer
  36716. * @returns the currentAbstractMesh
  36717. * @see https://www.babylonjs-playground.com/#19O9TU#0
  36718. */
  36719. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean, options?: IEdgesRendererOptions): AbstractMesh;
  36720. /**
  36721. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  36722. * @returns an array of particle systems in the scene that use the mesh as an emitter
  36723. */
  36724. getConnectedParticleSystems(): IParticleSystem[];
  36725. }
  36726. }
  36727. declare module BABYLON {
  36728. /**
  36729. * Interface used to define ActionEvent
  36730. */
  36731. export interface IActionEvent {
  36732. /** The mesh or sprite that triggered the action */
  36733. source: any;
  36734. /** The X mouse cursor position at the time of the event */
  36735. pointerX: number;
  36736. /** The Y mouse cursor position at the time of the event */
  36737. pointerY: number;
  36738. /** The mesh that is currently pointed at (can be null) */
  36739. meshUnderPointer: Nullable<AbstractMesh>;
  36740. /** the original (browser) event that triggered the ActionEvent */
  36741. sourceEvent?: any;
  36742. /** additional data for the event */
  36743. additionalData?: any;
  36744. }
  36745. /**
  36746. * ActionEvent is the event being sent when an action is triggered.
  36747. */
  36748. export class ActionEvent implements IActionEvent {
  36749. /** The mesh or sprite that triggered the action */
  36750. source: any;
  36751. /** The X mouse cursor position at the time of the event */
  36752. pointerX: number;
  36753. /** The Y mouse cursor position at the time of the event */
  36754. pointerY: number;
  36755. /** The mesh that is currently pointed at (can be null) */
  36756. meshUnderPointer: Nullable<AbstractMesh>;
  36757. /** the original (browser) event that triggered the ActionEvent */
  36758. sourceEvent?: any;
  36759. /** additional data for the event */
  36760. additionalData?: any;
  36761. /**
  36762. * Creates a new ActionEvent
  36763. * @param source The mesh or sprite that triggered the action
  36764. * @param pointerX The X mouse cursor position at the time of the event
  36765. * @param pointerY The Y mouse cursor position at the time of the event
  36766. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  36767. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  36768. * @param additionalData additional data for the event
  36769. */
  36770. constructor(
  36771. /** The mesh or sprite that triggered the action */
  36772. source: any,
  36773. /** The X mouse cursor position at the time of the event */
  36774. pointerX: number,
  36775. /** The Y mouse cursor position at the time of the event */
  36776. pointerY: number,
  36777. /** The mesh that is currently pointed at (can be null) */
  36778. meshUnderPointer: Nullable<AbstractMesh>,
  36779. /** the original (browser) event that triggered the ActionEvent */
  36780. sourceEvent?: any,
  36781. /** additional data for the event */
  36782. additionalData?: any);
  36783. /**
  36784. * Helper function to auto-create an ActionEvent from a source mesh.
  36785. * @param source The source mesh that triggered the event
  36786. * @param evt The original (browser) event
  36787. * @param additionalData additional data for the event
  36788. * @returns the new ActionEvent
  36789. */
  36790. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  36791. /**
  36792. * Helper function to auto-create an ActionEvent from a source sprite
  36793. * @param source The source sprite that triggered the event
  36794. * @param scene Scene associated with the sprite
  36795. * @param evt The original (browser) event
  36796. * @param additionalData additional data for the event
  36797. * @returns the new ActionEvent
  36798. */
  36799. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  36800. /**
  36801. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  36802. * @param scene the scene where the event occurred
  36803. * @param evt The original (browser) event
  36804. * @returns the new ActionEvent
  36805. */
  36806. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  36807. /**
  36808. * Helper function to auto-create an ActionEvent from a primitive
  36809. * @param prim defines the target primitive
  36810. * @param pointerPos defines the pointer position
  36811. * @param evt The original (browser) event
  36812. * @param additionalData additional data for the event
  36813. * @returns the new ActionEvent
  36814. */
  36815. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  36816. }
  36817. }
  36818. declare module BABYLON {
  36819. /**
  36820. * Abstract class used to decouple action Manager from scene and meshes.
  36821. * Do not instantiate.
  36822. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  36823. */
  36824. export abstract class AbstractActionManager implements IDisposable {
  36825. /** Gets the list of active triggers */
  36826. static Triggers: {
  36827. [key: string]: number;
  36828. };
  36829. /** Gets the cursor to use when hovering items */
  36830. hoverCursor: string;
  36831. /** Gets the list of actions */
  36832. actions: IAction[];
  36833. /**
  36834. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36835. */
  36836. isRecursive: boolean;
  36837. /**
  36838. * Releases all associated resources
  36839. */
  36840. abstract dispose(): void;
  36841. /**
  36842. * Does this action manager has pointer triggers
  36843. */
  36844. abstract get hasPointerTriggers(): boolean;
  36845. /**
  36846. * Does this action manager has pick triggers
  36847. */
  36848. abstract get hasPickTriggers(): boolean;
  36849. /**
  36850. * Process a specific trigger
  36851. * @param trigger defines the trigger to process
  36852. * @param evt defines the event details to be processed
  36853. */
  36854. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36855. /**
  36856. * Does this action manager handles actions of any of the given triggers
  36857. * @param triggers defines the triggers to be tested
  36858. * @return a boolean indicating whether one (or more) of the triggers is handled
  36859. */
  36860. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36861. /**
  36862. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36863. * speed.
  36864. * @param triggerA defines the trigger to be tested
  36865. * @param triggerB defines the trigger to be tested
  36866. * @return a boolean indicating whether one (or more) of the triggers is handled
  36867. */
  36868. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36869. /**
  36870. * Does this action manager handles actions of a given trigger
  36871. * @param trigger defines the trigger to be tested
  36872. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36873. * @return whether the trigger is handled
  36874. */
  36875. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36876. /**
  36877. * Serialize this manager to a JSON object
  36878. * @param name defines the property name to store this manager
  36879. * @returns a JSON representation of this manager
  36880. */
  36881. abstract serialize(name: string): any;
  36882. /**
  36883. * Registers an action to this action manager
  36884. * @param action defines the action to be registered
  36885. * @return the action amended (prepared) after registration
  36886. */
  36887. abstract registerAction(action: IAction): Nullable<IAction>;
  36888. /**
  36889. * Unregisters an action to this action manager
  36890. * @param action defines the action to be unregistered
  36891. * @return a boolean indicating whether the action has been unregistered
  36892. */
  36893. abstract unregisterAction(action: IAction): Boolean;
  36894. /**
  36895. * Does exist one action manager with at least one trigger
  36896. **/
  36897. static get HasTriggers(): boolean;
  36898. /**
  36899. * Does exist one action manager with at least one pick trigger
  36900. **/
  36901. static get HasPickTriggers(): boolean;
  36902. /**
  36903. * Does exist one action manager that handles actions of a given trigger
  36904. * @param trigger defines the trigger to be tested
  36905. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36906. **/
  36907. static HasSpecificTrigger(trigger: number): boolean;
  36908. }
  36909. }
  36910. declare module BABYLON {
  36911. /**
  36912. * Defines how a node can be built from a string name.
  36913. */
  36914. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36915. /**
  36916. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36917. */
  36918. export class Node implements IBehaviorAware<Node> {
  36919. /** @hidden */
  36920. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36921. private static _NodeConstructors;
  36922. /**
  36923. * Add a new node constructor
  36924. * @param type defines the type name of the node to construct
  36925. * @param constructorFunc defines the constructor function
  36926. */
  36927. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36928. /**
  36929. * Returns a node constructor based on type name
  36930. * @param type defines the type name
  36931. * @param name defines the new node name
  36932. * @param scene defines the hosting scene
  36933. * @param options defines optional options to transmit to constructors
  36934. * @returns the new constructor or null
  36935. */
  36936. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36937. /**
  36938. * Gets or sets the name of the node
  36939. */
  36940. name: string;
  36941. /**
  36942. * Gets or sets the id of the node
  36943. */
  36944. id: string;
  36945. /**
  36946. * Gets or sets the unique id of the node
  36947. */
  36948. uniqueId: number;
  36949. /**
  36950. * Gets or sets a string used to store user defined state for the node
  36951. */
  36952. state: string;
  36953. /**
  36954. * Gets or sets an object used to store user defined information for the node
  36955. */
  36956. metadata: any;
  36957. /**
  36958. * For internal use only. Please do not use.
  36959. */
  36960. reservedDataStore: any;
  36961. /**
  36962. * List of inspectable custom properties (used by the Inspector)
  36963. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36964. */
  36965. inspectableCustomProperties: IInspectable[];
  36966. private _doNotSerialize;
  36967. /**
  36968. * Gets or sets a boolean used to define if the node must be serialized
  36969. */
  36970. get doNotSerialize(): boolean;
  36971. set doNotSerialize(value: boolean);
  36972. /** @hidden */
  36973. _isDisposed: boolean;
  36974. /**
  36975. * Gets a list of Animations associated with the node
  36976. */
  36977. animations: Animation[];
  36978. protected _ranges: {
  36979. [name: string]: Nullable<AnimationRange>;
  36980. };
  36981. /**
  36982. * Callback raised when the node is ready to be used
  36983. */
  36984. onReady: Nullable<(node: Node) => void>;
  36985. private _isEnabled;
  36986. private _isParentEnabled;
  36987. private _isReady;
  36988. /** @hidden */
  36989. _currentRenderId: number;
  36990. private _parentUpdateId;
  36991. /** @hidden */
  36992. _childUpdateId: number;
  36993. /** @hidden */
  36994. _waitingParentId: Nullable<string>;
  36995. /** @hidden */
  36996. _scene: Scene;
  36997. /** @hidden */
  36998. _cache: any;
  36999. private _parentNode;
  37000. private _children;
  37001. /** @hidden */
  37002. _worldMatrix: Matrix;
  37003. /** @hidden */
  37004. _worldMatrixDeterminant: number;
  37005. /** @hidden */
  37006. _worldMatrixDeterminantIsDirty: boolean;
  37007. /** @hidden */
  37008. private _sceneRootNodesIndex;
  37009. /**
  37010. * Gets a boolean indicating if the node has been disposed
  37011. * @returns true if the node was disposed
  37012. */
  37013. isDisposed(): boolean;
  37014. /**
  37015. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37016. * @see https://doc.babylonjs.com/how_to/parenting
  37017. */
  37018. set parent(parent: Nullable<Node>);
  37019. get parent(): Nullable<Node>;
  37020. /** @hidden */
  37021. _addToSceneRootNodes(): void;
  37022. /** @hidden */
  37023. _removeFromSceneRootNodes(): void;
  37024. private _animationPropertiesOverride;
  37025. /**
  37026. * Gets or sets the animation properties override
  37027. */
  37028. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37029. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37030. /**
  37031. * Gets a string identifying the name of the class
  37032. * @returns "Node" string
  37033. */
  37034. getClassName(): string;
  37035. /** @hidden */
  37036. readonly _isNode: boolean;
  37037. /**
  37038. * An event triggered when the mesh is disposed
  37039. */
  37040. onDisposeObservable: Observable<Node>;
  37041. private _onDisposeObserver;
  37042. /**
  37043. * Sets a callback that will be raised when the node will be disposed
  37044. */
  37045. set onDispose(callback: () => void);
  37046. /**
  37047. * Creates a new Node
  37048. * @param name the name and id to be given to this node
  37049. * @param scene the scene this node will be added to
  37050. */
  37051. constructor(name: string, scene?: Nullable<Scene>);
  37052. /**
  37053. * Gets the scene of the node
  37054. * @returns a scene
  37055. */
  37056. getScene(): Scene;
  37057. /**
  37058. * Gets the engine of the node
  37059. * @returns a Engine
  37060. */
  37061. getEngine(): Engine;
  37062. private _behaviors;
  37063. /**
  37064. * Attach a behavior to the node
  37065. * @see https://doc.babylonjs.com/features/behaviour
  37066. * @param behavior defines the behavior to attach
  37067. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37068. * @returns the current Node
  37069. */
  37070. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37071. /**
  37072. * Remove an attached behavior
  37073. * @see https://doc.babylonjs.com/features/behaviour
  37074. * @param behavior defines the behavior to attach
  37075. * @returns the current Node
  37076. */
  37077. removeBehavior(behavior: Behavior<Node>): Node;
  37078. /**
  37079. * Gets the list of attached behaviors
  37080. * @see https://doc.babylonjs.com/features/behaviour
  37081. */
  37082. get behaviors(): Behavior<Node>[];
  37083. /**
  37084. * Gets an attached behavior by name
  37085. * @param name defines the name of the behavior to look for
  37086. * @see https://doc.babylonjs.com/features/behaviour
  37087. * @returns null if behavior was not found else the requested behavior
  37088. */
  37089. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  37090. /**
  37091. * Returns the latest update of the World matrix
  37092. * @returns a Matrix
  37093. */
  37094. getWorldMatrix(): Matrix;
  37095. /** @hidden */
  37096. _getWorldMatrixDeterminant(): number;
  37097. /**
  37098. * Returns directly the latest state of the mesh World matrix.
  37099. * A Matrix is returned.
  37100. */
  37101. get worldMatrixFromCache(): Matrix;
  37102. /** @hidden */
  37103. _initCache(): void;
  37104. /** @hidden */
  37105. updateCache(force?: boolean): void;
  37106. /** @hidden */
  37107. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37108. /** @hidden */
  37109. _updateCache(ignoreParentClass?: boolean): void;
  37110. /** @hidden */
  37111. _isSynchronized(): boolean;
  37112. /** @hidden */
  37113. _markSyncedWithParent(): void;
  37114. /** @hidden */
  37115. isSynchronizedWithParent(): boolean;
  37116. /** @hidden */
  37117. isSynchronized(): boolean;
  37118. /**
  37119. * Is this node ready to be used/rendered
  37120. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  37121. * @return true if the node is ready
  37122. */
  37123. isReady(completeCheck?: boolean): boolean;
  37124. /**
  37125. * Is this node enabled?
  37126. * 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
  37127. * @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
  37128. * @return whether this node (and its parent) is enabled
  37129. */
  37130. isEnabled(checkAncestors?: boolean): boolean;
  37131. /** @hidden */
  37132. protected _syncParentEnabledState(): void;
  37133. /**
  37134. * Set the enabled state of this node
  37135. * @param value defines the new enabled state
  37136. */
  37137. setEnabled(value: boolean): void;
  37138. /**
  37139. * Is this node a descendant of the given node?
  37140. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  37141. * @param ancestor defines the parent node to inspect
  37142. * @returns a boolean indicating if this node is a descendant of the given node
  37143. */
  37144. isDescendantOf(ancestor: Node): boolean;
  37145. /** @hidden */
  37146. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  37147. /**
  37148. * Will return all nodes that have this node as ascendant
  37149. * @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
  37150. * @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
  37151. * @return all children nodes of all types
  37152. */
  37153. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  37154. /**
  37155. * Get all child-meshes of this node
  37156. * @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)
  37157. * @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
  37158. * @returns an array of AbstractMesh
  37159. */
  37160. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  37161. /**
  37162. * Get all direct children of this node
  37163. * @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
  37164. * @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)
  37165. * @returns an array of Node
  37166. */
  37167. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  37168. /** @hidden */
  37169. _setReady(state: boolean): void;
  37170. /**
  37171. * Get an animation by name
  37172. * @param name defines the name of the animation to look for
  37173. * @returns null if not found else the requested animation
  37174. */
  37175. getAnimationByName(name: string): Nullable<Animation>;
  37176. /**
  37177. * Creates an animation range for this node
  37178. * @param name defines the name of the range
  37179. * @param from defines the starting key
  37180. * @param to defines the end key
  37181. */
  37182. createAnimationRange(name: string, from: number, to: number): void;
  37183. /**
  37184. * Delete a specific animation range
  37185. * @param name defines the name of the range to delete
  37186. * @param deleteFrames defines if animation frames from the range must be deleted as well
  37187. */
  37188. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  37189. /**
  37190. * Get an animation range by name
  37191. * @param name defines the name of the animation range to look for
  37192. * @returns null if not found else the requested animation range
  37193. */
  37194. getAnimationRange(name: string): Nullable<AnimationRange>;
  37195. /**
  37196. * Gets the list of all animation ranges defined on this node
  37197. * @returns an array
  37198. */
  37199. getAnimationRanges(): Nullable<AnimationRange>[];
  37200. /**
  37201. * Will start the animation sequence
  37202. * @param name defines the range frames for animation sequence
  37203. * @param loop defines if the animation should loop (false by default)
  37204. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  37205. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  37206. * @returns the object created for this animation. If range does not exist, it will return null
  37207. */
  37208. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  37209. /**
  37210. * Serialize animation ranges into a JSON compatible object
  37211. * @returns serialization object
  37212. */
  37213. serializeAnimationRanges(): any;
  37214. /**
  37215. * Computes the world matrix of the node
  37216. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  37217. * @returns the world matrix
  37218. */
  37219. computeWorldMatrix(force?: boolean): Matrix;
  37220. /**
  37221. * Releases resources associated with this node.
  37222. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37223. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37224. */
  37225. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37226. /**
  37227. * Parse animation range data from a serialization object and store them into a given node
  37228. * @param node defines where to store the animation ranges
  37229. * @param parsedNode defines the serialization object to read data from
  37230. * @param scene defines the hosting scene
  37231. */
  37232. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  37233. /**
  37234. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  37235. * @param includeDescendants Include bounding info from descendants as well (true by default)
  37236. * @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
  37237. * @returns the new bounding vectors
  37238. */
  37239. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  37240. min: Vector3;
  37241. max: Vector3;
  37242. };
  37243. }
  37244. }
  37245. declare module BABYLON {
  37246. /**
  37247. * @hidden
  37248. */
  37249. export class _IAnimationState {
  37250. key: number;
  37251. repeatCount: number;
  37252. workValue?: any;
  37253. loopMode?: number;
  37254. offsetValue?: any;
  37255. highLimitValue?: any;
  37256. }
  37257. /**
  37258. * Class used to store any kind of animation
  37259. */
  37260. export class Animation {
  37261. /**Name of the animation */
  37262. name: string;
  37263. /**Property to animate */
  37264. targetProperty: string;
  37265. /**The frames per second of the animation */
  37266. framePerSecond: number;
  37267. /**The data type of the animation */
  37268. dataType: number;
  37269. /**The loop mode of the animation */
  37270. loopMode?: number | undefined;
  37271. /**Specifies if blending should be enabled */
  37272. enableBlending?: boolean | undefined;
  37273. /**
  37274. * Use matrix interpolation instead of using direct key value when animating matrices
  37275. */
  37276. static AllowMatricesInterpolation: boolean;
  37277. /**
  37278. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  37279. */
  37280. static AllowMatrixDecomposeForInterpolation: boolean;
  37281. /** Define the Url to load snippets */
  37282. static SnippetUrl: string;
  37283. /** Snippet ID if the animation was created from the snippet server */
  37284. snippetId: string;
  37285. /**
  37286. * Stores the key frames of the animation
  37287. */
  37288. private _keys;
  37289. /**
  37290. * Stores the easing function of the animation
  37291. */
  37292. private _easingFunction;
  37293. /**
  37294. * @hidden Internal use only
  37295. */
  37296. _runtimeAnimations: RuntimeAnimation[];
  37297. /**
  37298. * The set of event that will be linked to this animation
  37299. */
  37300. private _events;
  37301. /**
  37302. * Stores an array of target property paths
  37303. */
  37304. targetPropertyPath: string[];
  37305. /**
  37306. * Stores the blending speed of the animation
  37307. */
  37308. blendingSpeed: number;
  37309. /**
  37310. * Stores the animation ranges for the animation
  37311. */
  37312. private _ranges;
  37313. /**
  37314. * @hidden Internal use
  37315. */
  37316. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  37317. /**
  37318. * Sets up an animation
  37319. * @param property The property to animate
  37320. * @param animationType The animation type to apply
  37321. * @param framePerSecond The frames per second of the animation
  37322. * @param easingFunction The easing function used in the animation
  37323. * @returns The created animation
  37324. */
  37325. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  37326. /**
  37327. * Create and start an animation on a node
  37328. * @param name defines the name of the global animation that will be run on all nodes
  37329. * @param node defines the root node where the animation will take place
  37330. * @param targetProperty defines property to animate
  37331. * @param framePerSecond defines the number of frame per second yo use
  37332. * @param totalFrame defines the number of frames in total
  37333. * @param from defines the initial value
  37334. * @param to defines the final value
  37335. * @param loopMode defines which loop mode you want to use (off by default)
  37336. * @param easingFunction defines the easing function to use (linear by default)
  37337. * @param onAnimationEnd defines the callback to call when animation end
  37338. * @returns the animatable created for this animation
  37339. */
  37340. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37341. /**
  37342. * Create and start an animation on a node and its descendants
  37343. * @param name defines the name of the global animation that will be run on all nodes
  37344. * @param node defines the root node where the animation will take place
  37345. * @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
  37346. * @param targetProperty defines property to animate
  37347. * @param framePerSecond defines the number of frame per second to use
  37348. * @param totalFrame defines the number of frames in total
  37349. * @param from defines the initial value
  37350. * @param to defines the final value
  37351. * @param loopMode defines which loop mode you want to use (off by default)
  37352. * @param easingFunction defines the easing function to use (linear by default)
  37353. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  37354. * @returns the list of animatables created for all nodes
  37355. * @example https://www.babylonjs-playground.com/#MH0VLI
  37356. */
  37357. 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[]>;
  37358. /**
  37359. * Creates a new animation, merges it with the existing animations and starts it
  37360. * @param name Name of the animation
  37361. * @param node Node which contains the scene that begins the animations
  37362. * @param targetProperty Specifies which property to animate
  37363. * @param framePerSecond The frames per second of the animation
  37364. * @param totalFrame The total number of frames
  37365. * @param from The frame at the beginning of the animation
  37366. * @param to The frame at the end of the animation
  37367. * @param loopMode Specifies the loop mode of the animation
  37368. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  37369. * @param onAnimationEnd Callback to run once the animation is complete
  37370. * @returns Nullable animation
  37371. */
  37372. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  37373. /**
  37374. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  37375. * @param sourceAnimation defines the Animation containing keyframes to convert
  37376. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  37377. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  37378. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  37379. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  37380. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  37381. */
  37382. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  37383. /**
  37384. * Transition property of an host to the target Value
  37385. * @param property The property to transition
  37386. * @param targetValue The target Value of the property
  37387. * @param host The object where the property to animate belongs
  37388. * @param scene Scene used to run the animation
  37389. * @param frameRate Framerate (in frame/s) to use
  37390. * @param transition The transition type we want to use
  37391. * @param duration The duration of the animation, in milliseconds
  37392. * @param onAnimationEnd Callback trigger at the end of the animation
  37393. * @returns Nullable animation
  37394. */
  37395. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  37396. /**
  37397. * Return the array of runtime animations currently using this animation
  37398. */
  37399. get runtimeAnimations(): RuntimeAnimation[];
  37400. /**
  37401. * Specifies if any of the runtime animations are currently running
  37402. */
  37403. get hasRunningRuntimeAnimations(): boolean;
  37404. /**
  37405. * Initializes the animation
  37406. * @param name Name of the animation
  37407. * @param targetProperty Property to animate
  37408. * @param framePerSecond The frames per second of the animation
  37409. * @param dataType The data type of the animation
  37410. * @param loopMode The loop mode of the animation
  37411. * @param enableBlending Specifies if blending should be enabled
  37412. */
  37413. constructor(
  37414. /**Name of the animation */
  37415. name: string,
  37416. /**Property to animate */
  37417. targetProperty: string,
  37418. /**The frames per second of the animation */
  37419. framePerSecond: number,
  37420. /**The data type of the animation */
  37421. dataType: number,
  37422. /**The loop mode of the animation */
  37423. loopMode?: number | undefined,
  37424. /**Specifies if blending should be enabled */
  37425. enableBlending?: boolean | undefined);
  37426. /**
  37427. * Converts the animation to a string
  37428. * @param fullDetails support for multiple levels of logging within scene loading
  37429. * @returns String form of the animation
  37430. */
  37431. toString(fullDetails?: boolean): string;
  37432. /**
  37433. * Add an event to this animation
  37434. * @param event Event to add
  37435. */
  37436. addEvent(event: AnimationEvent): void;
  37437. /**
  37438. * Remove all events found at the given frame
  37439. * @param frame The frame to remove events from
  37440. */
  37441. removeEvents(frame: number): void;
  37442. /**
  37443. * Retrieves all the events from the animation
  37444. * @returns Events from the animation
  37445. */
  37446. getEvents(): AnimationEvent[];
  37447. /**
  37448. * Creates an animation range
  37449. * @param name Name of the animation range
  37450. * @param from Starting frame of the animation range
  37451. * @param to Ending frame of the animation
  37452. */
  37453. createRange(name: string, from: number, to: number): void;
  37454. /**
  37455. * Deletes an animation range by name
  37456. * @param name Name of the animation range to delete
  37457. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  37458. */
  37459. deleteRange(name: string, deleteFrames?: boolean): void;
  37460. /**
  37461. * Gets the animation range by name, or null if not defined
  37462. * @param name Name of the animation range
  37463. * @returns Nullable animation range
  37464. */
  37465. getRange(name: string): Nullable<AnimationRange>;
  37466. /**
  37467. * Gets the key frames from the animation
  37468. * @returns The key frames of the animation
  37469. */
  37470. getKeys(): Array<IAnimationKey>;
  37471. /**
  37472. * Gets the highest frame rate of the animation
  37473. * @returns Highest frame rate of the animation
  37474. */
  37475. getHighestFrame(): number;
  37476. /**
  37477. * Gets the easing function of the animation
  37478. * @returns Easing function of the animation
  37479. */
  37480. getEasingFunction(): IEasingFunction;
  37481. /**
  37482. * Sets the easing function of the animation
  37483. * @param easingFunction A custom mathematical formula for animation
  37484. */
  37485. setEasingFunction(easingFunction: EasingFunction): void;
  37486. /**
  37487. * Interpolates a scalar linearly
  37488. * @param startValue Start value of the animation curve
  37489. * @param endValue End value of the animation curve
  37490. * @param gradient Scalar amount to interpolate
  37491. * @returns Interpolated scalar value
  37492. */
  37493. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  37494. /**
  37495. * Interpolates a scalar cubically
  37496. * @param startValue Start value of the animation curve
  37497. * @param outTangent End tangent of the animation
  37498. * @param endValue End value of the animation curve
  37499. * @param inTangent Start tangent of the animation curve
  37500. * @param gradient Scalar amount to interpolate
  37501. * @returns Interpolated scalar value
  37502. */
  37503. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  37504. /**
  37505. * Interpolates a quaternion using a spherical linear interpolation
  37506. * @param startValue Start value of the animation curve
  37507. * @param endValue End value of the animation curve
  37508. * @param gradient Scalar amount to interpolate
  37509. * @returns Interpolated quaternion value
  37510. */
  37511. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  37512. /**
  37513. * Interpolates a quaternion cubically
  37514. * @param startValue Start value of the animation curve
  37515. * @param outTangent End tangent of the animation curve
  37516. * @param endValue End value of the animation curve
  37517. * @param inTangent Start tangent of the animation curve
  37518. * @param gradient Scalar amount to interpolate
  37519. * @returns Interpolated quaternion value
  37520. */
  37521. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  37522. /**
  37523. * Interpolates a Vector3 linearl
  37524. * @param startValue Start value of the animation curve
  37525. * @param endValue End value of the animation curve
  37526. * @param gradient Scalar amount to interpolate
  37527. * @returns Interpolated scalar value
  37528. */
  37529. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  37530. /**
  37531. * Interpolates a Vector3 cubically
  37532. * @param startValue Start value of the animation curve
  37533. * @param outTangent End tangent of the animation
  37534. * @param endValue End value of the animation curve
  37535. * @param inTangent Start tangent of the animation curve
  37536. * @param gradient Scalar amount to interpolate
  37537. * @returns InterpolatedVector3 value
  37538. */
  37539. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  37540. /**
  37541. * Interpolates a Vector2 linearly
  37542. * @param startValue Start value of the animation curve
  37543. * @param endValue End value of the animation curve
  37544. * @param gradient Scalar amount to interpolate
  37545. * @returns Interpolated Vector2 value
  37546. */
  37547. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  37548. /**
  37549. * Interpolates a Vector2 cubically
  37550. * @param startValue Start value of the animation curve
  37551. * @param outTangent End tangent of the animation
  37552. * @param endValue End value of the animation curve
  37553. * @param inTangent Start tangent of the animation curve
  37554. * @param gradient Scalar amount to interpolate
  37555. * @returns Interpolated Vector2 value
  37556. */
  37557. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  37558. /**
  37559. * Interpolates a size linearly
  37560. * @param startValue Start value of the animation curve
  37561. * @param endValue End value of the animation curve
  37562. * @param gradient Scalar amount to interpolate
  37563. * @returns Interpolated Size value
  37564. */
  37565. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  37566. /**
  37567. * Interpolates a Color3 linearly
  37568. * @param startValue Start value of the animation curve
  37569. * @param endValue End value of the animation curve
  37570. * @param gradient Scalar amount to interpolate
  37571. * @returns Interpolated Color3 value
  37572. */
  37573. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  37574. /**
  37575. * Interpolates a Color4 linearly
  37576. * @param startValue Start value of the animation curve
  37577. * @param endValue End value of the animation curve
  37578. * @param gradient Scalar amount to interpolate
  37579. * @returns Interpolated Color3 value
  37580. */
  37581. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  37582. /**
  37583. * @hidden Internal use only
  37584. */
  37585. _getKeyValue(value: any): any;
  37586. /**
  37587. * @hidden Internal use only
  37588. */
  37589. _interpolate(currentFrame: number, state: _IAnimationState): any;
  37590. /**
  37591. * Defines the function to use to interpolate matrices
  37592. * @param startValue defines the start matrix
  37593. * @param endValue defines the end matrix
  37594. * @param gradient defines the gradient between both matrices
  37595. * @param result defines an optional target matrix where to store the interpolation
  37596. * @returns the interpolated matrix
  37597. */
  37598. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  37599. /**
  37600. * Makes a copy of the animation
  37601. * @returns Cloned animation
  37602. */
  37603. clone(): Animation;
  37604. /**
  37605. * Sets the key frames of the animation
  37606. * @param values The animation key frames to set
  37607. */
  37608. setKeys(values: Array<IAnimationKey>): void;
  37609. /**
  37610. * Serializes the animation to an object
  37611. * @returns Serialized object
  37612. */
  37613. serialize(): any;
  37614. /**
  37615. * Float animation type
  37616. */
  37617. static readonly ANIMATIONTYPE_FLOAT: number;
  37618. /**
  37619. * Vector3 animation type
  37620. */
  37621. static readonly ANIMATIONTYPE_VECTOR3: number;
  37622. /**
  37623. * Quaternion animation type
  37624. */
  37625. static readonly ANIMATIONTYPE_QUATERNION: number;
  37626. /**
  37627. * Matrix animation type
  37628. */
  37629. static readonly ANIMATIONTYPE_MATRIX: number;
  37630. /**
  37631. * Color3 animation type
  37632. */
  37633. static readonly ANIMATIONTYPE_COLOR3: number;
  37634. /**
  37635. * Color3 animation type
  37636. */
  37637. static readonly ANIMATIONTYPE_COLOR4: number;
  37638. /**
  37639. * Vector2 animation type
  37640. */
  37641. static readonly ANIMATIONTYPE_VECTOR2: number;
  37642. /**
  37643. * Size animation type
  37644. */
  37645. static readonly ANIMATIONTYPE_SIZE: number;
  37646. /**
  37647. * Relative Loop Mode
  37648. */
  37649. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  37650. /**
  37651. * Cycle Loop Mode
  37652. */
  37653. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  37654. /**
  37655. * Constant Loop Mode
  37656. */
  37657. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  37658. /** @hidden */
  37659. static _UniversalLerp(left: any, right: any, amount: number): any;
  37660. /**
  37661. * Parses an animation object and creates an animation
  37662. * @param parsedAnimation Parsed animation object
  37663. * @returns Animation object
  37664. */
  37665. static Parse(parsedAnimation: any): Animation;
  37666. /**
  37667. * Appends the serialized animations from the source animations
  37668. * @param source Source containing the animations
  37669. * @param destination Target to store the animations
  37670. */
  37671. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37672. /**
  37673. * Creates a new animation or an array of animations from a snippet saved in a remote file
  37674. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  37675. * @param url defines the url to load from
  37676. * @returns a promise that will resolve to the new animation or an array of animations
  37677. */
  37678. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  37679. /**
  37680. * Creates an animation or an array of animations from a snippet saved by the Inspector
  37681. * @param snippetId defines the snippet to load
  37682. * @returns a promise that will resolve to the new animation or a new array of animations
  37683. */
  37684. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  37685. }
  37686. }
  37687. declare module BABYLON {
  37688. /**
  37689. * Interface containing an array of animations
  37690. */
  37691. export interface IAnimatable {
  37692. /**
  37693. * Array of animations
  37694. */
  37695. animations: Nullable<Array<Animation>>;
  37696. }
  37697. }
  37698. declare module BABYLON {
  37699. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  37700. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37701. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37702. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37703. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37704. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37705. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37706. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37707. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37708. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37709. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37710. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37711. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37712. /**
  37713. * Decorator used to define property that can be serialized as reference to a camera
  37714. * @param sourceName defines the name of the property to decorate
  37715. */
  37716. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  37717. /**
  37718. * Class used to help serialization objects
  37719. */
  37720. export class SerializationHelper {
  37721. /** @hidden */
  37722. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  37723. /** @hidden */
  37724. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  37725. /** @hidden */
  37726. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  37727. /** @hidden */
  37728. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  37729. /**
  37730. * Appends the serialized animations from the source animations
  37731. * @param source Source containing the animations
  37732. * @param destination Target to store the animations
  37733. */
  37734. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  37735. /**
  37736. * Static function used to serialized a specific entity
  37737. * @param entity defines the entity to serialize
  37738. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  37739. * @returns a JSON compatible object representing the serialization of the entity
  37740. */
  37741. static Serialize<T>(entity: T, serializationObject?: any): any;
  37742. /**
  37743. * Creates a new entity from a serialization data object
  37744. * @param creationFunction defines a function used to instanciated the new entity
  37745. * @param source defines the source serialization data
  37746. * @param scene defines the hosting scene
  37747. * @param rootUrl defines the root url for resources
  37748. * @returns a new entity
  37749. */
  37750. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  37751. /**
  37752. * Clones an object
  37753. * @param creationFunction defines the function used to instanciate the new object
  37754. * @param source defines the source object
  37755. * @returns the cloned object
  37756. */
  37757. static Clone<T>(creationFunction: () => T, source: T): T;
  37758. /**
  37759. * Instanciates a new object based on a source one (some data will be shared between both object)
  37760. * @param creationFunction defines the function used to instanciate the new object
  37761. * @param source defines the source object
  37762. * @returns the new object
  37763. */
  37764. static Instanciate<T>(creationFunction: () => T, source: T): T;
  37765. }
  37766. }
  37767. declare module BABYLON {
  37768. /**
  37769. * This is the base class of all the camera used in the application.
  37770. * @see https://doc.babylonjs.com/features/cameras
  37771. */
  37772. export class Camera extends Node {
  37773. /** @hidden */
  37774. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  37775. /**
  37776. * This is the default projection mode used by the cameras.
  37777. * It helps recreating a feeling of perspective and better appreciate depth.
  37778. * This is the best way to simulate real life cameras.
  37779. */
  37780. static readonly PERSPECTIVE_CAMERA: number;
  37781. /**
  37782. * This helps creating camera with an orthographic mode.
  37783. * 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.
  37784. */
  37785. static readonly ORTHOGRAPHIC_CAMERA: number;
  37786. /**
  37787. * This is the default FOV mode for perspective cameras.
  37788. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  37789. */
  37790. static readonly FOVMODE_VERTICAL_FIXED: number;
  37791. /**
  37792. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  37793. */
  37794. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  37795. /**
  37796. * This specifies ther is no need for a camera rig.
  37797. * Basically only one eye is rendered corresponding to the camera.
  37798. */
  37799. static readonly RIG_MODE_NONE: number;
  37800. /**
  37801. * Simulates a camera Rig with one blue eye and one red eye.
  37802. * This can be use with 3d blue and red glasses.
  37803. */
  37804. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  37805. /**
  37806. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  37807. */
  37808. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  37809. /**
  37810. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  37811. */
  37812. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  37813. /**
  37814. * Defines that both eyes of the camera will be rendered over under each other.
  37815. */
  37816. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  37817. /**
  37818. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  37819. */
  37820. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  37821. /**
  37822. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  37823. */
  37824. static readonly RIG_MODE_VR: number;
  37825. /**
  37826. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  37827. */
  37828. static readonly RIG_MODE_WEBVR: number;
  37829. /**
  37830. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  37831. */
  37832. static readonly RIG_MODE_CUSTOM: number;
  37833. /**
  37834. * Defines if by default attaching controls should prevent the default javascript event to continue.
  37835. */
  37836. static ForceAttachControlToAlwaysPreventDefault: boolean;
  37837. /**
  37838. * Define the input manager associated with the camera.
  37839. */
  37840. inputs: CameraInputsManager<Camera>;
  37841. /** @hidden */
  37842. _position: Vector3;
  37843. /**
  37844. * Define the current local position of the camera in the scene
  37845. */
  37846. get position(): Vector3;
  37847. set position(newPosition: Vector3);
  37848. protected _upVector: Vector3;
  37849. /**
  37850. * The vector the camera should consider as up.
  37851. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  37852. */
  37853. set upVector(vec: Vector3);
  37854. get upVector(): Vector3;
  37855. /**
  37856. * Define the current limit on the left side for an orthographic camera
  37857. * In scene unit
  37858. */
  37859. orthoLeft: Nullable<number>;
  37860. /**
  37861. * Define the current limit on the right side for an orthographic camera
  37862. * In scene unit
  37863. */
  37864. orthoRight: Nullable<number>;
  37865. /**
  37866. * Define the current limit on the bottom side for an orthographic camera
  37867. * In scene unit
  37868. */
  37869. orthoBottom: Nullable<number>;
  37870. /**
  37871. * Define the current limit on the top side for an orthographic camera
  37872. * In scene unit
  37873. */
  37874. orthoTop: Nullable<number>;
  37875. /**
  37876. * Field Of View is set in Radians. (default is 0.8)
  37877. */
  37878. fov: number;
  37879. /**
  37880. * Define the minimum distance the camera can see from.
  37881. * This is important to note that the depth buffer are not infinite and the closer it starts
  37882. * the more your scene might encounter depth fighting issue.
  37883. */
  37884. minZ: number;
  37885. /**
  37886. * Define the maximum distance the camera can see to.
  37887. * This is important to note that the depth buffer are not infinite and the further it end
  37888. * the more your scene might encounter depth fighting issue.
  37889. */
  37890. maxZ: number;
  37891. /**
  37892. * Define the default inertia of the camera.
  37893. * This helps giving a smooth feeling to the camera movement.
  37894. */
  37895. inertia: number;
  37896. /**
  37897. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  37898. */
  37899. mode: number;
  37900. /**
  37901. * Define whether the camera is intermediate.
  37902. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  37903. */
  37904. isIntermediate: boolean;
  37905. /**
  37906. * Define the viewport of the camera.
  37907. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  37908. */
  37909. viewport: Viewport;
  37910. /**
  37911. * Restricts the camera to viewing objects with the same layerMask.
  37912. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  37913. */
  37914. layerMask: number;
  37915. /**
  37916. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  37917. */
  37918. fovMode: number;
  37919. /**
  37920. * Rig mode of the camera.
  37921. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  37922. * This is normally controlled byt the camera themselves as internal use.
  37923. */
  37924. cameraRigMode: number;
  37925. /**
  37926. * Defines the distance between both "eyes" in case of a RIG
  37927. */
  37928. interaxialDistance: number;
  37929. /**
  37930. * Defines if stereoscopic rendering is done side by side or over under.
  37931. */
  37932. isStereoscopicSideBySide: boolean;
  37933. /**
  37934. * 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
  37935. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  37936. * else in the scene. (Eg. security camera)
  37937. *
  37938. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  37939. */
  37940. customRenderTargets: RenderTargetTexture[];
  37941. /**
  37942. * When set, the camera will render to this render target instead of the default canvas
  37943. *
  37944. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  37945. */
  37946. outputRenderTarget: Nullable<RenderTargetTexture>;
  37947. /**
  37948. * Observable triggered when the camera view matrix has changed.
  37949. */
  37950. onViewMatrixChangedObservable: Observable<Camera>;
  37951. /**
  37952. * Observable triggered when the camera Projection matrix has changed.
  37953. */
  37954. onProjectionMatrixChangedObservable: Observable<Camera>;
  37955. /**
  37956. * Observable triggered when the inputs have been processed.
  37957. */
  37958. onAfterCheckInputsObservable: Observable<Camera>;
  37959. /**
  37960. * Observable triggered when reset has been called and applied to the camera.
  37961. */
  37962. onRestoreStateObservable: Observable<Camera>;
  37963. /**
  37964. * Is this camera a part of a rig system?
  37965. */
  37966. isRigCamera: boolean;
  37967. /**
  37968. * If isRigCamera set to true this will be set with the parent camera.
  37969. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  37970. */
  37971. rigParent?: Camera;
  37972. /** @hidden */
  37973. _cameraRigParams: any;
  37974. /** @hidden */
  37975. _rigCameras: Camera[];
  37976. /** @hidden */
  37977. _rigPostProcess: Nullable<PostProcess>;
  37978. protected _webvrViewMatrix: Matrix;
  37979. /** @hidden */
  37980. _skipRendering: boolean;
  37981. /** @hidden */
  37982. _projectionMatrix: Matrix;
  37983. /** @hidden */
  37984. _postProcesses: Nullable<PostProcess>[];
  37985. /** @hidden */
  37986. _activeMeshes: SmartArray<AbstractMesh>;
  37987. protected _globalPosition: Vector3;
  37988. /** @hidden */
  37989. _computedViewMatrix: Matrix;
  37990. private _doNotComputeProjectionMatrix;
  37991. private _transformMatrix;
  37992. private _frustumPlanes;
  37993. private _refreshFrustumPlanes;
  37994. private _storedFov;
  37995. private _stateStored;
  37996. /**
  37997. * Instantiates a new camera object.
  37998. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  37999. * @see https://doc.babylonjs.com/features/cameras
  38000. * @param name Defines the name of the camera in the scene
  38001. * @param position Defines the position of the camera
  38002. * @param scene Defines the scene the camera belongs too
  38003. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  38004. */
  38005. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38006. /**
  38007. * Store current camera state (fov, position, etc..)
  38008. * @returns the camera
  38009. */
  38010. storeState(): Camera;
  38011. /**
  38012. * Restores the camera state values if it has been stored. You must call storeState() first
  38013. */
  38014. protected _restoreStateValues(): boolean;
  38015. /**
  38016. * Restored camera state. You must call storeState() first.
  38017. * @returns true if restored and false otherwise
  38018. */
  38019. restoreState(): boolean;
  38020. /**
  38021. * Gets the class name of the camera.
  38022. * @returns the class name
  38023. */
  38024. getClassName(): string;
  38025. /** @hidden */
  38026. readonly _isCamera: boolean;
  38027. /**
  38028. * Gets a string representation of the camera useful for debug purpose.
  38029. * @param fullDetails Defines that a more verboe level of logging is required
  38030. * @returns the string representation
  38031. */
  38032. toString(fullDetails?: boolean): string;
  38033. /**
  38034. * Gets the current world space position of the camera.
  38035. */
  38036. get globalPosition(): Vector3;
  38037. /**
  38038. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  38039. * @returns the active meshe list
  38040. */
  38041. getActiveMeshes(): SmartArray<AbstractMesh>;
  38042. /**
  38043. * Check whether a mesh is part of the current active mesh list of the camera
  38044. * @param mesh Defines the mesh to check
  38045. * @returns true if active, false otherwise
  38046. */
  38047. isActiveMesh(mesh: Mesh): boolean;
  38048. /**
  38049. * Is this camera ready to be used/rendered
  38050. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  38051. * @return true if the camera is ready
  38052. */
  38053. isReady(completeCheck?: boolean): boolean;
  38054. /** @hidden */
  38055. _initCache(): void;
  38056. /** @hidden */
  38057. _updateCache(ignoreParentClass?: boolean): void;
  38058. /** @hidden */
  38059. _isSynchronized(): boolean;
  38060. /** @hidden */
  38061. _isSynchronizedViewMatrix(): boolean;
  38062. /** @hidden */
  38063. _isSynchronizedProjectionMatrix(): boolean;
  38064. /**
  38065. * Attach the input controls to a specific dom element to get the input from.
  38066. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38067. */
  38068. attachControl(noPreventDefault?: boolean): void;
  38069. /**
  38070. * Attach the input controls to a specific dom element to get the input from.
  38071. * @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
  38072. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38073. * BACK COMPAT SIGNATURE ONLY.
  38074. */
  38075. attachControl(ignored: any, noPreventDefault?: boolean): void;
  38076. /**
  38077. * Detach the current controls from the specified dom element.
  38078. */
  38079. detachControl(): void;
  38080. /**
  38081. * Detach the current controls from the specified dom element.
  38082. * @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
  38083. */
  38084. detachControl(ignored: any): void;
  38085. /**
  38086. * Update the camera state according to the different inputs gathered during the frame.
  38087. */
  38088. update(): void;
  38089. /** @hidden */
  38090. _checkInputs(): void;
  38091. /** @hidden */
  38092. get rigCameras(): Camera[];
  38093. /**
  38094. * Gets the post process used by the rig cameras
  38095. */
  38096. get rigPostProcess(): Nullable<PostProcess>;
  38097. /**
  38098. * Internal, gets the first post proces.
  38099. * @returns the first post process to be run on this camera.
  38100. */
  38101. _getFirstPostProcess(): Nullable<PostProcess>;
  38102. private _cascadePostProcessesToRigCams;
  38103. /**
  38104. * Attach a post process to the camera.
  38105. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38106. * @param postProcess The post process to attach to the camera
  38107. * @param insertAt The position of the post process in case several of them are in use in the scene
  38108. * @returns the position the post process has been inserted at
  38109. */
  38110. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  38111. /**
  38112. * Detach a post process to the camera.
  38113. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  38114. * @param postProcess The post process to detach from the camera
  38115. */
  38116. detachPostProcess(postProcess: PostProcess): void;
  38117. /**
  38118. * Gets the current world matrix of the camera
  38119. */
  38120. getWorldMatrix(): Matrix;
  38121. /** @hidden */
  38122. _getViewMatrix(): Matrix;
  38123. /**
  38124. * Gets the current view matrix of the camera.
  38125. * @param force forces the camera to recompute the matrix without looking at the cached state
  38126. * @returns the view matrix
  38127. */
  38128. getViewMatrix(force?: boolean): Matrix;
  38129. /**
  38130. * Freeze the projection matrix.
  38131. * It will prevent the cache check of the camera projection compute and can speed up perf
  38132. * if no parameter of the camera are meant to change
  38133. * @param projection Defines manually a projection if necessary
  38134. */
  38135. freezeProjectionMatrix(projection?: Matrix): void;
  38136. /**
  38137. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  38138. */
  38139. unfreezeProjectionMatrix(): void;
  38140. /**
  38141. * Gets the current projection matrix of the camera.
  38142. * @param force forces the camera to recompute the matrix without looking at the cached state
  38143. * @returns the projection matrix
  38144. */
  38145. getProjectionMatrix(force?: boolean): Matrix;
  38146. /**
  38147. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  38148. * @returns a Matrix
  38149. */
  38150. getTransformationMatrix(): Matrix;
  38151. private _updateFrustumPlanes;
  38152. /**
  38153. * Checks if a cullable object (mesh...) is in the camera frustum
  38154. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  38155. * @param target The object to check
  38156. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  38157. * @returns true if the object is in frustum otherwise false
  38158. */
  38159. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  38160. /**
  38161. * Checks if a cullable object (mesh...) is in the camera frustum
  38162. * Unlike isInFrustum this cheks the full bounding box
  38163. * @param target The object to check
  38164. * @returns true if the object is in frustum otherwise false
  38165. */
  38166. isCompletelyInFrustum(target: ICullable): boolean;
  38167. /**
  38168. * Gets a ray in the forward direction from the camera.
  38169. * @param length Defines the length of the ray to create
  38170. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38171. * @param origin Defines the start point of the ray which defaults to the camera position
  38172. * @returns the forward ray
  38173. */
  38174. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38175. /**
  38176. * Gets a ray in the forward direction from the camera.
  38177. * @param refRay the ray to (re)use when setting the values
  38178. * @param length Defines the length of the ray to create
  38179. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  38180. * @param origin Defines the start point of the ray which defaults to the camera position
  38181. * @returns the forward ray
  38182. */
  38183. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  38184. /**
  38185. * Releases resources associated with this node.
  38186. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38187. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38188. */
  38189. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38190. /** @hidden */
  38191. _isLeftCamera: boolean;
  38192. /**
  38193. * Gets the left camera of a rig setup in case of Rigged Camera
  38194. */
  38195. get isLeftCamera(): boolean;
  38196. /** @hidden */
  38197. _isRightCamera: boolean;
  38198. /**
  38199. * Gets the right camera of a rig setup in case of Rigged Camera
  38200. */
  38201. get isRightCamera(): boolean;
  38202. /**
  38203. * Gets the left camera of a rig setup in case of Rigged Camera
  38204. */
  38205. get leftCamera(): Nullable<FreeCamera>;
  38206. /**
  38207. * Gets the right camera of a rig setup in case of Rigged Camera
  38208. */
  38209. get rightCamera(): Nullable<FreeCamera>;
  38210. /**
  38211. * Gets the left camera target of a rig setup in case of Rigged Camera
  38212. * @returns the target position
  38213. */
  38214. getLeftTarget(): Nullable<Vector3>;
  38215. /**
  38216. * Gets the right camera target of a rig setup in case of Rigged Camera
  38217. * @returns the target position
  38218. */
  38219. getRightTarget(): Nullable<Vector3>;
  38220. /**
  38221. * @hidden
  38222. */
  38223. setCameraRigMode(mode: number, rigParams: any): void;
  38224. /** @hidden */
  38225. static _setStereoscopicRigMode(camera: Camera): void;
  38226. /** @hidden */
  38227. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  38228. /** @hidden */
  38229. static _setVRRigMode(camera: Camera, rigParams: any): void;
  38230. /** @hidden */
  38231. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  38232. /** @hidden */
  38233. _getVRProjectionMatrix(): Matrix;
  38234. protected _updateCameraRotationMatrix(): void;
  38235. protected _updateWebVRCameraRotationMatrix(): void;
  38236. /**
  38237. * This function MUST be overwritten by the different WebVR cameras available.
  38238. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38239. * @hidden
  38240. */
  38241. _getWebVRProjectionMatrix(): Matrix;
  38242. /**
  38243. * This function MUST be overwritten by the different WebVR cameras available.
  38244. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  38245. * @hidden
  38246. */
  38247. _getWebVRViewMatrix(): Matrix;
  38248. /** @hidden */
  38249. setCameraRigParameter(name: string, value: any): void;
  38250. /**
  38251. * needs to be overridden by children so sub has required properties to be copied
  38252. * @hidden
  38253. */
  38254. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  38255. /**
  38256. * May need to be overridden by children
  38257. * @hidden
  38258. */
  38259. _updateRigCameras(): void;
  38260. /** @hidden */
  38261. _setupInputs(): void;
  38262. /**
  38263. * Serialiaze the camera setup to a json represention
  38264. * @returns the JSON representation
  38265. */
  38266. serialize(): any;
  38267. /**
  38268. * Clones the current camera.
  38269. * @param name The cloned camera name
  38270. * @returns the cloned camera
  38271. */
  38272. clone(name: string): Camera;
  38273. /**
  38274. * Gets the direction of the camera relative to a given local axis.
  38275. * @param localAxis Defines the reference axis to provide a relative direction.
  38276. * @return the direction
  38277. */
  38278. getDirection(localAxis: Vector3): Vector3;
  38279. /**
  38280. * Returns the current camera absolute rotation
  38281. */
  38282. get absoluteRotation(): Quaternion;
  38283. /**
  38284. * Gets the direction of the camera relative to a given local axis into a passed vector.
  38285. * @param localAxis Defines the reference axis to provide a relative direction.
  38286. * @param result Defines the vector to store the result in
  38287. */
  38288. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  38289. /**
  38290. * Gets a camera constructor for a given camera type
  38291. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  38292. * @param name The name of the camera the result will be able to instantiate
  38293. * @param scene The scene the result will construct the camera in
  38294. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  38295. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  38296. * @returns a factory method to construc the camera
  38297. */
  38298. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  38299. /**
  38300. * Compute the world matrix of the camera.
  38301. * @returns the camera world matrix
  38302. */
  38303. computeWorldMatrix(): Matrix;
  38304. /**
  38305. * Parse a JSON and creates the camera from the parsed information
  38306. * @param parsedCamera The JSON to parse
  38307. * @param scene The scene to instantiate the camera in
  38308. * @returns the newly constructed camera
  38309. */
  38310. static Parse(parsedCamera: any, scene: Scene): Camera;
  38311. }
  38312. }
  38313. declare module BABYLON {
  38314. /**
  38315. * PostProcessManager is used to manage one or more post processes or post process pipelines
  38316. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  38317. */
  38318. export class PostProcessManager {
  38319. private _scene;
  38320. private _indexBuffer;
  38321. private _vertexBuffers;
  38322. /**
  38323. * Creates a new instance PostProcess
  38324. * @param scene The scene that the post process is associated with.
  38325. */
  38326. constructor(scene: Scene);
  38327. private _prepareBuffers;
  38328. private _buildIndexBuffer;
  38329. /**
  38330. * Rebuilds the vertex buffers of the manager.
  38331. * @hidden
  38332. */
  38333. _rebuild(): void;
  38334. /**
  38335. * Prepares a frame to be run through a post process.
  38336. * @param sourceTexture The input texture to the post procesess. (default: null)
  38337. * @param postProcesses An array of post processes to be run. (default: null)
  38338. * @returns True if the post processes were able to be run.
  38339. * @hidden
  38340. */
  38341. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  38342. /**
  38343. * Manually render a set of post processes to a texture.
  38344. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  38345. * @param postProcesses An array of post processes to be run.
  38346. * @param targetTexture The target texture to render to.
  38347. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  38348. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  38349. * @param lodLevel defines which lod of the texture to render to
  38350. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  38351. */
  38352. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  38353. /**
  38354. * Finalize the result of the output of the postprocesses.
  38355. * @param doNotPresent If true the result will not be displayed to the screen.
  38356. * @param targetTexture The target texture to render to.
  38357. * @param faceIndex The index of the face to bind the target texture to.
  38358. * @param postProcesses The array of post processes to render.
  38359. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  38360. * @hidden
  38361. */
  38362. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  38363. /**
  38364. * Disposes of the post process manager.
  38365. */
  38366. dispose(): void;
  38367. }
  38368. }
  38369. declare module BABYLON {
  38370. /**
  38371. * This Helps creating a texture that will be created from a camera in your scene.
  38372. * It is basically a dynamic texture that could be used to create special effects for instance.
  38373. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  38374. */
  38375. export class RenderTargetTexture extends Texture {
  38376. /**
  38377. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  38378. */
  38379. static readonly REFRESHRATE_RENDER_ONCE: number;
  38380. /**
  38381. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  38382. */
  38383. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  38384. /**
  38385. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  38386. * the central point of your effect and can save a lot of performances.
  38387. */
  38388. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  38389. /**
  38390. * Use this predicate to dynamically define the list of mesh you want to render.
  38391. * If set, the renderList property will be overwritten.
  38392. */
  38393. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  38394. private _renderList;
  38395. /**
  38396. * Use this list to define the list of mesh you want to render.
  38397. */
  38398. get renderList(): Nullable<Array<AbstractMesh>>;
  38399. set renderList(value: Nullable<Array<AbstractMesh>>);
  38400. /**
  38401. * Use this function to overload the renderList array at rendering time.
  38402. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  38403. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  38404. * the cube (if the RTT is a cube, else layerOrFace=0).
  38405. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  38406. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  38407. * hold dummy elements!
  38408. */
  38409. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  38410. private _hookArray;
  38411. /**
  38412. * Define if particles should be rendered in your texture.
  38413. */
  38414. renderParticles: boolean;
  38415. /**
  38416. * Define if sprites should be rendered in your texture.
  38417. */
  38418. renderSprites: boolean;
  38419. /**
  38420. * Define the camera used to render the texture.
  38421. */
  38422. activeCamera: Nullable<Camera>;
  38423. /**
  38424. * Override the mesh isReady function with your own one.
  38425. */
  38426. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  38427. /**
  38428. * Override the render function of the texture with your own one.
  38429. */
  38430. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  38431. /**
  38432. * Define if camera post processes should be use while rendering the texture.
  38433. */
  38434. useCameraPostProcesses: boolean;
  38435. /**
  38436. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  38437. */
  38438. ignoreCameraViewport: boolean;
  38439. private _postProcessManager;
  38440. private _postProcesses;
  38441. private _resizeObserver;
  38442. /**
  38443. * An event triggered when the texture is unbind.
  38444. */
  38445. onBeforeBindObservable: Observable<RenderTargetTexture>;
  38446. /**
  38447. * An event triggered when the texture is unbind.
  38448. */
  38449. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  38450. private _onAfterUnbindObserver;
  38451. /**
  38452. * Set a after unbind callback in the texture.
  38453. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  38454. */
  38455. set onAfterUnbind(callback: () => void);
  38456. /**
  38457. * An event triggered before rendering the texture
  38458. */
  38459. onBeforeRenderObservable: Observable<number>;
  38460. private _onBeforeRenderObserver;
  38461. /**
  38462. * Set a before render callback in the texture.
  38463. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  38464. */
  38465. set onBeforeRender(callback: (faceIndex: number) => void);
  38466. /**
  38467. * An event triggered after rendering the texture
  38468. */
  38469. onAfterRenderObservable: Observable<number>;
  38470. private _onAfterRenderObserver;
  38471. /**
  38472. * Set a after render callback in the texture.
  38473. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  38474. */
  38475. set onAfterRender(callback: (faceIndex: number) => void);
  38476. /**
  38477. * An event triggered after the texture clear
  38478. */
  38479. onClearObservable: Observable<Engine>;
  38480. private _onClearObserver;
  38481. /**
  38482. * Set a clear callback in the texture.
  38483. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  38484. */
  38485. set onClear(callback: (Engine: Engine) => void);
  38486. /**
  38487. * An event triggered when the texture is resized.
  38488. */
  38489. onResizeObservable: Observable<RenderTargetTexture>;
  38490. /**
  38491. * Define the clear color of the Render Target if it should be different from the scene.
  38492. */
  38493. clearColor: Color4;
  38494. protected _size: number | {
  38495. width: number;
  38496. height: number;
  38497. layers?: number;
  38498. };
  38499. protected _initialSizeParameter: number | {
  38500. width: number;
  38501. height: number;
  38502. } | {
  38503. ratio: number;
  38504. };
  38505. protected _sizeRatio: Nullable<number>;
  38506. /** @hidden */
  38507. _generateMipMaps: boolean;
  38508. protected _renderingManager: RenderingManager;
  38509. /** @hidden */
  38510. _waitingRenderList?: string[];
  38511. protected _doNotChangeAspectRatio: boolean;
  38512. protected _currentRefreshId: number;
  38513. protected _refreshRate: number;
  38514. protected _textureMatrix: Matrix;
  38515. protected _samples: number;
  38516. protected _renderTargetOptions: RenderTargetCreationOptions;
  38517. /**
  38518. * Gets render target creation options that were used.
  38519. */
  38520. get renderTargetOptions(): RenderTargetCreationOptions;
  38521. protected _onRatioRescale(): void;
  38522. /**
  38523. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  38524. * It must define where the camera used to render the texture is set
  38525. */
  38526. boundingBoxPosition: Vector3;
  38527. private _boundingBoxSize;
  38528. /**
  38529. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  38530. * When defined, the cubemap will switch to local mode
  38531. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  38532. * @example https://www.babylonjs-playground.com/#RNASML
  38533. */
  38534. set boundingBoxSize(value: Vector3);
  38535. get boundingBoxSize(): Vector3;
  38536. /**
  38537. * In case the RTT has been created with a depth texture, get the associated
  38538. * depth texture.
  38539. * Otherwise, return null.
  38540. */
  38541. get depthStencilTexture(): Nullable<InternalTexture>;
  38542. /**
  38543. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  38544. * or used a shadow, depth texture...
  38545. * @param name The friendly name of the texture
  38546. * @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)
  38547. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  38548. * @param generateMipMaps True if mip maps need to be generated after render.
  38549. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  38550. * @param type The type of the buffer in the RTT (int, half float, float...)
  38551. * @param isCube True if a cube texture needs to be created
  38552. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  38553. * @param generateDepthBuffer True to generate a depth buffer
  38554. * @param generateStencilBuffer True to generate a stencil buffer
  38555. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  38556. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  38557. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38558. * @param samples sample count to use when creating the RTT
  38559. */
  38560. constructor(name: string, size: number | {
  38561. width: number;
  38562. height: number;
  38563. layers?: number;
  38564. } | {
  38565. ratio: number;
  38566. }, 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);
  38567. /**
  38568. * Creates a depth stencil texture.
  38569. * This is only available in WebGL 2 or with the depth texture extension available.
  38570. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  38571. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  38572. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  38573. * @param samples sample count of the depth/stencil texture
  38574. */
  38575. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean, samples?: number): void;
  38576. private _processSizeParameter;
  38577. /**
  38578. * Define the number of samples to use in case of MSAA.
  38579. * It defaults to one meaning no MSAA has been enabled.
  38580. */
  38581. get samples(): number;
  38582. set samples(value: number);
  38583. /**
  38584. * Resets the refresh counter of the texture and start bak from scratch.
  38585. * Could be useful to regenerate the texture if it is setup to render only once.
  38586. */
  38587. resetRefreshCounter(): void;
  38588. /**
  38589. * Define the refresh rate of the texture or the rendering frequency.
  38590. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  38591. */
  38592. get refreshRate(): number;
  38593. set refreshRate(value: number);
  38594. /**
  38595. * Adds a post process to the render target rendering passes.
  38596. * @param postProcess define the post process to add
  38597. */
  38598. addPostProcess(postProcess: PostProcess): void;
  38599. /**
  38600. * Clear all the post processes attached to the render target
  38601. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  38602. */
  38603. clearPostProcesses(dispose?: boolean): void;
  38604. /**
  38605. * Remove one of the post process from the list of attached post processes to the texture
  38606. * @param postProcess define the post process to remove from the list
  38607. */
  38608. removePostProcess(postProcess: PostProcess): void;
  38609. /** @hidden */
  38610. _shouldRender(): boolean;
  38611. /**
  38612. * Gets the actual render size of the texture.
  38613. * @returns the width of the render size
  38614. */
  38615. getRenderSize(): number;
  38616. /**
  38617. * Gets the actual render width of the texture.
  38618. * @returns the width of the render size
  38619. */
  38620. getRenderWidth(): number;
  38621. /**
  38622. * Gets the actual render height of the texture.
  38623. * @returns the height of the render size
  38624. */
  38625. getRenderHeight(): number;
  38626. /**
  38627. * Gets the actual number of layers of the texture.
  38628. * @returns the number of layers
  38629. */
  38630. getRenderLayers(): number;
  38631. /**
  38632. * Get if the texture can be rescaled or not.
  38633. */
  38634. get canRescale(): boolean;
  38635. /**
  38636. * Resize the texture using a ratio.
  38637. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  38638. */
  38639. scale(ratio: number): void;
  38640. /**
  38641. * Get the texture reflection matrix used to rotate/transform the reflection.
  38642. * @returns the reflection matrix
  38643. */
  38644. getReflectionTextureMatrix(): Matrix;
  38645. /**
  38646. * Resize the texture to a new desired size.
  38647. * Be carrefull as it will recreate all the data in the new texture.
  38648. * @param size Define the new size. It can be:
  38649. * - a number for squared texture,
  38650. * - an object containing { width: number, height: number }
  38651. * - or an object containing a ratio { ratio: number }
  38652. */
  38653. resize(size: number | {
  38654. width: number;
  38655. height: number;
  38656. } | {
  38657. ratio: number;
  38658. }): void;
  38659. private _defaultRenderListPrepared;
  38660. /**
  38661. * Renders all the objects from the render list into the texture.
  38662. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  38663. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  38664. */
  38665. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  38666. private _bestReflectionRenderTargetDimension;
  38667. private _prepareRenderingManager;
  38668. /**
  38669. * @hidden
  38670. * @param faceIndex face index to bind to if this is a cubetexture
  38671. * @param layer defines the index of the texture to bind in the array
  38672. */
  38673. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  38674. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  38675. private renderToTarget;
  38676. /**
  38677. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38678. * This allowed control for front to back rendering or reversly depending of the special needs.
  38679. *
  38680. * @param renderingGroupId The rendering group id corresponding to its index
  38681. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38682. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38683. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38684. */
  38685. 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;
  38686. /**
  38687. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38688. *
  38689. * @param renderingGroupId The rendering group id corresponding to its index
  38690. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38691. */
  38692. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  38693. /**
  38694. * Clones the texture.
  38695. * @returns the cloned texture
  38696. */
  38697. clone(): RenderTargetTexture;
  38698. /**
  38699. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  38700. * @returns The JSON representation of the texture
  38701. */
  38702. serialize(): any;
  38703. /**
  38704. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  38705. */
  38706. disposeFramebufferObjects(): void;
  38707. /**
  38708. * Dispose the texture and release its associated resources.
  38709. */
  38710. dispose(): void;
  38711. /** @hidden */
  38712. _rebuild(): void;
  38713. /**
  38714. * Clear the info related to rendering groups preventing retention point in material dispose.
  38715. */
  38716. freeRenderingGroups(): void;
  38717. /**
  38718. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  38719. * @returns the view count
  38720. */
  38721. getViewCount(): number;
  38722. }
  38723. }
  38724. declare module BABYLON {
  38725. /**
  38726. * Options to be used when creating an effect.
  38727. */
  38728. export interface IEffectCreationOptions {
  38729. /**
  38730. * Atrributes that will be used in the shader.
  38731. */
  38732. attributes: string[];
  38733. /**
  38734. * Uniform varible names that will be set in the shader.
  38735. */
  38736. uniformsNames: string[];
  38737. /**
  38738. * Uniform buffer variable names that will be set in the shader.
  38739. */
  38740. uniformBuffersNames: string[];
  38741. /**
  38742. * Sampler texture variable names that will be set in the shader.
  38743. */
  38744. samplers: string[];
  38745. /**
  38746. * Define statements that will be set in the shader.
  38747. */
  38748. defines: any;
  38749. /**
  38750. * Possible fallbacks for this effect to improve performance when needed.
  38751. */
  38752. fallbacks: Nullable<IEffectFallbacks>;
  38753. /**
  38754. * Callback that will be called when the shader is compiled.
  38755. */
  38756. onCompiled: Nullable<(effect: Effect) => void>;
  38757. /**
  38758. * Callback that will be called if an error occurs during shader compilation.
  38759. */
  38760. onError: Nullable<(effect: Effect, errors: string) => void>;
  38761. /**
  38762. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38763. */
  38764. indexParameters?: any;
  38765. /**
  38766. * Max number of lights that can be used in the shader.
  38767. */
  38768. maxSimultaneousLights?: number;
  38769. /**
  38770. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  38771. */
  38772. transformFeedbackVaryings?: Nullable<string[]>;
  38773. /**
  38774. * 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
  38775. */
  38776. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  38777. /**
  38778. * Is this effect rendering to several color attachments ?
  38779. */
  38780. multiTarget?: boolean;
  38781. }
  38782. /**
  38783. * Effect containing vertex and fragment shader that can be executed on an object.
  38784. */
  38785. export class Effect implements IDisposable {
  38786. /**
  38787. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38788. */
  38789. static ShadersRepository: string;
  38790. /**
  38791. * Enable logging of the shader code when a compilation error occurs
  38792. */
  38793. static LogShaderCodeOnCompilationError: boolean;
  38794. /**
  38795. * Name of the effect.
  38796. */
  38797. name: any;
  38798. /**
  38799. * String container all the define statements that should be set on the shader.
  38800. */
  38801. defines: string;
  38802. /**
  38803. * Callback that will be called when the shader is compiled.
  38804. */
  38805. onCompiled: Nullable<(effect: Effect) => void>;
  38806. /**
  38807. * Callback that will be called if an error occurs during shader compilation.
  38808. */
  38809. onError: Nullable<(effect: Effect, errors: string) => void>;
  38810. /**
  38811. * Callback that will be called when effect is bound.
  38812. */
  38813. onBind: Nullable<(effect: Effect) => void>;
  38814. /**
  38815. * Unique ID of the effect.
  38816. */
  38817. uniqueId: number;
  38818. /**
  38819. * Observable that will be called when the shader is compiled.
  38820. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  38821. */
  38822. onCompileObservable: Observable<Effect>;
  38823. /**
  38824. * Observable that will be called if an error occurs during shader compilation.
  38825. */
  38826. onErrorObservable: Observable<Effect>;
  38827. /** @hidden */
  38828. _onBindObservable: Nullable<Observable<Effect>>;
  38829. /**
  38830. * @hidden
  38831. * Specifies if the effect was previously ready
  38832. */
  38833. _wasPreviouslyReady: boolean;
  38834. /**
  38835. * Observable that will be called when effect is bound.
  38836. */
  38837. get onBindObservable(): Observable<Effect>;
  38838. /** @hidden */
  38839. _bonesComputationForcedToCPU: boolean;
  38840. /** @hidden */
  38841. _uniformBuffersNames: {
  38842. [key: string]: number;
  38843. };
  38844. /** @hidden */
  38845. _samplerList: string[];
  38846. /** @hidden */
  38847. _multiTarget: boolean;
  38848. private static _uniqueIdSeed;
  38849. private _engine;
  38850. private _uniformBuffersNamesList;
  38851. private _uniformsNames;
  38852. private _samplers;
  38853. private _isReady;
  38854. private _compilationError;
  38855. private _allFallbacksProcessed;
  38856. private _attributesNames;
  38857. private _attributes;
  38858. private _attributeLocationByName;
  38859. private _uniforms;
  38860. /**
  38861. * Key for the effect.
  38862. * @hidden
  38863. */
  38864. _key: string;
  38865. private _indexParameters;
  38866. private _fallbacks;
  38867. private _vertexSourceCodeOverride;
  38868. private _fragmentSourceCodeOverride;
  38869. private _transformFeedbackVaryings;
  38870. /**
  38871. * Compiled shader to webGL program.
  38872. * @hidden
  38873. */
  38874. _pipelineContext: Nullable<IPipelineContext>;
  38875. /** @hidden */
  38876. _vertexSourceCode: string;
  38877. /** @hidden */
  38878. _fragmentSourceCode: string;
  38879. /** @hidden */
  38880. private _rawVertexSourceCode;
  38881. /** @hidden */
  38882. private _rawFragmentSourceCode;
  38883. private static _baseCache;
  38884. private _processingContext;
  38885. /**
  38886. * Instantiates an effect.
  38887. * An effect can be used to create/manage/execute vertex and fragment shaders.
  38888. * @param baseName Name of the effect.
  38889. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  38890. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  38891. * @param samplers List of sampler variables that will be passed to the shader.
  38892. * @param engine Engine to be used to render the effect
  38893. * @param defines Define statements to be added to the shader.
  38894. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  38895. * @param onCompiled Callback that will be called when the shader is compiled.
  38896. * @param onError Callback that will be called if an error occurs during shader compilation.
  38897. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  38898. * @param key Effect Key identifying uniquely compiled shader variants
  38899. */
  38900. 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);
  38901. private _useFinalCode;
  38902. /**
  38903. * Unique key for this effect
  38904. */
  38905. get key(): string;
  38906. /**
  38907. * If the effect has been compiled and prepared.
  38908. * @returns if the effect is compiled and prepared.
  38909. */
  38910. isReady(): boolean;
  38911. private _isReadyInternal;
  38912. /**
  38913. * The engine the effect was initialized with.
  38914. * @returns the engine.
  38915. */
  38916. getEngine(): Engine;
  38917. /**
  38918. * The pipeline context for this effect
  38919. * @returns the associated pipeline context
  38920. */
  38921. getPipelineContext(): Nullable<IPipelineContext>;
  38922. /**
  38923. * The set of names of attribute variables for the shader.
  38924. * @returns An array of attribute names.
  38925. */
  38926. getAttributesNames(): string[];
  38927. /**
  38928. * Returns the attribute at the given index.
  38929. * @param index The index of the attribute.
  38930. * @returns The location of the attribute.
  38931. */
  38932. getAttributeLocation(index: number): number;
  38933. /**
  38934. * Returns the attribute based on the name of the variable.
  38935. * @param name of the attribute to look up.
  38936. * @returns the attribute location.
  38937. */
  38938. getAttributeLocationByName(name: string): number;
  38939. /**
  38940. * The number of attributes.
  38941. * @returns the numnber of attributes.
  38942. */
  38943. getAttributesCount(): number;
  38944. /**
  38945. * Gets the index of a uniform variable.
  38946. * @param uniformName of the uniform to look up.
  38947. * @returns the index.
  38948. */
  38949. getUniformIndex(uniformName: string): number;
  38950. /**
  38951. * Returns the attribute based on the name of the variable.
  38952. * @param uniformName of the uniform to look up.
  38953. * @returns the location of the uniform.
  38954. */
  38955. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  38956. /**
  38957. * Returns an array of sampler variable names
  38958. * @returns The array of sampler variable names.
  38959. */
  38960. getSamplers(): string[];
  38961. /**
  38962. * Returns an array of uniform variable names
  38963. * @returns The array of uniform variable names.
  38964. */
  38965. getUniformNames(): string[];
  38966. /**
  38967. * Returns an array of uniform buffer variable names
  38968. * @returns The array of uniform buffer variable names.
  38969. */
  38970. getUniformBuffersNames(): string[];
  38971. /**
  38972. * Returns the index parameters used to create the effect
  38973. * @returns The index parameters object
  38974. */
  38975. getIndexParameters(): any;
  38976. /**
  38977. * The error from the last compilation.
  38978. * @returns the error string.
  38979. */
  38980. getCompilationError(): string;
  38981. /**
  38982. * Gets a boolean indicating that all fallbacks were used during compilation
  38983. * @returns true if all fallbacks were used
  38984. */
  38985. allFallbacksProcessed(): boolean;
  38986. /**
  38987. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  38988. * @param func The callback to be used.
  38989. */
  38990. executeWhenCompiled(func: (effect: Effect) => void): void;
  38991. private _checkIsReady;
  38992. private _loadShader;
  38993. /**
  38994. * Gets the vertex shader source code of this effect
  38995. */
  38996. get vertexSourceCode(): string;
  38997. /**
  38998. * Gets the fragment shader source code of this effect
  38999. */
  39000. get fragmentSourceCode(): string;
  39001. /**
  39002. * Gets the vertex shader source code before it has been processed by the preprocessor
  39003. */
  39004. get rawVertexSourceCode(): string;
  39005. /**
  39006. * Gets the fragment shader source code before it has been processed by the preprocessor
  39007. */
  39008. get rawFragmentSourceCode(): string;
  39009. /**
  39010. * Recompiles the webGL program
  39011. * @param vertexSourceCode The source code for the vertex shader.
  39012. * @param fragmentSourceCode The source code for the fragment shader.
  39013. * @param onCompiled Callback called when completed.
  39014. * @param onError Callback called on error.
  39015. * @hidden
  39016. */
  39017. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39018. /**
  39019. * Prepares the effect
  39020. * @hidden
  39021. */
  39022. _prepareEffect(): void;
  39023. private _getShaderCodeAndErrorLine;
  39024. private _processCompilationErrors;
  39025. /**
  39026. * Checks if the effect is supported. (Must be called after compilation)
  39027. */
  39028. get isSupported(): boolean;
  39029. /**
  39030. * Binds a texture to the engine to be used as output of the shader.
  39031. * @param channel Name of the output variable.
  39032. * @param texture Texture to bind.
  39033. * @hidden
  39034. */
  39035. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39036. /**
  39037. * Sets a texture on the engine to be used in the shader.
  39038. * @param channel Name of the sampler variable.
  39039. * @param texture Texture to set.
  39040. */
  39041. setTexture(channel: string, texture: Nullable<ThinTexture>): void;
  39042. /**
  39043. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39044. * @param channel Name of the sampler variable.
  39045. * @param texture Texture to set.
  39046. */
  39047. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39048. /**
  39049. * Sets an array of textures on the engine to be used in the shader.
  39050. * @param channel Name of the variable.
  39051. * @param textures Textures to set.
  39052. */
  39053. setTextureArray(channel: string, textures: ThinTexture[]): void;
  39054. /**
  39055. * 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)
  39056. * @param channel Name of the sampler variable.
  39057. * @param postProcess Post process to get the input texture from.
  39058. */
  39059. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39060. /**
  39061. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39062. * 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)
  39063. * @param channel Name of the sampler variable.
  39064. * @param postProcess Post process to get the output texture from.
  39065. */
  39066. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39067. /**
  39068. * Binds a buffer to a uniform.
  39069. * @param buffer Buffer to bind.
  39070. * @param name Name of the uniform variable to bind to.
  39071. */
  39072. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39073. /**
  39074. * Binds block to a uniform.
  39075. * @param blockName Name of the block to bind.
  39076. * @param index Index to bind.
  39077. */
  39078. bindUniformBlock(blockName: string, index: number): void;
  39079. /**
  39080. * Sets an interger value on a uniform variable.
  39081. * @param uniformName Name of the variable.
  39082. * @param value Value to be set.
  39083. * @returns this effect.
  39084. */
  39085. setInt(uniformName: string, value: number): Effect;
  39086. /**
  39087. * Sets an int2 value on a uniform variable.
  39088. * @param uniformName Name of the variable.
  39089. * @param x First int in int2.
  39090. * @param y Second int in int2.
  39091. * @returns this effect.
  39092. */
  39093. setInt2(uniformName: string, x: number, y: number): Effect;
  39094. /**
  39095. * Sets an int3 value on a uniform variable.
  39096. * @param uniformName Name of the variable.
  39097. * @param x First int in int3.
  39098. * @param y Second int in int3.
  39099. * @param z Third int in int3.
  39100. * @returns this effect.
  39101. */
  39102. setInt3(uniformName: string, x: number, y: number, z: number): Effect;
  39103. /**
  39104. * Sets an int4 value on a uniform variable.
  39105. * @param uniformName Name of the variable.
  39106. * @param x First int in int4.
  39107. * @param y Second int in int4.
  39108. * @param z Third int in int4.
  39109. * @param w Fourth int in int4.
  39110. * @returns this effect.
  39111. */
  39112. setInt4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39113. /**
  39114. * Sets an int array on a uniform variable.
  39115. * @param uniformName Name of the variable.
  39116. * @param array array to be set.
  39117. * @returns this effect.
  39118. */
  39119. setIntArray(uniformName: string, array: Int32Array): Effect;
  39120. /**
  39121. * 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)
  39122. * @param uniformName Name of the variable.
  39123. * @param array array to be set.
  39124. * @returns this effect.
  39125. */
  39126. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39127. /**
  39128. * 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)
  39129. * @param uniformName Name of the variable.
  39130. * @param array array to be set.
  39131. * @returns this effect.
  39132. */
  39133. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39134. /**
  39135. * 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)
  39136. * @param uniformName Name of the variable.
  39137. * @param array array to be set.
  39138. * @returns this effect.
  39139. */
  39140. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39141. /**
  39142. * Sets an float array on a uniform variable.
  39143. * @param uniformName Name of the variable.
  39144. * @param array array to be set.
  39145. * @returns this effect.
  39146. */
  39147. setFloatArray(uniformName: string, array: FloatArray): Effect;
  39148. /**
  39149. * 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)
  39150. * @param uniformName Name of the variable.
  39151. * @param array array to be set.
  39152. * @returns this effect.
  39153. */
  39154. setFloatArray2(uniformName: string, array: FloatArray): Effect;
  39155. /**
  39156. * 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)
  39157. * @param uniformName Name of the variable.
  39158. * @param array array to be set.
  39159. * @returns this effect.
  39160. */
  39161. setFloatArray3(uniformName: string, array: FloatArray): Effect;
  39162. /**
  39163. * 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)
  39164. * @param uniformName Name of the variable.
  39165. * @param array array to be set.
  39166. * @returns this effect.
  39167. */
  39168. setFloatArray4(uniformName: string, array: FloatArray): Effect;
  39169. /**
  39170. * Sets an array on a uniform variable.
  39171. * @param uniformName Name of the variable.
  39172. * @param array array to be set.
  39173. * @returns this effect.
  39174. */
  39175. setArray(uniformName: string, array: number[]): Effect;
  39176. /**
  39177. * 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)
  39178. * @param uniformName Name of the variable.
  39179. * @param array array to be set.
  39180. * @returns this effect.
  39181. */
  39182. setArray2(uniformName: string, array: number[]): Effect;
  39183. /**
  39184. * 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)
  39185. * @param uniformName Name of the variable.
  39186. * @param array array to be set.
  39187. * @returns this effect.
  39188. */
  39189. setArray3(uniformName: string, array: number[]): Effect;
  39190. /**
  39191. * 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)
  39192. * @param uniformName Name of the variable.
  39193. * @param array array to be set.
  39194. * @returns this effect.
  39195. */
  39196. setArray4(uniformName: string, array: number[]): Effect;
  39197. /**
  39198. * Sets matrices on a uniform variable.
  39199. * @param uniformName Name of the variable.
  39200. * @param matrices matrices to be set.
  39201. * @returns this effect.
  39202. */
  39203. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39204. /**
  39205. * Sets matrix on a uniform variable.
  39206. * @param uniformName Name of the variable.
  39207. * @param matrix matrix to be set.
  39208. * @returns this effect.
  39209. */
  39210. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39211. /**
  39212. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  39213. * @param uniformName Name of the variable.
  39214. * @param matrix matrix to be set.
  39215. * @returns this effect.
  39216. */
  39217. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39218. /**
  39219. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39220. * @param uniformName Name of the variable.
  39221. * @param matrix matrix to be set.
  39222. * @returns this effect.
  39223. */
  39224. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39225. /**
  39226. * Sets a float on a uniform variable.
  39227. * @param uniformName Name of the variable.
  39228. * @param value value to be set.
  39229. * @returns this effect.
  39230. */
  39231. setFloat(uniformName: string, value: number): Effect;
  39232. /**
  39233. * Sets a boolean on a uniform variable.
  39234. * @param uniformName Name of the variable.
  39235. * @param bool value to be set.
  39236. * @returns this effect.
  39237. */
  39238. setBool(uniformName: string, bool: boolean): Effect;
  39239. /**
  39240. * Sets a Vector2 on a uniform variable.
  39241. * @param uniformName Name of the variable.
  39242. * @param vector2 vector2 to be set.
  39243. * @returns this effect.
  39244. */
  39245. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39246. /**
  39247. * Sets a float2 on a uniform variable.
  39248. * @param uniformName Name of the variable.
  39249. * @param x First float in float2.
  39250. * @param y Second float in float2.
  39251. * @returns this effect.
  39252. */
  39253. setFloat2(uniformName: string, x: number, y: number): Effect;
  39254. /**
  39255. * Sets a Vector3 on a uniform variable.
  39256. * @param uniformName Name of the variable.
  39257. * @param vector3 Value to be set.
  39258. * @returns this effect.
  39259. */
  39260. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39261. /**
  39262. * Sets a float3 on a uniform variable.
  39263. * @param uniformName Name of the variable.
  39264. * @param x First float in float3.
  39265. * @param y Second float in float3.
  39266. * @param z Third float in float3.
  39267. * @returns this effect.
  39268. */
  39269. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39270. /**
  39271. * Sets a Vector4 on a uniform variable.
  39272. * @param uniformName Name of the variable.
  39273. * @param vector4 Value to be set.
  39274. * @returns this effect.
  39275. */
  39276. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39277. /**
  39278. * Sets a float4 on a uniform variable.
  39279. * @param uniformName Name of the variable.
  39280. * @param x First float in float4.
  39281. * @param y Second float in float4.
  39282. * @param z Third float in float4.
  39283. * @param w Fourth float in float4.
  39284. * @returns this effect.
  39285. */
  39286. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39287. /**
  39288. * Sets a Color3 on a uniform variable.
  39289. * @param uniformName Name of the variable.
  39290. * @param color3 Value to be set.
  39291. * @returns this effect.
  39292. */
  39293. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39294. /**
  39295. * Sets a Color4 on a uniform variable.
  39296. * @param uniformName Name of the variable.
  39297. * @param color3 Value to be set.
  39298. * @param alpha Alpha value to be set.
  39299. * @returns this effect.
  39300. */
  39301. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39302. /**
  39303. * Sets a Color4 on a uniform variable
  39304. * @param uniformName defines the name of the variable
  39305. * @param color4 defines the value to be set
  39306. * @returns this effect.
  39307. */
  39308. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39309. /**
  39310. * Release all associated resources.
  39311. **/
  39312. dispose(): void;
  39313. /**
  39314. * This function will add a new shader to the shader store
  39315. * @param name the name of the shader
  39316. * @param pixelShader optional pixel shader content
  39317. * @param vertexShader optional vertex shader content
  39318. */
  39319. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39320. /**
  39321. * Store of each shader (The can be looked up using effect.key)
  39322. */
  39323. static ShadersStore: {
  39324. [key: string]: string;
  39325. };
  39326. /**
  39327. * Store of each included file for a shader (The can be looked up using effect.key)
  39328. */
  39329. static IncludesShadersStore: {
  39330. [key: string]: string;
  39331. };
  39332. /**
  39333. * Resets the cache of effects.
  39334. */
  39335. static ResetCache(): void;
  39336. }
  39337. }
  39338. declare module BABYLON {
  39339. /**
  39340. * Interface used to describe the capabilities of the engine relatively to the current browser
  39341. */
  39342. export interface EngineCapabilities {
  39343. /** Maximum textures units per fragment shader */
  39344. maxTexturesImageUnits: number;
  39345. /** Maximum texture units per vertex shader */
  39346. maxVertexTextureImageUnits: number;
  39347. /** Maximum textures units in the entire pipeline */
  39348. maxCombinedTexturesImageUnits: number;
  39349. /** Maximum texture size */
  39350. maxTextureSize: number;
  39351. /** Maximum texture samples */
  39352. maxSamples?: number;
  39353. /** Maximum cube texture size */
  39354. maxCubemapTextureSize: number;
  39355. /** Maximum render texture size */
  39356. maxRenderTextureSize: number;
  39357. /** Maximum number of vertex attributes */
  39358. maxVertexAttribs: number;
  39359. /** Maximum number of varyings */
  39360. maxVaryingVectors: number;
  39361. /** Maximum number of uniforms per vertex shader */
  39362. maxVertexUniformVectors: number;
  39363. /** Maximum number of uniforms per fragment shader */
  39364. maxFragmentUniformVectors: number;
  39365. /** Defines if standard derivates (dx/dy) are supported */
  39366. standardDerivatives: boolean;
  39367. /** Defines if s3tc texture compression is supported */
  39368. s3tc?: WEBGL_compressed_texture_s3tc;
  39369. /** Defines if pvrtc texture compression is supported */
  39370. pvrtc: any;
  39371. /** Defines if etc1 texture compression is supported */
  39372. etc1: any;
  39373. /** Defines if etc2 texture compression is supported */
  39374. etc2: any;
  39375. /** Defines if astc texture compression is supported */
  39376. astc: any;
  39377. /** Defines if bptc texture compression is supported */
  39378. bptc: any;
  39379. /** Defines if float textures are supported */
  39380. textureFloat: boolean;
  39381. /** Defines if vertex array objects are supported */
  39382. vertexArrayObject: boolean;
  39383. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39384. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39385. /** Gets the maximum level of anisotropy supported */
  39386. maxAnisotropy: number;
  39387. /** Defines if instancing is supported */
  39388. instancedArrays: boolean;
  39389. /** Defines if 32 bits indices are supported */
  39390. uintIndices: boolean;
  39391. /** Defines if high precision shaders are supported */
  39392. highPrecisionShaderSupported: boolean;
  39393. /** Defines if depth reading in the fragment shader is supported */
  39394. fragmentDepthSupported: boolean;
  39395. /** Defines if float texture linear filtering is supported*/
  39396. textureFloatLinearFiltering: boolean;
  39397. /** Defines if rendering to float textures is supported */
  39398. textureFloatRender: boolean;
  39399. /** Defines if half float textures are supported*/
  39400. textureHalfFloat: boolean;
  39401. /** Defines if half float texture linear filtering is supported*/
  39402. textureHalfFloatLinearFiltering: boolean;
  39403. /** Defines if rendering to half float textures is supported */
  39404. textureHalfFloatRender: boolean;
  39405. /** Defines if textureLOD shader command is supported */
  39406. textureLOD: boolean;
  39407. /** Defines if draw buffers extension is supported */
  39408. drawBuffersExtension: boolean;
  39409. /** Defines if depth textures are supported */
  39410. depthTextureExtension: boolean;
  39411. /** Defines if float color buffer are supported */
  39412. colorBufferFloat: boolean;
  39413. /** Gets disjoint timer query extension (null if not supported) */
  39414. timerQuery?: EXT_disjoint_timer_query;
  39415. /** Defines if timestamp can be used with timer query */
  39416. canUseTimestampForTimerQuery: boolean;
  39417. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39418. multiview?: any;
  39419. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39420. oculusMultiview?: any;
  39421. /** Function used to let the system compiles shaders in background */
  39422. parallelShaderCompile?: {
  39423. COMPLETION_STATUS_KHR: number;
  39424. };
  39425. /** Max number of texture samples for MSAA */
  39426. maxMSAASamples: number;
  39427. /** Defines if the blend min max extension is supported */
  39428. blendMinMax: boolean;
  39429. /** 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 */
  39430. canUseGLInstanceID: boolean;
  39431. }
  39432. }
  39433. declare module BABYLON {
  39434. /**
  39435. * @hidden
  39436. **/
  39437. export class DepthCullingState {
  39438. private _isDepthTestDirty;
  39439. private _isDepthMaskDirty;
  39440. private _isDepthFuncDirty;
  39441. private _isCullFaceDirty;
  39442. private _isCullDirty;
  39443. private _isZOffsetDirty;
  39444. private _isFrontFaceDirty;
  39445. private _depthTest;
  39446. private _depthMask;
  39447. private _depthFunc;
  39448. private _cull;
  39449. private _cullFace;
  39450. private _zOffset;
  39451. private _frontFace;
  39452. /**
  39453. * Initializes the state.
  39454. */
  39455. constructor();
  39456. get isDirty(): boolean;
  39457. get zOffset(): number;
  39458. set zOffset(value: number);
  39459. get cullFace(): Nullable<number>;
  39460. set cullFace(value: Nullable<number>);
  39461. get cull(): Nullable<boolean>;
  39462. set cull(value: Nullable<boolean>);
  39463. get depthFunc(): Nullable<number>;
  39464. set depthFunc(value: Nullable<number>);
  39465. get depthMask(): boolean;
  39466. set depthMask(value: boolean);
  39467. get depthTest(): boolean;
  39468. set depthTest(value: boolean);
  39469. get frontFace(): Nullable<number>;
  39470. set frontFace(value: Nullable<number>);
  39471. reset(): void;
  39472. apply(gl: WebGLRenderingContext): void;
  39473. }
  39474. }
  39475. declare module BABYLON {
  39476. /**
  39477. * @hidden
  39478. **/
  39479. export class StencilState {
  39480. /** 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 */
  39481. static readonly ALWAYS: number;
  39482. /** Passed to stencilOperation to specify that stencil value must be kept */
  39483. static readonly KEEP: number;
  39484. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39485. static readonly REPLACE: number;
  39486. private _isStencilTestDirty;
  39487. private _isStencilMaskDirty;
  39488. private _isStencilFuncDirty;
  39489. private _isStencilOpDirty;
  39490. private _stencilTest;
  39491. private _stencilMask;
  39492. private _stencilFunc;
  39493. private _stencilFuncRef;
  39494. private _stencilFuncMask;
  39495. private _stencilOpStencilFail;
  39496. private _stencilOpDepthFail;
  39497. private _stencilOpStencilDepthPass;
  39498. get isDirty(): boolean;
  39499. get stencilFunc(): number;
  39500. set stencilFunc(value: number);
  39501. get stencilFuncRef(): number;
  39502. set stencilFuncRef(value: number);
  39503. get stencilFuncMask(): number;
  39504. set stencilFuncMask(value: number);
  39505. get stencilOpStencilFail(): number;
  39506. set stencilOpStencilFail(value: number);
  39507. get stencilOpDepthFail(): number;
  39508. set stencilOpDepthFail(value: number);
  39509. get stencilOpStencilDepthPass(): number;
  39510. set stencilOpStencilDepthPass(value: number);
  39511. get stencilMask(): number;
  39512. set stencilMask(value: number);
  39513. get stencilTest(): boolean;
  39514. set stencilTest(value: boolean);
  39515. constructor();
  39516. reset(): void;
  39517. apply(gl: WebGLRenderingContext): void;
  39518. }
  39519. }
  39520. declare module BABYLON {
  39521. /**
  39522. * @hidden
  39523. **/
  39524. export class AlphaState {
  39525. _blendFunctionParameters: Nullable<number>[];
  39526. _blendEquationParameters: Nullable<number>[];
  39527. _blendConstants: Nullable<number>[];
  39528. _isBlendConstantsDirty: boolean;
  39529. private _alphaBlend;
  39530. private _isAlphaBlendDirty;
  39531. private _isBlendFunctionParametersDirty;
  39532. private _isBlendEquationParametersDirty;
  39533. /**
  39534. * Initializes the state.
  39535. */
  39536. constructor();
  39537. get isDirty(): boolean;
  39538. get alphaBlend(): boolean;
  39539. set alphaBlend(value: boolean);
  39540. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39541. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39542. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39543. reset(): void;
  39544. apply(gl: WebGLRenderingContext): void;
  39545. }
  39546. }
  39547. declare module BABYLON {
  39548. /** @hidden */
  39549. export class WebGLShaderProcessor implements IShaderProcessor {
  39550. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39551. }
  39552. }
  39553. declare module BABYLON {
  39554. /** @hidden */
  39555. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39556. attributeProcessor(attribute: string): string;
  39557. varyingProcessor(varying: string, isFragment: boolean): string;
  39558. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>, engine: ThinEngine): string;
  39559. }
  39560. }
  39561. declare module BABYLON {
  39562. /**
  39563. * Interface for attribute information associated with buffer instanciation
  39564. */
  39565. export interface InstancingAttributeInfo {
  39566. /**
  39567. * Name of the GLSL attribute
  39568. * if attribute index is not specified, this is used to retrieve the index from the effect
  39569. */
  39570. attributeName: string;
  39571. /**
  39572. * Index/offset of the attribute in the vertex shader
  39573. * if not specified, this will be computes from the name.
  39574. */
  39575. index?: number;
  39576. /**
  39577. * size of the attribute, 1, 2, 3 or 4
  39578. */
  39579. attributeSize: number;
  39580. /**
  39581. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39582. */
  39583. offset: number;
  39584. /**
  39585. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39586. * default to 1
  39587. */
  39588. divisor?: number;
  39589. /**
  39590. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39591. * default is FLOAT
  39592. */
  39593. attributeType?: number;
  39594. /**
  39595. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39596. */
  39597. normalized?: boolean;
  39598. }
  39599. }
  39600. declare module BABYLON {
  39601. /** @hidden */
  39602. export interface EngineFeatures {
  39603. /** Force using Bitmap when Bitmap or HTMLImageElement can be used */
  39604. forceBitmapOverHTMLImageElement: boolean;
  39605. /** Indicates that the engine support rendering to as well as copying to lod float textures */
  39606. supportRenderAndCopyToLodForFloatTextures: boolean;
  39607. /** Indicates that the engine support handling depth/stencil textures */
  39608. supportDepthStencilTexture: boolean;
  39609. /** Indicates that the engine support shadow samplers */
  39610. supportShadowSamplers: boolean;
  39611. /** 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 */
  39612. uniformBufferHardCheckMatrix: boolean;
  39613. /** Indicates that prefiltered mipmaps can be generated in some processes (for eg when loading an HDR cube texture) */
  39614. allowTexturePrefiltering: boolean;
  39615. /** Indicates to track the usage of ubos and to create new ones as necessary during a frame duration */
  39616. trackUbosInFrame: boolean;
  39617. /** Indicates that the Cascaded Shadow Map technic is supported */
  39618. supportCSM: boolean;
  39619. /** Indicates that the textures transcoded by the basis transcoder must have power of 2 width and height */
  39620. basisNeedsPOT: boolean;
  39621. /** Indicates that the engine supports 3D textures */
  39622. support3DTextures: boolean;
  39623. /** Indicates that constants need a type suffix in shaders (used by realtime filtering...) */
  39624. needTypeSuffixInShaderConstants: boolean;
  39625. /** Indicates that MSAA is supported */
  39626. supportMSAA: boolean;
  39627. /** Indicates that SSAO2 is supported */
  39628. supportSSAO2: boolean;
  39629. /** Indicates that some additional texture formats are supported (like TEXTUREFORMAT_R for eg) */
  39630. supportExtendedTextureFormats: boolean;
  39631. /** Indicates that the switch/case construct is supported in shaders */
  39632. supportSwitchCaseInShader: boolean;
  39633. /** @hidden */
  39634. _collectUbosUpdatedInFrame: boolean;
  39635. }
  39636. }
  39637. declare module BABYLON {
  39638. /** @hidden */
  39639. export class WebGLHardwareTexture implements HardwareTextureWrapper {
  39640. private _webGLTexture;
  39641. private _context;
  39642. get underlyingResource(): Nullable<WebGLTexture>;
  39643. constructor(existingTexture: WebGLTexture | null | undefined, context: WebGLRenderingContext);
  39644. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  39645. set(hardwareTexture: WebGLTexture): void;
  39646. reset(): void;
  39647. release(): void;
  39648. }
  39649. }
  39650. declare module BABYLON {
  39651. interface ThinEngine {
  39652. /**
  39653. * Update a video texture
  39654. * @param texture defines the texture to update
  39655. * @param video defines the video element to use
  39656. * @param invertY defines if data must be stored with Y axis inverted
  39657. */
  39658. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39659. }
  39660. }
  39661. declare module BABYLON {
  39662. interface ThinEngine {
  39663. /**
  39664. * Creates a dynamic texture
  39665. * @param width defines the width of the texture
  39666. * @param height defines the height of the texture
  39667. * @param generateMipMaps defines if the engine should generate the mip levels
  39668. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39669. * @returns the dynamic texture inside an InternalTexture
  39670. */
  39671. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39672. /**
  39673. * Update the content of a dynamic texture
  39674. * @param texture defines the texture to update
  39675. * @param source defines the source containing the data
  39676. * @param invertY defines if data must be stored with Y axis inverted
  39677. * @param premulAlpha defines if alpha is stored as premultiplied
  39678. * @param format defines the format of the data
  39679. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39680. */
  39681. updateDynamicTexture(texture: Nullable<InternalTexture>, source: ImageBitmap | ImageData | HTMLImageElement | HTMLCanvasElement | HTMLVideoElement | OffscreenCanvas, invertY?: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39682. }
  39683. }
  39684. declare module BABYLON {
  39685. /**
  39686. * Settings for finer control over video usage
  39687. */
  39688. export interface VideoTextureSettings {
  39689. /**
  39690. * Applies `autoplay` to video, if specified
  39691. */
  39692. autoPlay?: boolean;
  39693. /**
  39694. * Applies `muted` to video, if specified
  39695. */
  39696. muted?: boolean;
  39697. /**
  39698. * Applies `loop` to video, if specified
  39699. */
  39700. loop?: boolean;
  39701. /**
  39702. * Automatically updates internal texture from video at every frame in the render loop
  39703. */
  39704. autoUpdateTexture: boolean;
  39705. /**
  39706. * Image src displayed during the video loading or until the user interacts with the video.
  39707. */
  39708. poster?: string;
  39709. }
  39710. /**
  39711. * If you want to display a video in your scene, this is the special texture for that.
  39712. * This special texture works similar to other textures, with the exception of a few parameters.
  39713. * @see https://doc.babylonjs.com/how_to/video_texture
  39714. */
  39715. export class VideoTexture extends Texture {
  39716. /**
  39717. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  39718. */
  39719. readonly autoUpdateTexture: boolean;
  39720. /**
  39721. * The video instance used by the texture internally
  39722. */
  39723. readonly video: HTMLVideoElement;
  39724. private _onUserActionRequestedObservable;
  39725. /**
  39726. * Event triggerd when a dom action is required by the user to play the video.
  39727. * This happens due to recent changes in browser policies preventing video to auto start.
  39728. */
  39729. get onUserActionRequestedObservable(): Observable<Texture>;
  39730. private _generateMipMaps;
  39731. private _stillImageCaptured;
  39732. private _displayingPosterTexture;
  39733. private _settings;
  39734. private _createInternalTextureOnEvent;
  39735. private _frameId;
  39736. private _currentSrc;
  39737. /**
  39738. * Creates a video texture.
  39739. * If you want to display a video in your scene, this is the special texture for that.
  39740. * This special texture works similar to other textures, with the exception of a few parameters.
  39741. * @see https://doc.babylonjs.com/how_to/video_texture
  39742. * @param name optional name, will detect from video source, if not defined
  39743. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  39744. * @param scene is obviously the current scene.
  39745. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  39746. * @param invertY is false by default but can be used to invert video on Y axis
  39747. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  39748. * @param settings allows finer control over video usage
  39749. */
  39750. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  39751. private _getName;
  39752. private _getVideo;
  39753. private _createInternalTexture;
  39754. private reset;
  39755. /**
  39756. * @hidden Internal method to initiate `update`.
  39757. */
  39758. _rebuild(): void;
  39759. /**
  39760. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  39761. */
  39762. update(): void;
  39763. /**
  39764. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  39765. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  39766. */
  39767. updateTexture(isVisible: boolean): void;
  39768. protected _updateInternalTexture: () => void;
  39769. /**
  39770. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  39771. * @param url New url.
  39772. */
  39773. updateURL(url: string): void;
  39774. /**
  39775. * Clones the texture.
  39776. * @returns the cloned texture
  39777. */
  39778. clone(): VideoTexture;
  39779. /**
  39780. * Dispose the texture and release its associated resources.
  39781. */
  39782. dispose(): void;
  39783. /**
  39784. * Creates a video texture straight from a stream.
  39785. * @param scene Define the scene the texture should be created in
  39786. * @param stream Define the stream the texture should be created from
  39787. * @returns The created video texture as a promise
  39788. */
  39789. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  39790. /**
  39791. * Creates a video texture straight from your WebCam video feed.
  39792. * @param scene Define the scene the texture should be created in
  39793. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39794. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39795. * @returns The created video texture as a promise
  39796. */
  39797. static CreateFromWebCamAsync(scene: Scene, constraints: {
  39798. minWidth: number;
  39799. maxWidth: number;
  39800. minHeight: number;
  39801. maxHeight: number;
  39802. deviceId: string;
  39803. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  39804. /**
  39805. * Creates a video texture straight from your WebCam video feed.
  39806. * @param scene Define the scene the texture should be created in
  39807. * @param onReady Define a callback to triggered once the texture will be ready
  39808. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  39809. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  39810. */
  39811. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  39812. minWidth: number;
  39813. maxWidth: number;
  39814. minHeight: number;
  39815. maxHeight: number;
  39816. deviceId: string;
  39817. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  39818. }
  39819. }
  39820. declare module BABYLON {
  39821. /**
  39822. * Defines the interface used by objects working like Scene
  39823. * @hidden
  39824. */
  39825. export interface ISceneLike {
  39826. _addPendingData(data: any): void;
  39827. _removePendingData(data: any): void;
  39828. offlineProvider: IOfflineProvider;
  39829. }
  39830. /**
  39831. * Information about the current host
  39832. */
  39833. export interface HostInformation {
  39834. /**
  39835. * Defines if the current host is a mobile
  39836. */
  39837. isMobile: boolean;
  39838. }
  39839. /** Interface defining initialization parameters for Engine class */
  39840. export interface EngineOptions extends WebGLContextAttributes {
  39841. /**
  39842. * Defines if the engine should no exceed a specified device ratio
  39843. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  39844. */
  39845. limitDeviceRatio?: number;
  39846. /**
  39847. * Defines if webvr should be enabled automatically
  39848. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39849. */
  39850. autoEnableWebVR?: boolean;
  39851. /**
  39852. * Defines if webgl2 should be turned off even if supported
  39853. * @see https://doc.babylonjs.com/features/webgl2
  39854. */
  39855. disableWebGL2Support?: boolean;
  39856. /**
  39857. * Defines if webaudio should be initialized as well
  39858. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39859. */
  39860. audioEngine?: boolean;
  39861. /**
  39862. * Defines if animations should run using a deterministic lock step
  39863. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39864. */
  39865. deterministicLockstep?: boolean;
  39866. /** Defines the maximum steps to use with deterministic lock step mode */
  39867. lockstepMaxSteps?: number;
  39868. /** Defines the seconds between each deterministic lock step */
  39869. timeStep?: number;
  39870. /**
  39871. * Defines that engine should ignore context lost events
  39872. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  39873. */
  39874. doNotHandleContextLost?: boolean;
  39875. /**
  39876. * Defines that engine should ignore modifying touch action attribute and style
  39877. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  39878. */
  39879. doNotHandleTouchAction?: boolean;
  39880. /**
  39881. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  39882. */
  39883. useHighPrecisionFloats?: boolean;
  39884. /**
  39885. * Make the canvas XR Compatible for XR sessions
  39886. */
  39887. xrCompatible?: boolean;
  39888. /**
  39889. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  39890. */
  39891. useHighPrecisionMatrix?: boolean;
  39892. /**
  39893. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  39894. */
  39895. failIfMajorPerformanceCaveat?: boolean;
  39896. /**
  39897. * Defines whether to adapt to the device's viewport characteristics (default: false)
  39898. */
  39899. adaptToDeviceRatio?: boolean;
  39900. }
  39901. /**
  39902. * The base engine class (root of all engines)
  39903. */
  39904. export class ThinEngine {
  39905. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  39906. static ExceptionList: ({
  39907. key: string;
  39908. capture: string;
  39909. captureConstraint: number;
  39910. targets: string[];
  39911. } | {
  39912. key: string;
  39913. capture: null;
  39914. captureConstraint: null;
  39915. targets: string[];
  39916. })[];
  39917. /** @hidden */
  39918. static _TextureLoaders: IInternalTextureLoader[];
  39919. /**
  39920. * Returns the current npm package of the sdk
  39921. */
  39922. static get NpmPackage(): string;
  39923. /**
  39924. * Returns the current version of the framework
  39925. */
  39926. static get Version(): string;
  39927. /**
  39928. * Returns a string describing the current engine
  39929. */
  39930. get description(): string;
  39931. /**
  39932. * Returns the name of the engine
  39933. */
  39934. get name(): string;
  39935. /**
  39936. * Returns the version of the engine
  39937. */
  39938. get version(): number;
  39939. /**
  39940. * Gets or sets the epsilon value used by collision engine
  39941. */
  39942. static CollisionsEpsilon: number;
  39943. /**
  39944. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39945. */
  39946. static get ShadersRepository(): string;
  39947. static set ShadersRepository(value: string);
  39948. /** @hidden */
  39949. _shaderProcessor: Nullable<IShaderProcessor>;
  39950. /**
  39951. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  39952. */
  39953. forcePOTTextures: boolean;
  39954. /**
  39955. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  39956. */
  39957. isFullscreen: boolean;
  39958. /**
  39959. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  39960. */
  39961. cullBackFaces: boolean;
  39962. /**
  39963. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  39964. */
  39965. renderEvenInBackground: boolean;
  39966. /**
  39967. * Gets or sets a boolean indicating that cache can be kept between frames
  39968. */
  39969. preventCacheWipeBetweenFrames: boolean;
  39970. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  39971. validateShaderPrograms: boolean;
  39972. /**
  39973. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  39974. * This can provide greater z depth for distant objects.
  39975. */
  39976. useReverseDepthBuffer: boolean;
  39977. /**
  39978. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  39979. */
  39980. disableUniformBuffers: boolean;
  39981. private _frameId;
  39982. /**
  39983. * Gets the current frame id
  39984. */
  39985. get frameId(): number;
  39986. /** @hidden */
  39987. _uniformBuffers: UniformBuffer[];
  39988. /**
  39989. * Gets a boolean indicating that the engine supports uniform buffers
  39990. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  39991. */
  39992. get supportsUniformBuffers(): boolean;
  39993. /** @hidden */
  39994. _gl: WebGLRenderingContext;
  39995. /** @hidden */
  39996. _webGLVersion: number;
  39997. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  39998. protected _windowIsBackground: boolean;
  39999. protected _creationOptions: EngineOptions;
  40000. protected _highPrecisionShadersAllowed: boolean;
  40001. /** @hidden */
  40002. get _shouldUseHighPrecisionShader(): boolean;
  40003. /**
  40004. * Gets a boolean indicating that only power of 2 textures are supported
  40005. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40006. */
  40007. get needPOTTextures(): boolean;
  40008. /** @hidden */
  40009. _badOS: boolean;
  40010. /** @hidden */
  40011. _badDesktopOS: boolean;
  40012. protected _hardwareScalingLevel: number;
  40013. /** @hidden */
  40014. _caps: EngineCapabilities;
  40015. /** @hidden */
  40016. _features: EngineFeatures;
  40017. protected _isStencilEnable: boolean;
  40018. private _glVersion;
  40019. private _glRenderer;
  40020. private _glVendor;
  40021. /** @hidden */
  40022. _videoTextureSupported: boolean;
  40023. protected _renderingQueueLaunched: boolean;
  40024. protected _activeRenderLoops: (() => void)[];
  40025. /**
  40026. * Observable signaled when a context lost event is raised
  40027. */
  40028. onContextLostObservable: Observable<ThinEngine>;
  40029. /**
  40030. * Observable signaled when a context restored event is raised
  40031. */
  40032. onContextRestoredObservable: Observable<ThinEngine>;
  40033. private _onContextLost;
  40034. private _onContextRestored;
  40035. protected _contextWasLost: boolean;
  40036. /** @hidden */
  40037. _doNotHandleContextLost: boolean;
  40038. /**
  40039. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40040. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40041. */
  40042. get doNotHandleContextLost(): boolean;
  40043. set doNotHandleContextLost(value: boolean);
  40044. /**
  40045. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40046. */
  40047. disableVertexArrayObjects: boolean;
  40048. /** @hidden */
  40049. protected _colorWrite: boolean;
  40050. /** @hidden */
  40051. protected _colorWriteChanged: boolean;
  40052. /** @hidden */
  40053. protected _depthCullingState: DepthCullingState;
  40054. /** @hidden */
  40055. protected _stencilState: StencilState;
  40056. /** @hidden */
  40057. _alphaState: AlphaState;
  40058. /** @hidden */
  40059. _alphaMode: number;
  40060. /** @hidden */
  40061. _alphaEquation: number;
  40062. /** @hidden */
  40063. _internalTexturesCache: InternalTexture[];
  40064. /** @hidden */
  40065. protected _activeChannel: number;
  40066. private _currentTextureChannel;
  40067. /** @hidden */
  40068. protected _boundTexturesCache: {
  40069. [key: string]: Nullable<InternalTexture>;
  40070. };
  40071. /** @hidden */
  40072. protected _currentEffect: Nullable<Effect>;
  40073. /** @hidden */
  40074. protected _currentProgram: Nullable<WebGLProgram>;
  40075. protected _compiledEffects: {
  40076. [key: string]: Effect;
  40077. };
  40078. private _vertexAttribArraysEnabled;
  40079. /** @hidden */
  40080. protected _cachedViewport: Nullable<IViewportLike>;
  40081. private _cachedVertexArrayObject;
  40082. /** @hidden */
  40083. protected _cachedVertexBuffers: any;
  40084. /** @hidden */
  40085. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40086. /** @hidden */
  40087. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40088. /** @hidden */
  40089. _currentRenderTarget: Nullable<InternalTexture>;
  40090. private _uintIndicesCurrentlySet;
  40091. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40092. /** @hidden */
  40093. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40094. /** @hidden */
  40095. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40096. private _currentBufferPointers;
  40097. private _currentInstanceLocations;
  40098. private _currentInstanceBuffers;
  40099. private _textureUnits;
  40100. /** @hidden */
  40101. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40102. /** @hidden */
  40103. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40104. /** @hidden */
  40105. _boundRenderFunction: any;
  40106. private _vaoRecordInProgress;
  40107. private _mustWipeVertexAttributes;
  40108. private _emptyTexture;
  40109. private _emptyCubeTexture;
  40110. private _emptyTexture3D;
  40111. private _emptyTexture2DArray;
  40112. /** @hidden */
  40113. _frameHandler: number;
  40114. private _nextFreeTextureSlots;
  40115. private _maxSimultaneousTextures;
  40116. private _activeRequests;
  40117. /** @hidden */
  40118. _transformTextureUrl: Nullable<(url: string) => string>;
  40119. /**
  40120. * Gets information about the current host
  40121. */
  40122. hostInformation: HostInformation;
  40123. protected get _supportsHardwareTextureRescaling(): boolean;
  40124. private _framebufferDimensionsObject;
  40125. /**
  40126. * sets the object from which width and height will be taken from when getting render width and height
  40127. * Will fallback to the gl object
  40128. * @param dimensions the framebuffer width and height that will be used.
  40129. */
  40130. set framebufferDimensionsObject(dimensions: Nullable<{
  40131. framebufferWidth: number;
  40132. framebufferHeight: number;
  40133. }>);
  40134. /**
  40135. * Gets the current viewport
  40136. */
  40137. get currentViewport(): Nullable<IViewportLike>;
  40138. /**
  40139. * Gets the default empty texture
  40140. */
  40141. get emptyTexture(): InternalTexture;
  40142. /**
  40143. * Gets the default empty 3D texture
  40144. */
  40145. get emptyTexture3D(): InternalTexture;
  40146. /**
  40147. * Gets the default empty 2D array texture
  40148. */
  40149. get emptyTexture2DArray(): InternalTexture;
  40150. /**
  40151. * Gets the default empty cube texture
  40152. */
  40153. get emptyCubeTexture(): InternalTexture;
  40154. /**
  40155. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40156. */
  40157. premultipliedAlpha: boolean;
  40158. /**
  40159. * Observable event triggered before each texture is initialized
  40160. */
  40161. onBeforeTextureInitObservable: Observable<Texture>;
  40162. /** @hidden */
  40163. protected _isWebGPU: boolean;
  40164. /**
  40165. * Gets a boolean indicating if the engine runs in WebGPU or not.
  40166. */
  40167. get isWebGPU(): boolean;
  40168. /** @hidden */
  40169. protected _shaderPlatformName: string;
  40170. /**
  40171. * Gets the shader platfrom name used by the effects.
  40172. */
  40173. get shaderPlatformName(): string;
  40174. /**
  40175. * Creates a new engine
  40176. * @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
  40177. * @param antialias defines enable antialiasing (default: false)
  40178. * @param options defines further options to be sent to the getContext() function
  40179. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40180. */
  40181. constructor(canvasOrContext: Nullable<HTMLCanvasElement | OffscreenCanvas | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40182. /**
  40183. * @hidden
  40184. */
  40185. _debugPushGroup(groupName: string, targetObject?: number): void;
  40186. /**
  40187. * @hidden
  40188. */
  40189. _debugPopGroup(targetObject?: number): void;
  40190. /**
  40191. * @hidden
  40192. */
  40193. _debugInsertMarker(text: string, targetObject?: number): void;
  40194. /**
  40195. * Shared initialization across engines types.
  40196. * @param canvas The canvas associated with this instance of the engine.
  40197. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  40198. * @param audioEngine Defines if an audio engine should be created by default
  40199. */
  40200. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  40201. /**
  40202. * Gets a shader processor implementation fitting with the current engine type.
  40203. * @returns The shader processor implementation.
  40204. */
  40205. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  40206. /** @hidden */
  40207. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  40208. private _rebuildInternalTextures;
  40209. private _rebuildEffects;
  40210. /**
  40211. * Gets a boolean indicating if all created effects are ready
  40212. * @returns true if all effects are ready
  40213. */
  40214. areAllEffectsReady(): boolean;
  40215. protected _rebuildBuffers(): void;
  40216. protected _initGLContext(): void;
  40217. protected _initFeatures(): void;
  40218. /**
  40219. * Gets version of the current webGL context
  40220. * Keep it for back compat - use version instead
  40221. */
  40222. get webGLVersion(): number;
  40223. /**
  40224. * Gets a string identifying the name of the class
  40225. * @returns "Engine" string
  40226. */
  40227. getClassName(): string;
  40228. /**
  40229. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40230. */
  40231. get isStencilEnable(): boolean;
  40232. /** @hidden */
  40233. _prepareWorkingCanvas(): void;
  40234. /**
  40235. * Reset the texture cache to empty state
  40236. */
  40237. resetTextureCache(): void;
  40238. /**
  40239. * Gets an object containing information about the current webGL context
  40240. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40241. */
  40242. getGlInfo(): {
  40243. vendor: string;
  40244. renderer: string;
  40245. version: string;
  40246. };
  40247. /**
  40248. * Defines the hardware scaling level.
  40249. * By default the hardware scaling level is computed from the window device ratio.
  40250. * 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.
  40251. * @param level defines the level to use
  40252. */
  40253. setHardwareScalingLevel(level: number): void;
  40254. /**
  40255. * Gets the current hardware scaling level.
  40256. * By default the hardware scaling level is computed from the window device ratio.
  40257. * 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.
  40258. * @returns a number indicating the current hardware scaling level
  40259. */
  40260. getHardwareScalingLevel(): number;
  40261. /**
  40262. * Gets the list of loaded textures
  40263. * @returns an array containing all loaded textures
  40264. */
  40265. getLoadedTexturesCache(): InternalTexture[];
  40266. /**
  40267. * Gets the object containing all engine capabilities
  40268. * @returns the EngineCapabilities object
  40269. */
  40270. getCaps(): EngineCapabilities;
  40271. /**
  40272. * stop executing a render loop function and remove it from the execution array
  40273. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40274. */
  40275. stopRenderLoop(renderFunction?: () => void): void;
  40276. /** @hidden */
  40277. _renderLoop(): void;
  40278. /**
  40279. * Gets the HTML canvas attached with the current webGL context
  40280. * @returns a HTML canvas
  40281. */
  40282. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40283. /**
  40284. * Gets host window
  40285. * @returns the host window object
  40286. */
  40287. getHostWindow(): Nullable<Window>;
  40288. /**
  40289. * Gets the current render width
  40290. * @param useScreen defines if screen size must be used (or the current render target if any)
  40291. * @returns a number defining the current render width
  40292. */
  40293. getRenderWidth(useScreen?: boolean): number;
  40294. /**
  40295. * Gets the current render height
  40296. * @param useScreen defines if screen size must be used (or the current render target if any)
  40297. * @returns a number defining the current render height
  40298. */
  40299. getRenderHeight(useScreen?: boolean): number;
  40300. /**
  40301. * Can be used to override the current requestAnimationFrame requester.
  40302. * @hidden
  40303. */
  40304. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40305. /**
  40306. * Register and execute a render loop. The engine can have more than one render function
  40307. * @param renderFunction defines the function to continuously execute
  40308. */
  40309. runRenderLoop(renderFunction: () => void): void;
  40310. /**
  40311. * Clear the current render buffer or the current render target (if any is set up)
  40312. * @param color defines the color to use
  40313. * @param backBuffer defines if the back buffer must be cleared
  40314. * @param depth defines if the depth buffer must be cleared
  40315. * @param stencil defines if the stencil buffer must be cleared
  40316. */
  40317. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40318. protected _viewportCached: {
  40319. x: number;
  40320. y: number;
  40321. z: number;
  40322. w: number;
  40323. };
  40324. /** @hidden */
  40325. _viewport(x: number, y: number, width: number, height: number): void;
  40326. /**
  40327. * Set the WebGL's viewport
  40328. * @param viewport defines the viewport element to be used
  40329. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40330. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40331. */
  40332. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40333. /**
  40334. * Begin a new frame
  40335. */
  40336. beginFrame(): void;
  40337. /**
  40338. * Enf the current frame
  40339. */
  40340. endFrame(): void;
  40341. /**
  40342. * Resize the view according to the canvas' size
  40343. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40344. */
  40345. resize(forceSetSize?: boolean): void;
  40346. /**
  40347. * Force a specific size of the canvas
  40348. * @param width defines the new canvas' width
  40349. * @param height defines the new canvas' height
  40350. * @param forceSetSize true to force setting the sizes of the underlying canvas
  40351. * @returns true if the size was changed
  40352. */
  40353. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  40354. /**
  40355. * Binds the frame buffer to the specified texture.
  40356. * @param texture The texture to render to or null for the default canvas
  40357. * @param faceIndex The face of the texture to render to in case of cube texture
  40358. * @param requiredWidth The width of the target to render to
  40359. * @param requiredHeight The height of the target to render to
  40360. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40361. * @param lodLevel defines the lod level to bind to the frame buffer
  40362. * @param layer defines the 2d array index to bind to frame buffer to
  40363. */
  40364. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40365. /** @hidden */
  40366. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40367. /**
  40368. * Unbind the current render target texture from the webGL context
  40369. * @param texture defines the render target texture to unbind
  40370. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40371. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40372. */
  40373. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40374. /**
  40375. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40376. */
  40377. flushFramebuffer(): void;
  40378. /**
  40379. * Unbind the current render target and bind the default framebuffer
  40380. */
  40381. restoreDefaultFramebuffer(): void;
  40382. /** @hidden */
  40383. protected _resetVertexBufferBinding(): void;
  40384. /**
  40385. * Creates a vertex buffer
  40386. * @param data the data for the vertex buffer
  40387. * @returns the new WebGL static buffer
  40388. */
  40389. createVertexBuffer(data: DataArray): DataBuffer;
  40390. private _createVertexBuffer;
  40391. /**
  40392. * Creates a dynamic vertex buffer
  40393. * @param data the data for the dynamic vertex buffer
  40394. * @returns the new WebGL dynamic buffer
  40395. */
  40396. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40397. protected _resetIndexBufferBinding(): void;
  40398. /**
  40399. * Creates a new index buffer
  40400. * @param indices defines the content of the index buffer
  40401. * @param updatable defines if the index buffer must be updatable
  40402. * @returns a new webGL buffer
  40403. */
  40404. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40405. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40406. /**
  40407. * Bind a webGL buffer to the webGL context
  40408. * @param buffer defines the buffer to bind
  40409. */
  40410. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40411. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40412. private bindBuffer;
  40413. /**
  40414. * update the bound buffer with the given data
  40415. * @param data defines the data to update
  40416. */
  40417. updateArrayBuffer(data: Float32Array): void;
  40418. private _vertexAttribPointer;
  40419. /** @hidden */
  40420. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40421. private _bindVertexBuffersAttributes;
  40422. /**
  40423. * Records a vertex array object
  40424. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40425. * @param vertexBuffers defines the list of vertex buffers to store
  40426. * @param indexBuffer defines the index buffer to store
  40427. * @param effect defines the effect to store
  40428. * @returns the new vertex array object
  40429. */
  40430. recordVertexArrayObject(vertexBuffers: {
  40431. [key: string]: VertexBuffer;
  40432. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40433. /**
  40434. * Bind a specific vertex array object
  40435. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40436. * @param vertexArrayObject defines the vertex array object to bind
  40437. * @param indexBuffer defines the index buffer to bind
  40438. */
  40439. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40440. /**
  40441. * Bind webGl buffers directly to the webGL context
  40442. * @param vertexBuffer defines the vertex buffer to bind
  40443. * @param indexBuffer defines the index buffer to bind
  40444. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40445. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40446. * @param effect defines the effect associated with the vertex buffer
  40447. */
  40448. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40449. private _unbindVertexArrayObject;
  40450. /**
  40451. * Bind a list of vertex buffers to the webGL context
  40452. * @param vertexBuffers defines the list of vertex buffers to bind
  40453. * @param indexBuffer defines the index buffer to bind
  40454. * @param effect defines the effect associated with the vertex buffers
  40455. */
  40456. bindBuffers(vertexBuffers: {
  40457. [key: string]: Nullable<VertexBuffer>;
  40458. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40459. /**
  40460. * Unbind all instance attributes
  40461. */
  40462. unbindInstanceAttributes(): void;
  40463. /**
  40464. * Release and free the memory of a vertex array object
  40465. * @param vao defines the vertex array object to delete
  40466. */
  40467. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40468. /** @hidden */
  40469. _releaseBuffer(buffer: DataBuffer): boolean;
  40470. protected _deleteBuffer(buffer: DataBuffer): void;
  40471. /**
  40472. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40473. * @param instancesBuffer defines the webGL buffer to update and bind
  40474. * @param data defines the data to store in the buffer
  40475. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40476. */
  40477. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40478. /**
  40479. * Bind the content of a webGL buffer used with instantiation
  40480. * @param instancesBuffer defines the webGL buffer to bind
  40481. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40482. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40483. */
  40484. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40485. /**
  40486. * Disable the instance attribute corresponding to the name in parameter
  40487. * @param name defines the name of the attribute to disable
  40488. */
  40489. disableInstanceAttributeByName(name: string): void;
  40490. /**
  40491. * Disable the instance attribute corresponding to the location in parameter
  40492. * @param attributeLocation defines the attribute location of the attribute to disable
  40493. */
  40494. disableInstanceAttribute(attributeLocation: number): void;
  40495. /**
  40496. * Disable the attribute corresponding to the location in parameter
  40497. * @param attributeLocation defines the attribute location of the attribute to disable
  40498. */
  40499. disableAttributeByIndex(attributeLocation: number): void;
  40500. /**
  40501. * Send a draw order
  40502. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40503. * @param indexStart defines the starting index
  40504. * @param indexCount defines the number of index to draw
  40505. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40506. */
  40507. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40508. /**
  40509. * Draw a list of points
  40510. * @param verticesStart defines the index of first vertex to draw
  40511. * @param verticesCount defines the count of vertices to draw
  40512. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40513. */
  40514. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40515. /**
  40516. * Draw a list of unindexed primitives
  40517. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40518. * @param verticesStart defines the index of first vertex to draw
  40519. * @param verticesCount defines the count of vertices to draw
  40520. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40521. */
  40522. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40523. /**
  40524. * Draw a list of indexed primitives
  40525. * @param fillMode defines the primitive to use
  40526. * @param indexStart defines the starting index
  40527. * @param indexCount defines the number of index to draw
  40528. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40529. */
  40530. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40531. /**
  40532. * Draw a list of unindexed primitives
  40533. * @param fillMode defines the primitive to use
  40534. * @param verticesStart defines the index of first vertex to draw
  40535. * @param verticesCount defines the count of vertices to draw
  40536. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40537. */
  40538. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40539. private _drawMode;
  40540. /** @hidden */
  40541. protected _reportDrawCall(): void;
  40542. /** @hidden */
  40543. _releaseEffect(effect: Effect): void;
  40544. /** @hidden */
  40545. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40546. /**
  40547. * Create a new effect (used to store vertex/fragment shaders)
  40548. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40549. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40550. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40551. * @param samplers defines an array of string used to represent textures
  40552. * @param defines defines the string containing the defines to use to compile the shaders
  40553. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40554. * @param onCompiled defines a function to call when the effect creation is successful
  40555. * @param onError defines a function to call when the effect creation has failed
  40556. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40557. * @returns the new Effect
  40558. */
  40559. 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;
  40560. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40561. private _compileShader;
  40562. private _compileRawShader;
  40563. /** @hidden */
  40564. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40565. /**
  40566. * Directly creates a webGL program
  40567. * @param pipelineContext defines the pipeline context to attach to
  40568. * @param vertexCode defines the vertex shader code to use
  40569. * @param fragmentCode defines the fragment shader code to use
  40570. * @param context defines the webGL context to use (if not set, the current one will be used)
  40571. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40572. * @returns the new webGL program
  40573. */
  40574. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40575. /**
  40576. * Creates a webGL program
  40577. * @param pipelineContext defines the pipeline context to attach to
  40578. * @param vertexCode defines the vertex shader code to use
  40579. * @param fragmentCode defines the fragment shader code to use
  40580. * @param defines defines the string containing the defines to use to compile the shaders
  40581. * @param context defines the webGL context to use (if not set, the current one will be used)
  40582. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40583. * @returns the new webGL program
  40584. */
  40585. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40586. /**
  40587. * Creates a new pipeline context
  40588. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  40589. * @returns the new pipeline
  40590. */
  40591. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  40592. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40593. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40594. /** @hidden */
  40595. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  40596. /** @hidden */
  40597. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40598. /** @hidden */
  40599. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40600. /**
  40601. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40602. * @param pipelineContext defines the pipeline context to use
  40603. * @param uniformsNames defines the list of uniform names
  40604. * @returns an array of webGL uniform locations
  40605. */
  40606. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40607. /**
  40608. * Gets the list of active attributes for a given webGL program
  40609. * @param pipelineContext defines the pipeline context to use
  40610. * @param attributesNames defines the list of attribute names to get
  40611. * @returns an array of indices indicating the offset of each attribute
  40612. */
  40613. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40614. /**
  40615. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40616. * @param effect defines the effect to activate
  40617. */
  40618. enableEffect(effect: Nullable<Effect>): void;
  40619. /**
  40620. * Set the value of an uniform to a number (int)
  40621. * @param uniform defines the webGL uniform location where to store the value
  40622. * @param value defines the int number to store
  40623. * @returns true if the value was set
  40624. */
  40625. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40626. /**
  40627. * Set the value of an uniform to a int2
  40628. * @param uniform defines the webGL uniform location where to store the value
  40629. * @param x defines the 1st component of the value
  40630. * @param y defines the 2nd component of the value
  40631. * @returns true if the value was set
  40632. */
  40633. setInt2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40634. /**
  40635. * Set the value of an uniform to a int3
  40636. * @param uniform defines the webGL uniform location where to store the value
  40637. * @param x defines the 1st component of the value
  40638. * @param y defines the 2nd component of the value
  40639. * @param z defines the 3rd component of the value
  40640. * @returns true if the value was set
  40641. */
  40642. setInt3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40643. /**
  40644. * Set the value of an uniform to a int4
  40645. * @param uniform defines the webGL uniform location where to store the value
  40646. * @param x defines the 1st component of the value
  40647. * @param y defines the 2nd component of the value
  40648. * @param z defines the 3rd component of the value
  40649. * @param w defines the 4th component of the value
  40650. * @returns true if the value was set
  40651. */
  40652. setInt4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40653. /**
  40654. * Set the value of an uniform to an array of int32
  40655. * @param uniform defines the webGL uniform location where to store the value
  40656. * @param array defines the array of int32 to store
  40657. * @returns true if the value was set
  40658. */
  40659. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40660. /**
  40661. * Set the value of an uniform to an array of int32 (stored as vec2)
  40662. * @param uniform defines the webGL uniform location where to store the value
  40663. * @param array defines the array of int32 to store
  40664. * @returns true if the value was set
  40665. */
  40666. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40667. /**
  40668. * Set the value of an uniform to an array of int32 (stored as vec3)
  40669. * @param uniform defines the webGL uniform location where to store the value
  40670. * @param array defines the array of int32 to store
  40671. * @returns true if the value was set
  40672. */
  40673. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40674. /**
  40675. * Set the value of an uniform to an array of int32 (stored as vec4)
  40676. * @param uniform defines the webGL uniform location where to store the value
  40677. * @param array defines the array of int32 to store
  40678. * @returns true if the value was set
  40679. */
  40680. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40681. /**
  40682. * Set the value of an uniform to an array of number
  40683. * @param uniform defines the webGL uniform location where to store the value
  40684. * @param array defines the array of number to store
  40685. * @returns true if the value was set
  40686. */
  40687. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40688. /**
  40689. * Set the value of an uniform to an array of number (stored as vec2)
  40690. * @param uniform defines the webGL uniform location where to store the value
  40691. * @param array defines the array of number to store
  40692. * @returns true if the value was set
  40693. */
  40694. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40695. /**
  40696. * Set the value of an uniform to an array of number (stored as vec3)
  40697. * @param uniform defines the webGL uniform location where to store the value
  40698. * @param array defines the array of number to store
  40699. * @returns true if the value was set
  40700. */
  40701. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40702. /**
  40703. * Set the value of an uniform to an array of number (stored as vec4)
  40704. * @param uniform defines the webGL uniform location where to store the value
  40705. * @param array defines the array of number to store
  40706. * @returns true if the value was set
  40707. */
  40708. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40709. /**
  40710. * Set the value of an uniform to an array of float32 (stored as matrices)
  40711. * @param uniform defines the webGL uniform location where to store the value
  40712. * @param matrices defines the array of float32 to store
  40713. * @returns true if the value was set
  40714. */
  40715. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40716. /**
  40717. * Set the value of an uniform to a matrix (3x3)
  40718. * @param uniform defines the webGL uniform location where to store the value
  40719. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40720. * @returns true if the value was set
  40721. */
  40722. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40723. /**
  40724. * Set the value of an uniform to a matrix (2x2)
  40725. * @param uniform defines the webGL uniform location where to store the value
  40726. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40727. * @returns true if the value was set
  40728. */
  40729. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40730. /**
  40731. * Set the value of an uniform to a number (float)
  40732. * @param uniform defines the webGL uniform location where to store the value
  40733. * @param value defines the float number to store
  40734. * @returns true if the value was transfered
  40735. */
  40736. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40737. /**
  40738. * Set the value of an uniform to a vec2
  40739. * @param uniform defines the webGL uniform location where to store the value
  40740. * @param x defines the 1st component of the value
  40741. * @param y defines the 2nd component of the value
  40742. * @returns true if the value was set
  40743. */
  40744. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40745. /**
  40746. * Set the value of an uniform to a vec3
  40747. * @param uniform defines the webGL uniform location where to store the value
  40748. * @param x defines the 1st component of the value
  40749. * @param y defines the 2nd component of the value
  40750. * @param z defines the 3rd component of the value
  40751. * @returns true if the value was set
  40752. */
  40753. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40754. /**
  40755. * Set the value of an uniform to a vec4
  40756. * @param uniform defines the webGL uniform location where to store the value
  40757. * @param x defines the 1st component of the value
  40758. * @param y defines the 2nd component of the value
  40759. * @param z defines the 3rd component of the value
  40760. * @param w defines the 4th component of the value
  40761. * @returns true if the value was set
  40762. */
  40763. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40764. /**
  40765. * Apply all cached states (depth, culling, stencil and alpha)
  40766. */
  40767. applyStates(): void;
  40768. /**
  40769. * Enable or disable color writing
  40770. * @param enable defines the state to set
  40771. */
  40772. setColorWrite(enable: boolean): void;
  40773. /**
  40774. * Gets a boolean indicating if color writing is enabled
  40775. * @returns the current color writing state
  40776. */
  40777. getColorWrite(): boolean;
  40778. /**
  40779. * Gets the depth culling state manager
  40780. */
  40781. get depthCullingState(): DepthCullingState;
  40782. /**
  40783. * Gets the alpha state manager
  40784. */
  40785. get alphaState(): AlphaState;
  40786. /**
  40787. * Gets the stencil state manager
  40788. */
  40789. get stencilState(): StencilState;
  40790. /**
  40791. * Clears the list of texture accessible through engine.
  40792. * This can help preventing texture load conflict due to name collision.
  40793. */
  40794. clearInternalTexturesCache(): void;
  40795. /**
  40796. * Force the entire cache to be cleared
  40797. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  40798. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  40799. */
  40800. wipeCaches(bruteForce?: boolean): void;
  40801. /** @hidden */
  40802. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  40803. min: number;
  40804. mag: number;
  40805. };
  40806. /** @hidden */
  40807. protected _createTexture(): WebGLTexture;
  40808. /** @hidden */
  40809. _createHardwareTexture(): HardwareTextureWrapper;
  40810. 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 | {
  40811. width: number;
  40812. height: number;
  40813. }, invertY: boolean, noMipmap: boolean, isCompressed: boolean, processFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40814. width: number;
  40815. height: number;
  40816. }, extension: string, texture: InternalTexture, continuationCallback: () => void) => boolean, samplingMode: number) => void, prepareTextureProcessFunction: (width: number, height: number, img: HTMLImageElement | ImageBitmap | {
  40817. width: number;
  40818. height: number;
  40819. }, 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;
  40820. /**
  40821. * Usually called from Texture.ts.
  40822. * Passed information to create a WebGLTexture
  40823. * @param url defines a value which contains one of the following:
  40824. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  40825. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  40826. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  40827. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  40828. * @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)
  40829. * @param scene needed for loading to the correct scene
  40830. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  40831. * @param onLoad optional callback to be called upon successful completion
  40832. * @param onError optional callback to be called upon failure
  40833. * @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
  40834. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  40835. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  40836. * @param forcedExtension defines the extension to use to pick the right loader
  40837. * @param mimeType defines an optional mime type
  40838. * @param loaderOptions options to be passed to the loader
  40839. * @returns a InternalTexture for assignment back into BABYLON.Texture
  40840. */
  40841. 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;
  40842. /**
  40843. * Loads an image as an HTMLImageElement.
  40844. * @param input url string, ArrayBuffer, or Blob to load
  40845. * @param onLoad callback called when the image successfully loads
  40846. * @param onError callback called when the image fails to load
  40847. * @param offlineProvider offline provider for caching
  40848. * @param mimeType optional mime type
  40849. * @returns the HTMLImageElement of the loaded image
  40850. * @hidden
  40851. */
  40852. 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>;
  40853. /**
  40854. * @hidden
  40855. */
  40856. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  40857. private _unpackFlipYCached;
  40858. /**
  40859. * In case you are sharing the context with other applications, it might
  40860. * be interested to not cache the unpack flip y state to ensure a consistent
  40861. * value would be set.
  40862. */
  40863. enableUnpackFlipYCached: boolean;
  40864. /** @hidden */
  40865. _unpackFlipY(value: boolean): void;
  40866. /** @hidden */
  40867. _getUnpackAlignement(): number;
  40868. private _getTextureTarget;
  40869. /**
  40870. * Update the sampling mode of a given texture
  40871. * @param samplingMode defines the required sampling mode
  40872. * @param texture defines the texture to update
  40873. * @param generateMipMaps defines whether to generate mipmaps for the texture
  40874. */
  40875. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  40876. /**
  40877. * Update the dimensions of a texture
  40878. * @param texture texture to update
  40879. * @param width new width of the texture
  40880. * @param height new height of the texture
  40881. * @param depth new depth of the texture
  40882. */
  40883. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  40884. /**
  40885. * Update the sampling mode of a given texture
  40886. * @param texture defines the texture to update
  40887. * @param wrapU defines the texture wrap mode of the u coordinates
  40888. * @param wrapV defines the texture wrap mode of the v coordinates
  40889. * @param wrapR defines the texture wrap mode of the r coordinates
  40890. */
  40891. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  40892. /** @hidden */
  40893. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  40894. width: number;
  40895. height: number;
  40896. layers?: number;
  40897. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  40898. /** @hidden */
  40899. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40900. /** @hidden */
  40901. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  40902. /**
  40903. * Update a portion of an internal texture
  40904. * @param texture defines the texture to update
  40905. * @param imageData defines the data to store into the texture
  40906. * @param xOffset defines the x coordinates of the update rectangle
  40907. * @param yOffset defines the y coordinates of the update rectangle
  40908. * @param width defines the width of the update rectangle
  40909. * @param height defines the height of the update rectangle
  40910. * @param faceIndex defines the face index if texture is a cube (0 by default)
  40911. * @param lod defines the lod level to update (0 by default)
  40912. */
  40913. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  40914. /** @hidden */
  40915. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40916. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  40917. private _prepareWebGLTexture;
  40918. /** @hidden */
  40919. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  40920. private _getDepthStencilBuffer;
  40921. /** @hidden */
  40922. _releaseFramebufferObjects(texture: InternalTexture): void;
  40923. /** @hidden */
  40924. _releaseTexture(texture: InternalTexture): void;
  40925. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  40926. protected _setProgram(program: WebGLProgram): void;
  40927. protected _boundUniforms: {
  40928. [key: number]: WebGLUniformLocation;
  40929. };
  40930. /**
  40931. * Binds an effect to the webGL context
  40932. * @param effect defines the effect to bind
  40933. */
  40934. bindSamplers(effect: Effect): void;
  40935. private _activateCurrentTexture;
  40936. /** @hidden */
  40937. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  40938. /** @hidden */
  40939. _bindTexture(channel: number, texture: Nullable<InternalTexture>, name: string): void;
  40940. /**
  40941. * Unbind all textures from the webGL context
  40942. */
  40943. unbindAllTextures(): void;
  40944. /**
  40945. * Sets a texture to the according uniform.
  40946. * @param channel The texture channel
  40947. * @param uniform The uniform to set
  40948. * @param texture The texture to apply
  40949. * @param name The name of the uniform in the effect
  40950. */
  40951. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<ThinTexture>, name: string): void;
  40952. private _bindSamplerUniformToChannel;
  40953. private _getTextureWrapMode;
  40954. protected _setTexture(channel: number, texture: Nullable<ThinTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string): boolean;
  40955. /**
  40956. * Sets an array of texture to the webGL context
  40957. * @param channel defines the channel where the texture array must be set
  40958. * @param uniform defines the associated uniform location
  40959. * @param textures defines the array of textures to bind
  40960. * @param name name of the channel
  40961. */
  40962. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: ThinTexture[], name: string): void;
  40963. /** @hidden */
  40964. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  40965. private _setTextureParameterFloat;
  40966. private _setTextureParameterInteger;
  40967. /**
  40968. * Unbind all vertex attributes from the webGL context
  40969. */
  40970. unbindAllAttributes(): void;
  40971. /**
  40972. * 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
  40973. */
  40974. releaseEffects(): void;
  40975. /**
  40976. * Dispose and release all associated resources
  40977. */
  40978. dispose(): void;
  40979. /**
  40980. * Attach a new callback raised when context lost event is fired
  40981. * @param callback defines the callback to call
  40982. */
  40983. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40984. /**
  40985. * Attach a new callback raised when context restored event is fired
  40986. * @param callback defines the callback to call
  40987. */
  40988. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  40989. /**
  40990. * Get the current error code of the webGL context
  40991. * @returns the error code
  40992. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40993. */
  40994. getError(): number;
  40995. private _canRenderToFloatFramebuffer;
  40996. private _canRenderToHalfFloatFramebuffer;
  40997. private _canRenderToFramebuffer;
  40998. /** @hidden */
  40999. _getWebGLTextureType(type: number): number;
  41000. /** @hidden */
  41001. _getInternalFormat(format: number): number;
  41002. /** @hidden */
  41003. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41004. /** @hidden */
  41005. _getRGBAMultiSampleBufferFormat(type: number): number;
  41006. /** @hidden */
  41007. _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;
  41008. /**
  41009. * Loads a file from a url
  41010. * @param url url to load
  41011. * @param onSuccess callback called when the file successfully loads
  41012. * @param onProgress callback called while file is loading (if the server supports this mode)
  41013. * @param offlineProvider defines the offline provider for caching
  41014. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41015. * @param onError callback called when the file fails to load
  41016. * @returns a file request object
  41017. * @hidden
  41018. */
  41019. 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;
  41020. /**
  41021. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41022. * @param x defines the x coordinate of the rectangle where pixels must be read
  41023. * @param y defines the y coordinate of the rectangle where pixels must be read
  41024. * @param width defines the width of the rectangle where pixels must be read
  41025. * @param height defines the height of the rectangle where pixels must be read
  41026. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41027. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  41028. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  41029. */
  41030. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41031. private static _IsSupported;
  41032. private static _HasMajorPerformanceCaveat;
  41033. /**
  41034. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41035. */
  41036. static get IsSupported(): boolean;
  41037. /**
  41038. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41039. * @returns true if the engine can be created
  41040. * @ignorenaming
  41041. */
  41042. static isSupported(): boolean;
  41043. /**
  41044. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  41045. */
  41046. static get HasMajorPerformanceCaveat(): boolean;
  41047. /**
  41048. * Find the next highest power of two.
  41049. * @param x Number to start search from.
  41050. * @return Next highest power of two.
  41051. */
  41052. static CeilingPOT(x: number): number;
  41053. /**
  41054. * Find the next lowest power of two.
  41055. * @param x Number to start search from.
  41056. * @return Next lowest power of two.
  41057. */
  41058. static FloorPOT(x: number): number;
  41059. /**
  41060. * Find the nearest power of two.
  41061. * @param x Number to start search from.
  41062. * @return Next nearest power of two.
  41063. */
  41064. static NearestPOT(x: number): number;
  41065. /**
  41066. * Get the closest exponent of two
  41067. * @param value defines the value to approximate
  41068. * @param max defines the maximum value to return
  41069. * @param mode defines how to define the closest value
  41070. * @returns closest exponent of two of the given value
  41071. */
  41072. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41073. /**
  41074. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41075. * @param func - the function to be called
  41076. * @param requester - the object that will request the next frame. Falls back to window.
  41077. * @returns frame number
  41078. */
  41079. static QueueNewFrame(func: () => void, requester?: any): number;
  41080. /**
  41081. * Gets host document
  41082. * @returns the host document object
  41083. */
  41084. getHostDocument(): Nullable<Document>;
  41085. }
  41086. }
  41087. declare module BABYLON {
  41088. /**
  41089. * Defines the source of the internal texture
  41090. */
  41091. export enum InternalTextureSource {
  41092. /**
  41093. * The source of the texture data is unknown
  41094. */
  41095. Unknown = 0,
  41096. /**
  41097. * Texture data comes from an URL
  41098. */
  41099. Url = 1,
  41100. /**
  41101. * Texture data is only used for temporary storage
  41102. */
  41103. Temp = 2,
  41104. /**
  41105. * Texture data comes from raw data (ArrayBuffer)
  41106. */
  41107. Raw = 3,
  41108. /**
  41109. * Texture content is dynamic (video or dynamic texture)
  41110. */
  41111. Dynamic = 4,
  41112. /**
  41113. * Texture content is generated by rendering to it
  41114. */
  41115. RenderTarget = 5,
  41116. /**
  41117. * Texture content is part of a multi render target process
  41118. */
  41119. MultiRenderTarget = 6,
  41120. /**
  41121. * Texture data comes from a cube data file
  41122. */
  41123. Cube = 7,
  41124. /**
  41125. * Texture data comes from a raw cube data
  41126. */
  41127. CubeRaw = 8,
  41128. /**
  41129. * Texture data come from a prefiltered cube data file
  41130. */
  41131. CubePrefiltered = 9,
  41132. /**
  41133. * Texture content is raw 3D data
  41134. */
  41135. Raw3D = 10,
  41136. /**
  41137. * Texture content is raw 2D array data
  41138. */
  41139. Raw2DArray = 11,
  41140. /**
  41141. * Texture content is a depth texture
  41142. */
  41143. Depth = 12,
  41144. /**
  41145. * Texture data comes from a raw cube data encoded with RGBD
  41146. */
  41147. CubeRawRGBD = 13
  41148. }
  41149. /**
  41150. * Class used to store data associated with WebGL texture data for the engine
  41151. * This class should not be used directly
  41152. */
  41153. export class InternalTexture {
  41154. /** @hidden */
  41155. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41156. /**
  41157. * Defines if the texture is ready
  41158. */
  41159. isReady: boolean;
  41160. /**
  41161. * Defines if the texture is a cube texture
  41162. */
  41163. isCube: boolean;
  41164. /**
  41165. * Defines if the texture contains 3D data
  41166. */
  41167. is3D: boolean;
  41168. /**
  41169. * Defines if the texture contains 2D array data
  41170. */
  41171. is2DArray: boolean;
  41172. /**
  41173. * Defines if the texture contains multiview data
  41174. */
  41175. isMultiview: boolean;
  41176. /**
  41177. * Gets the URL used to load this texture
  41178. */
  41179. url: string;
  41180. /** @hidden */
  41181. _originalUrl: string;
  41182. /**
  41183. * Gets the sampling mode of the texture
  41184. */
  41185. samplingMode: number;
  41186. /**
  41187. * Gets a boolean indicating if the texture needs mipmaps generation
  41188. */
  41189. generateMipMaps: boolean;
  41190. /**
  41191. * Gets the number of samples used by the texture (WebGL2+ only)
  41192. */
  41193. samples: number;
  41194. /**
  41195. * Gets the type of the texture (int, float...)
  41196. */
  41197. type: number;
  41198. /**
  41199. * Gets the format of the texture (RGB, RGBA...)
  41200. */
  41201. format: number;
  41202. /**
  41203. * Observable called when the texture is loaded
  41204. */
  41205. onLoadedObservable: Observable<InternalTexture>;
  41206. /**
  41207. * Gets the width of the texture
  41208. */
  41209. width: number;
  41210. /**
  41211. * Gets the height of the texture
  41212. */
  41213. height: number;
  41214. /**
  41215. * Gets the depth of the texture
  41216. */
  41217. depth: number;
  41218. /**
  41219. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41220. */
  41221. baseWidth: number;
  41222. /**
  41223. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41224. */
  41225. baseHeight: number;
  41226. /**
  41227. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41228. */
  41229. baseDepth: number;
  41230. /**
  41231. * Gets a boolean indicating if the texture is inverted on Y axis
  41232. */
  41233. invertY: boolean;
  41234. /** @hidden */
  41235. _invertVScale: boolean;
  41236. /** @hidden */
  41237. _associatedChannel: number;
  41238. /** @hidden */
  41239. _source: InternalTextureSource;
  41240. /** @hidden */
  41241. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41242. /** @hidden */
  41243. _bufferView: Nullable<ArrayBufferView>;
  41244. /** @hidden */
  41245. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41246. /** @hidden */
  41247. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41248. /** @hidden */
  41249. _size: number;
  41250. /** @hidden */
  41251. _extension: string;
  41252. /** @hidden */
  41253. _files: Nullable<string[]>;
  41254. /** @hidden */
  41255. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41256. /** @hidden */
  41257. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41258. /** @hidden */
  41259. _framebuffer: Nullable<WebGLFramebuffer>;
  41260. /** @hidden */
  41261. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41262. /** @hidden */
  41263. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41264. /** @hidden */
  41265. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41266. /** @hidden */
  41267. _attachments: Nullable<number[]>;
  41268. /** @hidden */
  41269. _textureArray: Nullable<InternalTexture[]>;
  41270. /** @hidden */
  41271. _cachedCoordinatesMode: Nullable<number>;
  41272. /** @hidden */
  41273. _cachedWrapU: Nullable<number>;
  41274. /** @hidden */
  41275. _cachedWrapV: Nullable<number>;
  41276. /** @hidden */
  41277. _cachedWrapR: Nullable<number>;
  41278. /** @hidden */
  41279. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41280. /** @hidden */
  41281. _isDisabled: boolean;
  41282. /** @hidden */
  41283. _compression: Nullable<string>;
  41284. /** @hidden */
  41285. _generateStencilBuffer: boolean;
  41286. /** @hidden */
  41287. _generateDepthBuffer: boolean;
  41288. /** @hidden */
  41289. _comparisonFunction: number;
  41290. /** @hidden */
  41291. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41292. /** @hidden */
  41293. _sphericalPolynomialPromise: Nullable<Promise<SphericalPolynomial>>;
  41294. /** @hidden */
  41295. _sphericalPolynomialComputed: boolean;
  41296. /** @hidden */
  41297. _lodGenerationScale: number;
  41298. /** @hidden */
  41299. _lodGenerationOffset: number;
  41300. /** @hidden */
  41301. _depthStencilTexture: Nullable<InternalTexture>;
  41302. /** @hidden */
  41303. _colorTextureArray: Nullable<WebGLTexture>;
  41304. /** @hidden */
  41305. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41306. /** @hidden */
  41307. _lodTextureHigh: Nullable<BaseTexture>;
  41308. /** @hidden */
  41309. _lodTextureMid: Nullable<BaseTexture>;
  41310. /** @hidden */
  41311. _lodTextureLow: Nullable<BaseTexture>;
  41312. /** @hidden */
  41313. _isRGBD: boolean;
  41314. /** @hidden */
  41315. _linearSpecularLOD: boolean;
  41316. /** @hidden */
  41317. _irradianceTexture: Nullable<BaseTexture>;
  41318. /** @hidden */
  41319. _hardwareTexture: Nullable<HardwareTextureWrapper>;
  41320. /** @hidden */
  41321. _references: number;
  41322. /** @hidden */
  41323. _gammaSpace: Nullable<boolean>;
  41324. private _engine;
  41325. private _uniqueId;
  41326. private static _Counter;
  41327. /** Gets the unique id of the internal texture */
  41328. get uniqueId(): number;
  41329. /**
  41330. * Gets the Engine the texture belongs to.
  41331. * @returns The babylon engine
  41332. */
  41333. getEngine(): ThinEngine;
  41334. /**
  41335. * Gets the data source type of the texture
  41336. */
  41337. get source(): InternalTextureSource;
  41338. /**
  41339. * Creates a new InternalTexture
  41340. * @param engine defines the engine to use
  41341. * @param source defines the type of data that will be used
  41342. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41343. */
  41344. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41345. /**
  41346. * Increments the number of references (ie. the number of Texture that point to it)
  41347. */
  41348. incrementReferences(): void;
  41349. /**
  41350. * Change the size of the texture (not the size of the content)
  41351. * @param width defines the new width
  41352. * @param height defines the new height
  41353. * @param depth defines the new depth (1 by default)
  41354. */
  41355. updateSize(width: int, height: int, depth?: int): void;
  41356. /** @hidden */
  41357. _rebuild(): void;
  41358. /** @hidden */
  41359. _swapAndDie(target: InternalTexture): void;
  41360. /**
  41361. * Dispose the current allocated resources
  41362. */
  41363. dispose(): void;
  41364. }
  41365. }
  41366. declare module BABYLON {
  41367. /**
  41368. * Interface used to present a loading screen while loading a scene
  41369. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41370. */
  41371. export interface ILoadingScreen {
  41372. /**
  41373. * Function called to display the loading screen
  41374. */
  41375. displayLoadingUI: () => void;
  41376. /**
  41377. * Function called to hide the loading screen
  41378. */
  41379. hideLoadingUI: () => void;
  41380. /**
  41381. * Gets or sets the color to use for the background
  41382. */
  41383. loadingUIBackgroundColor: string;
  41384. /**
  41385. * Gets or sets the text to display while loading
  41386. */
  41387. loadingUIText: string;
  41388. }
  41389. /**
  41390. * Class used for the default loading screen
  41391. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41392. */
  41393. export class DefaultLoadingScreen implements ILoadingScreen {
  41394. private _renderingCanvas;
  41395. private _loadingText;
  41396. private _loadingDivBackgroundColor;
  41397. private _loadingDiv;
  41398. private _loadingTextDiv;
  41399. /** Gets or sets the logo url to use for the default loading screen */
  41400. static DefaultLogoUrl: string;
  41401. /** Gets or sets the spinner url to use for the default loading screen */
  41402. static DefaultSpinnerUrl: string;
  41403. /**
  41404. * Creates a new default loading screen
  41405. * @param _renderingCanvas defines the canvas used to render the scene
  41406. * @param _loadingText defines the default text to display
  41407. * @param _loadingDivBackgroundColor defines the default background color
  41408. */
  41409. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41410. /**
  41411. * Function called to display the loading screen
  41412. */
  41413. displayLoadingUI(): void;
  41414. /**
  41415. * Function called to hide the loading screen
  41416. */
  41417. hideLoadingUI(): void;
  41418. /**
  41419. * Gets or sets the text to display while loading
  41420. */
  41421. set loadingUIText(text: string);
  41422. get loadingUIText(): string;
  41423. /**
  41424. * Gets or sets the color to use for the background
  41425. */
  41426. get loadingUIBackgroundColor(): string;
  41427. set loadingUIBackgroundColor(color: string);
  41428. private _resizeLoadingUI;
  41429. }
  41430. }
  41431. declare module BABYLON {
  41432. /**
  41433. * Interface for any object that can request an animation frame
  41434. */
  41435. export interface ICustomAnimationFrameRequester {
  41436. /**
  41437. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41438. */
  41439. renderFunction?: Function;
  41440. /**
  41441. * Called to request the next frame to render to
  41442. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41443. */
  41444. requestAnimationFrame: Function;
  41445. /**
  41446. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41447. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41448. */
  41449. requestID?: number;
  41450. }
  41451. }
  41452. declare module BABYLON {
  41453. /**
  41454. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41455. */
  41456. export class PerformanceMonitor {
  41457. private _enabled;
  41458. private _rollingFrameTime;
  41459. private _lastFrameTimeMs;
  41460. /**
  41461. * constructor
  41462. * @param frameSampleSize The number of samples required to saturate the sliding window
  41463. */
  41464. constructor(frameSampleSize?: number);
  41465. /**
  41466. * Samples current frame
  41467. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41468. */
  41469. sampleFrame(timeMs?: number): void;
  41470. /**
  41471. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41472. */
  41473. get averageFrameTime(): number;
  41474. /**
  41475. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41476. */
  41477. get averageFrameTimeVariance(): number;
  41478. /**
  41479. * Returns the frame time of the most recent frame
  41480. */
  41481. get instantaneousFrameTime(): number;
  41482. /**
  41483. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41484. */
  41485. get averageFPS(): number;
  41486. /**
  41487. * Returns the average framerate in frames per second using the most recent frame time
  41488. */
  41489. get instantaneousFPS(): number;
  41490. /**
  41491. * Returns true if enough samples have been taken to completely fill the sliding window
  41492. */
  41493. get isSaturated(): boolean;
  41494. /**
  41495. * Enables contributions to the sliding window sample set
  41496. */
  41497. enable(): void;
  41498. /**
  41499. * Disables contributions to the sliding window sample set
  41500. * Samples will not be interpolated over the disabled period
  41501. */
  41502. disable(): void;
  41503. /**
  41504. * Returns true if sampling is enabled
  41505. */
  41506. get isEnabled(): boolean;
  41507. /**
  41508. * Resets performance monitor
  41509. */
  41510. reset(): void;
  41511. }
  41512. /**
  41513. * RollingAverage
  41514. *
  41515. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41516. */
  41517. export class RollingAverage {
  41518. /**
  41519. * Current average
  41520. */
  41521. average: number;
  41522. /**
  41523. * Current variance
  41524. */
  41525. variance: number;
  41526. protected _samples: Array<number>;
  41527. protected _sampleCount: number;
  41528. protected _pos: number;
  41529. protected _m2: number;
  41530. /**
  41531. * constructor
  41532. * @param length The number of samples required to saturate the sliding window
  41533. */
  41534. constructor(length: number);
  41535. /**
  41536. * Adds a sample to the sample set
  41537. * @param v The sample value
  41538. */
  41539. add(v: number): void;
  41540. /**
  41541. * Returns previously added values or null if outside of history or outside the sliding window domain
  41542. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  41543. * @return Value previously recorded with add() or null if outside of range
  41544. */
  41545. history(i: number): number;
  41546. /**
  41547. * Returns true if enough samples have been taken to completely fill the sliding window
  41548. * @return true if sample-set saturated
  41549. */
  41550. isSaturated(): boolean;
  41551. /**
  41552. * Resets the rolling average (equivalent to 0 samples taken so far)
  41553. */
  41554. reset(): void;
  41555. /**
  41556. * Wraps a value around the sample range boundaries
  41557. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  41558. * @return Wrapped position in sample range
  41559. */
  41560. protected _wrapPosition(i: number): number;
  41561. }
  41562. }
  41563. declare module BABYLON {
  41564. /**
  41565. * This class is used to track a performance counter which is number based.
  41566. * The user has access to many properties which give statistics of different nature.
  41567. *
  41568. * The implementer can track two kinds of Performance Counter: time and count.
  41569. * 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.
  41570. * 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.
  41571. */
  41572. export class PerfCounter {
  41573. /**
  41574. * Gets or sets a global boolean to turn on and off all the counters
  41575. */
  41576. static Enabled: boolean;
  41577. /**
  41578. * Returns the smallest value ever
  41579. */
  41580. get min(): number;
  41581. /**
  41582. * Returns the biggest value ever
  41583. */
  41584. get max(): number;
  41585. /**
  41586. * Returns the average value since the performance counter is running
  41587. */
  41588. get average(): number;
  41589. /**
  41590. * Returns the average value of the last second the counter was monitored
  41591. */
  41592. get lastSecAverage(): number;
  41593. /**
  41594. * Returns the current value
  41595. */
  41596. get current(): number;
  41597. /**
  41598. * Gets the accumulated total
  41599. */
  41600. get total(): number;
  41601. /**
  41602. * Gets the total value count
  41603. */
  41604. get count(): number;
  41605. /**
  41606. * Creates a new counter
  41607. */
  41608. constructor();
  41609. /**
  41610. * Call this method to start monitoring a new frame.
  41611. * 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.
  41612. */
  41613. fetchNewFrame(): void;
  41614. /**
  41615. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  41616. * @param newCount the count value to add to the monitored count
  41617. * @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.
  41618. */
  41619. addCount(newCount: number, fetchResult: boolean): void;
  41620. /**
  41621. * Start monitoring this performance counter
  41622. */
  41623. beginMonitoring(): void;
  41624. /**
  41625. * Compute the time lapsed since the previous beginMonitoring() call.
  41626. * @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
  41627. */
  41628. endMonitoring(newFrame?: boolean): void;
  41629. private _fetchResult;
  41630. private _startMonitoringTime;
  41631. private _min;
  41632. private _max;
  41633. private _average;
  41634. private _current;
  41635. private _totalValueCount;
  41636. private _totalAccumulated;
  41637. private _lastSecAverage;
  41638. private _lastSecAccumulated;
  41639. private _lastSecTime;
  41640. private _lastSecValueCount;
  41641. }
  41642. }
  41643. declare module BABYLON {
  41644. interface ThinEngine {
  41645. /** @hidden */
  41646. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  41647. }
  41648. }
  41649. declare module BABYLON {
  41650. /**
  41651. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41652. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41653. */
  41654. export class Analyser {
  41655. /**
  41656. * Gets or sets the smoothing
  41657. * @ignorenaming
  41658. */
  41659. SMOOTHING: number;
  41660. /**
  41661. * Gets or sets the FFT table size
  41662. * @ignorenaming
  41663. */
  41664. FFT_SIZE: number;
  41665. /**
  41666. * Gets or sets the bar graph amplitude
  41667. * @ignorenaming
  41668. */
  41669. BARGRAPHAMPLITUDE: number;
  41670. /**
  41671. * Gets or sets the position of the debug canvas
  41672. * @ignorenaming
  41673. */
  41674. DEBUGCANVASPOS: {
  41675. x: number;
  41676. y: number;
  41677. };
  41678. /**
  41679. * Gets or sets the debug canvas size
  41680. * @ignorenaming
  41681. */
  41682. DEBUGCANVASSIZE: {
  41683. width: number;
  41684. height: number;
  41685. };
  41686. private _byteFreqs;
  41687. private _byteTime;
  41688. private _floatFreqs;
  41689. private _webAudioAnalyser;
  41690. private _debugCanvas;
  41691. private _debugCanvasContext;
  41692. private _scene;
  41693. private _registerFunc;
  41694. private _audioEngine;
  41695. /**
  41696. * Creates a new analyser
  41697. * @param scene defines hosting scene
  41698. */
  41699. constructor(scene: Scene);
  41700. /**
  41701. * Get the number of data values you will have to play with for the visualization
  41702. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41703. * @returns a number
  41704. */
  41705. getFrequencyBinCount(): number;
  41706. /**
  41707. * Gets the current frequency data as a byte array
  41708. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41709. * @returns a Uint8Array
  41710. */
  41711. getByteFrequencyData(): Uint8Array;
  41712. /**
  41713. * Gets the current waveform as a byte array
  41714. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41715. * @returns a Uint8Array
  41716. */
  41717. getByteTimeDomainData(): Uint8Array;
  41718. /**
  41719. * Gets the current frequency data as a float array
  41720. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41721. * @returns a Float32Array
  41722. */
  41723. getFloatFrequencyData(): Float32Array;
  41724. /**
  41725. * Renders the debug canvas
  41726. */
  41727. drawDebugCanvas(): void;
  41728. /**
  41729. * Stops rendering the debug canvas and removes it
  41730. */
  41731. stopDebugCanvas(): void;
  41732. /**
  41733. * Connects two audio nodes
  41734. * @param inputAudioNode defines first node to connect
  41735. * @param outputAudioNode defines second node to connect
  41736. */
  41737. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41738. /**
  41739. * Releases all associated resources
  41740. */
  41741. dispose(): void;
  41742. }
  41743. }
  41744. declare module BABYLON {
  41745. /**
  41746. * This represents an audio engine and it is responsible
  41747. * to play, synchronize and analyse sounds throughout the application.
  41748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41749. */
  41750. export interface IAudioEngine extends IDisposable {
  41751. /**
  41752. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41753. */
  41754. readonly canUseWebAudio: boolean;
  41755. /**
  41756. * Gets the current AudioContext if available.
  41757. */
  41758. readonly audioContext: Nullable<AudioContext>;
  41759. /**
  41760. * The master gain node defines the global audio volume of your audio engine.
  41761. */
  41762. readonly masterGain: GainNode;
  41763. /**
  41764. * Gets whether or not mp3 are supported by your browser.
  41765. */
  41766. readonly isMP3supported: boolean;
  41767. /**
  41768. * Gets whether or not ogg are supported by your browser.
  41769. */
  41770. readonly isOGGsupported: boolean;
  41771. /**
  41772. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41773. * @ignoreNaming
  41774. */
  41775. WarnedWebAudioUnsupported: boolean;
  41776. /**
  41777. * Defines if the audio engine relies on a custom unlocked button.
  41778. * In this case, the embedded button will not be displayed.
  41779. */
  41780. useCustomUnlockedButton: boolean;
  41781. /**
  41782. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41783. */
  41784. readonly unlocked: boolean;
  41785. /**
  41786. * Event raised when audio has been unlocked on the browser.
  41787. */
  41788. onAudioUnlockedObservable: Observable<IAudioEngine>;
  41789. /**
  41790. * Event raised when audio has been locked on the browser.
  41791. */
  41792. onAudioLockedObservable: Observable<IAudioEngine>;
  41793. /**
  41794. * Flags the audio engine in Locked state.
  41795. * This happens due to new browser policies preventing audio to autoplay.
  41796. */
  41797. lock(): void;
  41798. /**
  41799. * Unlocks the audio engine once a user action has been done on the dom.
  41800. * This is helpful to resume play once browser policies have been satisfied.
  41801. */
  41802. unlock(): void;
  41803. /**
  41804. * Gets the global volume sets on the master gain.
  41805. * @returns the global volume if set or -1 otherwise
  41806. */
  41807. getGlobalVolume(): number;
  41808. /**
  41809. * Sets the global volume of your experience (sets on the master gain).
  41810. * @param newVolume Defines the new global volume of the application
  41811. */
  41812. setGlobalVolume(newVolume: number): void;
  41813. /**
  41814. * Connect the audio engine to an audio analyser allowing some amazing
  41815. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41816. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41817. * @param analyser The analyser to connect to the engine
  41818. */
  41819. connectToAnalyser(analyser: Analyser): void;
  41820. }
  41821. }
  41822. declare module BABYLON {
  41823. /**
  41824. * Defines the interface used by display changed events
  41825. */
  41826. export interface IDisplayChangedEventArgs {
  41827. /** Gets the vrDisplay object (if any) */
  41828. vrDisplay: Nullable<any>;
  41829. /** Gets a boolean indicating if webVR is supported */
  41830. vrSupported: boolean;
  41831. }
  41832. /**
  41833. * Defines the interface used by objects containing a viewport (like a camera)
  41834. */
  41835. interface IViewportOwnerLike {
  41836. /**
  41837. * Gets or sets the viewport
  41838. */
  41839. viewport: IViewportLike;
  41840. }
  41841. /**
  41842. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  41843. */
  41844. export class Engine extends ThinEngine {
  41845. /** Defines that alpha blending is disabled */
  41846. static readonly ALPHA_DISABLE: number;
  41847. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  41848. static readonly ALPHA_ADD: number;
  41849. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  41850. static readonly ALPHA_COMBINE: number;
  41851. /** Defines that alpha blending to DEST - SRC * DEST */
  41852. static readonly ALPHA_SUBTRACT: number;
  41853. /** Defines that alpha blending to SRC * DEST */
  41854. static readonly ALPHA_MULTIPLY: number;
  41855. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  41856. static readonly ALPHA_MAXIMIZED: number;
  41857. /** Defines that alpha blending to SRC + DEST */
  41858. static readonly ALPHA_ONEONE: number;
  41859. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  41860. static readonly ALPHA_PREMULTIPLIED: number;
  41861. /**
  41862. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  41863. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  41864. */
  41865. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  41866. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  41867. static readonly ALPHA_INTERPOLATE: number;
  41868. /**
  41869. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  41870. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  41871. */
  41872. static readonly ALPHA_SCREENMODE: number;
  41873. /** Defines that the ressource is not delayed*/
  41874. static readonly DELAYLOADSTATE_NONE: number;
  41875. /** Defines that the ressource was successfully delay loaded */
  41876. static readonly DELAYLOADSTATE_LOADED: number;
  41877. /** Defines that the ressource is currently delay loading */
  41878. static readonly DELAYLOADSTATE_LOADING: number;
  41879. /** Defines that the ressource is delayed and has not started loading */
  41880. static readonly DELAYLOADSTATE_NOTLOADED: number;
  41881. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  41882. static readonly NEVER: number;
  41883. /** 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 */
  41884. static readonly ALWAYS: number;
  41885. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  41886. static readonly LESS: number;
  41887. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  41888. static readonly EQUAL: number;
  41889. /** 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 */
  41890. static readonly LEQUAL: number;
  41891. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  41892. static readonly GREATER: number;
  41893. /** 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 */
  41894. static readonly GEQUAL: number;
  41895. /** 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 */
  41896. static readonly NOTEQUAL: number;
  41897. /** Passed to stencilOperation to specify that stencil value must be kept */
  41898. static readonly KEEP: number;
  41899. /** Passed to stencilOperation to specify that stencil value must be replaced */
  41900. static readonly REPLACE: number;
  41901. /** Passed to stencilOperation to specify that stencil value must be incremented */
  41902. static readonly INCR: number;
  41903. /** Passed to stencilOperation to specify that stencil value must be decremented */
  41904. static readonly DECR: number;
  41905. /** Passed to stencilOperation to specify that stencil value must be inverted */
  41906. static readonly INVERT: number;
  41907. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  41908. static readonly INCR_WRAP: number;
  41909. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  41910. static readonly DECR_WRAP: number;
  41911. /** Texture is not repeating outside of 0..1 UVs */
  41912. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  41913. /** Texture is repeating outside of 0..1 UVs */
  41914. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  41915. /** Texture is repeating and mirrored */
  41916. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  41917. /** ALPHA */
  41918. static readonly TEXTUREFORMAT_ALPHA: number;
  41919. /** LUMINANCE */
  41920. static readonly TEXTUREFORMAT_LUMINANCE: number;
  41921. /** LUMINANCE_ALPHA */
  41922. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  41923. /** RGB */
  41924. static readonly TEXTUREFORMAT_RGB: number;
  41925. /** RGBA */
  41926. static readonly TEXTUREFORMAT_RGBA: number;
  41927. /** RED */
  41928. static readonly TEXTUREFORMAT_RED: number;
  41929. /** RED (2nd reference) */
  41930. static readonly TEXTUREFORMAT_R: number;
  41931. /** RG */
  41932. static readonly TEXTUREFORMAT_RG: number;
  41933. /** RED_INTEGER */
  41934. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  41935. /** RED_INTEGER (2nd reference) */
  41936. static readonly TEXTUREFORMAT_R_INTEGER: number;
  41937. /** RG_INTEGER */
  41938. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  41939. /** RGB_INTEGER */
  41940. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  41941. /** RGBA_INTEGER */
  41942. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  41943. /** UNSIGNED_BYTE */
  41944. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  41945. /** UNSIGNED_BYTE (2nd reference) */
  41946. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  41947. /** FLOAT */
  41948. static readonly TEXTURETYPE_FLOAT: number;
  41949. /** HALF_FLOAT */
  41950. static readonly TEXTURETYPE_HALF_FLOAT: number;
  41951. /** BYTE */
  41952. static readonly TEXTURETYPE_BYTE: number;
  41953. /** SHORT */
  41954. static readonly TEXTURETYPE_SHORT: number;
  41955. /** UNSIGNED_SHORT */
  41956. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  41957. /** INT */
  41958. static readonly TEXTURETYPE_INT: number;
  41959. /** UNSIGNED_INT */
  41960. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  41961. /** UNSIGNED_SHORT_4_4_4_4 */
  41962. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  41963. /** UNSIGNED_SHORT_5_5_5_1 */
  41964. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  41965. /** UNSIGNED_SHORT_5_6_5 */
  41966. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  41967. /** UNSIGNED_INT_2_10_10_10_REV */
  41968. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  41969. /** UNSIGNED_INT_24_8 */
  41970. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  41971. /** UNSIGNED_INT_10F_11F_11F_REV */
  41972. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  41973. /** UNSIGNED_INT_5_9_9_9_REV */
  41974. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  41975. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  41976. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  41977. /** nearest is mag = nearest and min = nearest and mip = none */
  41978. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  41979. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41980. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  41981. /** Trilinear is mag = linear and min = linear and mip = linear */
  41982. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  41983. /** nearest is mag = nearest and min = nearest and mip = linear */
  41984. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  41985. /** Bilinear is mag = linear and min = linear and mip = nearest */
  41986. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  41987. /** Trilinear is mag = linear and min = linear and mip = linear */
  41988. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  41989. /** mag = nearest and min = nearest and mip = nearest */
  41990. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  41991. /** mag = nearest and min = linear and mip = nearest */
  41992. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  41993. /** mag = nearest and min = linear and mip = linear */
  41994. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  41995. /** mag = nearest and min = linear and mip = none */
  41996. static readonly TEXTURE_NEAREST_LINEAR: number;
  41997. /** mag = nearest and min = nearest and mip = none */
  41998. static readonly TEXTURE_NEAREST_NEAREST: number;
  41999. /** mag = linear and min = nearest and mip = nearest */
  42000. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42001. /** mag = linear and min = nearest and mip = linear */
  42002. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42003. /** mag = linear and min = linear and mip = none */
  42004. static readonly TEXTURE_LINEAR_LINEAR: number;
  42005. /** mag = linear and min = nearest and mip = none */
  42006. static readonly TEXTURE_LINEAR_NEAREST: number;
  42007. /** Explicit coordinates mode */
  42008. static readonly TEXTURE_EXPLICIT_MODE: number;
  42009. /** Spherical coordinates mode */
  42010. static readonly TEXTURE_SPHERICAL_MODE: number;
  42011. /** Planar coordinates mode */
  42012. static readonly TEXTURE_PLANAR_MODE: number;
  42013. /** Cubic coordinates mode */
  42014. static readonly TEXTURE_CUBIC_MODE: number;
  42015. /** Projection coordinates mode */
  42016. static readonly TEXTURE_PROJECTION_MODE: number;
  42017. /** Skybox coordinates mode */
  42018. static readonly TEXTURE_SKYBOX_MODE: number;
  42019. /** Inverse Cubic coordinates mode */
  42020. static readonly TEXTURE_INVCUBIC_MODE: number;
  42021. /** Equirectangular coordinates mode */
  42022. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42023. /** Equirectangular Fixed coordinates mode */
  42024. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42025. /** Equirectangular Fixed Mirrored coordinates mode */
  42026. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42027. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42028. static readonly SCALEMODE_FLOOR: number;
  42029. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42030. static readonly SCALEMODE_NEAREST: number;
  42031. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42032. static readonly SCALEMODE_CEILING: number;
  42033. /**
  42034. * Returns the current npm package of the sdk
  42035. */
  42036. static get NpmPackage(): string;
  42037. /**
  42038. * Returns the current version of the framework
  42039. */
  42040. static get Version(): string;
  42041. /** Gets the list of created engines */
  42042. static get Instances(): Engine[];
  42043. /**
  42044. * Gets the latest created engine
  42045. */
  42046. static get LastCreatedEngine(): Nullable<Engine>;
  42047. /**
  42048. * Gets the latest created scene
  42049. */
  42050. static get LastCreatedScene(): Nullable<Scene>;
  42051. /**
  42052. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42053. * @param flag defines which part of the materials must be marked as dirty
  42054. * @param predicate defines a predicate used to filter which materials should be affected
  42055. */
  42056. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42057. /**
  42058. * Method called to create the default loading screen.
  42059. * This can be overriden in your own app.
  42060. * @param canvas The rendering canvas element
  42061. * @returns The loading screen
  42062. */
  42063. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42064. /**
  42065. * Method called to create the default rescale post process on each engine.
  42066. */
  42067. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42068. /**
  42069. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42070. **/
  42071. enableOfflineSupport: boolean;
  42072. /**
  42073. * 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)
  42074. **/
  42075. disableManifestCheck: boolean;
  42076. /**
  42077. * Gets the list of created scenes
  42078. */
  42079. scenes: Scene[];
  42080. /**
  42081. * Event raised when a new scene is created
  42082. */
  42083. onNewSceneAddedObservable: Observable<Scene>;
  42084. /**
  42085. * Gets the list of created postprocesses
  42086. */
  42087. postProcesses: PostProcess[];
  42088. /**
  42089. * Gets a boolean indicating if the pointer is currently locked
  42090. */
  42091. isPointerLock: boolean;
  42092. /**
  42093. * Observable event triggered each time the rendering canvas is resized
  42094. */
  42095. onResizeObservable: Observable<Engine>;
  42096. /**
  42097. * Observable event triggered each time the canvas loses focus
  42098. */
  42099. onCanvasBlurObservable: Observable<Engine>;
  42100. /**
  42101. * Observable event triggered each time the canvas gains focus
  42102. */
  42103. onCanvasFocusObservable: Observable<Engine>;
  42104. /**
  42105. * Observable event triggered each time the canvas receives pointerout event
  42106. */
  42107. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42108. /**
  42109. * Observable raised when the engine begins a new frame
  42110. */
  42111. onBeginFrameObservable: Observable<Engine>;
  42112. /**
  42113. * If set, will be used to request the next animation frame for the render loop
  42114. */
  42115. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42116. /**
  42117. * Observable raised when the engine ends the current frame
  42118. */
  42119. onEndFrameObservable: Observable<Engine>;
  42120. /**
  42121. * Observable raised when the engine is about to compile a shader
  42122. */
  42123. onBeforeShaderCompilationObservable: Observable<Engine>;
  42124. /**
  42125. * Observable raised when the engine has jsut compiled a shader
  42126. */
  42127. onAfterShaderCompilationObservable: Observable<Engine>;
  42128. /**
  42129. * Gets the audio engine
  42130. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42131. * @ignorenaming
  42132. */
  42133. static audioEngine: IAudioEngine;
  42134. /**
  42135. * Default AudioEngine factory responsible of creating the Audio Engine.
  42136. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42137. */
  42138. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42139. /**
  42140. * Default offline support factory responsible of creating a tool used to store data locally.
  42141. * By default, this will create a Database object if the workload has been embedded.
  42142. */
  42143. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42144. private _loadingScreen;
  42145. private _pointerLockRequested;
  42146. private _rescalePostProcess;
  42147. protected _deterministicLockstep: boolean;
  42148. protected _lockstepMaxSteps: number;
  42149. protected _timeStep: number;
  42150. protected get _supportsHardwareTextureRescaling(): boolean;
  42151. private _fps;
  42152. private _deltaTime;
  42153. /** @hidden */
  42154. _drawCalls: PerfCounter;
  42155. /** 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 */
  42156. canvasTabIndex: number;
  42157. /**
  42158. * Turn this value on if you want to pause FPS computation when in background
  42159. */
  42160. disablePerformanceMonitorInBackground: boolean;
  42161. private _performanceMonitor;
  42162. /**
  42163. * Gets the performance monitor attached to this engine
  42164. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42165. */
  42166. get performanceMonitor(): PerformanceMonitor;
  42167. private _onFocus;
  42168. private _onBlur;
  42169. private _onCanvasPointerOut;
  42170. private _onCanvasBlur;
  42171. private _onCanvasFocus;
  42172. private _onFullscreenChange;
  42173. private _onPointerLockChange;
  42174. /**
  42175. * Gets the HTML element used to attach event listeners
  42176. * @returns a HTML element
  42177. */
  42178. getInputElement(): Nullable<HTMLElement>;
  42179. /**
  42180. * Creates a new engine
  42181. * @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
  42182. * @param antialias defines enable antialiasing (default: false)
  42183. * @param options defines further options to be sent to the getContext() function
  42184. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42185. */
  42186. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42187. /**
  42188. * Shared initialization across engines types.
  42189. * @param canvas The canvas associated with this instance of the engine.
  42190. * @param doNotHandleTouchAction Defines that engine should ignore modifying touch action attribute and style
  42191. * @param audioEngine Defines if an audio engine should be created by default
  42192. */
  42193. protected _sharedInit(canvas: HTMLCanvasElement, doNotHandleTouchAction: boolean, audioEngine: boolean): void;
  42194. /**
  42195. * Gets current aspect ratio
  42196. * @param viewportOwner defines the camera to use to get the aspect ratio
  42197. * @param useScreen defines if screen size must be used (or the current render target if any)
  42198. * @returns a number defining the aspect ratio
  42199. */
  42200. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42201. /**
  42202. * Gets current screen aspect ratio
  42203. * @returns a number defining the aspect ratio
  42204. */
  42205. getScreenAspectRatio(): number;
  42206. /**
  42207. * Gets the client rect of the HTML canvas attached with the current webGL context
  42208. * @returns a client rectanglee
  42209. */
  42210. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42211. /**
  42212. * Gets the client rect of the HTML element used for events
  42213. * @returns a client rectanglee
  42214. */
  42215. getInputElementClientRect(): Nullable<ClientRect>;
  42216. /**
  42217. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42218. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42219. * @returns true if engine is in deterministic lock step mode
  42220. */
  42221. isDeterministicLockStep(): boolean;
  42222. /**
  42223. * Gets the max steps when engine is running in deterministic lock step
  42224. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42225. * @returns the max steps
  42226. */
  42227. getLockstepMaxSteps(): number;
  42228. /**
  42229. * Returns the time in ms between steps when using deterministic lock step.
  42230. * @returns time step in (ms)
  42231. */
  42232. getTimeStep(): number;
  42233. /**
  42234. * Force the mipmap generation for the given render target texture
  42235. * @param texture defines the render target texture to use
  42236. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42237. */
  42238. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42239. /** States */
  42240. /**
  42241. * Set various states to the webGL context
  42242. * @param culling defines backface culling state
  42243. * @param zOffset defines the value to apply to zOffset (0 by default)
  42244. * @param force defines if states must be applied even if cache is up to date
  42245. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42246. */
  42247. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42248. /**
  42249. * Set the z offset to apply to current rendering
  42250. * @param value defines the offset to apply
  42251. */
  42252. setZOffset(value: number): void;
  42253. /**
  42254. * Gets the current value of the zOffset
  42255. * @returns the current zOffset state
  42256. */
  42257. getZOffset(): number;
  42258. /**
  42259. * Gets a boolean indicating if depth testing is enabled
  42260. * @returns the current state
  42261. */
  42262. getDepthBuffer(): boolean;
  42263. /**
  42264. * Enable or disable depth buffering
  42265. * @param enable defines the state to set
  42266. */
  42267. setDepthBuffer(enable: boolean): void;
  42268. /**
  42269. * Gets a boolean indicating if depth writing is enabled
  42270. * @returns the current depth writing state
  42271. */
  42272. getDepthWrite(): boolean;
  42273. /**
  42274. * Enable or disable depth writing
  42275. * @param enable defines the state to set
  42276. */
  42277. setDepthWrite(enable: boolean): void;
  42278. /**
  42279. * Gets a boolean indicating if stencil buffer is enabled
  42280. * @returns the current stencil buffer state
  42281. */
  42282. getStencilBuffer(): boolean;
  42283. /**
  42284. * Enable or disable the stencil buffer
  42285. * @param enable defines if the stencil buffer must be enabled or disabled
  42286. */
  42287. setStencilBuffer(enable: boolean): void;
  42288. /**
  42289. * Gets the current stencil mask
  42290. * @returns a number defining the new stencil mask to use
  42291. */
  42292. getStencilMask(): number;
  42293. /**
  42294. * Sets the current stencil mask
  42295. * @param mask defines the new stencil mask to use
  42296. */
  42297. setStencilMask(mask: number): void;
  42298. /**
  42299. * Gets the current stencil function
  42300. * @returns a number defining the stencil function to use
  42301. */
  42302. getStencilFunction(): number;
  42303. /**
  42304. * Gets the current stencil reference value
  42305. * @returns a number defining the stencil reference value to use
  42306. */
  42307. getStencilFunctionReference(): number;
  42308. /**
  42309. * Gets the current stencil mask
  42310. * @returns a number defining the stencil mask to use
  42311. */
  42312. getStencilFunctionMask(): number;
  42313. /**
  42314. * Sets the current stencil function
  42315. * @param stencilFunc defines the new stencil function to use
  42316. */
  42317. setStencilFunction(stencilFunc: number): void;
  42318. /**
  42319. * Sets the current stencil reference
  42320. * @param reference defines the new stencil reference to use
  42321. */
  42322. setStencilFunctionReference(reference: number): void;
  42323. /**
  42324. * Sets the current stencil mask
  42325. * @param mask defines the new stencil mask to use
  42326. */
  42327. setStencilFunctionMask(mask: number): void;
  42328. /**
  42329. * Gets the current stencil operation when stencil fails
  42330. * @returns a number defining stencil operation to use when stencil fails
  42331. */
  42332. getStencilOperationFail(): number;
  42333. /**
  42334. * Gets the current stencil operation when depth fails
  42335. * @returns a number defining stencil operation to use when depth fails
  42336. */
  42337. getStencilOperationDepthFail(): number;
  42338. /**
  42339. * Gets the current stencil operation when stencil passes
  42340. * @returns a number defining stencil operation to use when stencil passes
  42341. */
  42342. getStencilOperationPass(): number;
  42343. /**
  42344. * Sets the stencil operation to use when stencil fails
  42345. * @param operation defines the stencil operation to use when stencil fails
  42346. */
  42347. setStencilOperationFail(operation: number): void;
  42348. /**
  42349. * Sets the stencil operation to use when depth fails
  42350. * @param operation defines the stencil operation to use when depth fails
  42351. */
  42352. setStencilOperationDepthFail(operation: number): void;
  42353. /**
  42354. * Sets the stencil operation to use when stencil passes
  42355. * @param operation defines the stencil operation to use when stencil passes
  42356. */
  42357. setStencilOperationPass(operation: number): void;
  42358. /**
  42359. * Sets a boolean indicating if the dithering state is enabled or disabled
  42360. * @param value defines the dithering state
  42361. */
  42362. setDitheringState(value: boolean): void;
  42363. /**
  42364. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42365. * @param value defines the rasterizer state
  42366. */
  42367. setRasterizerState(value: boolean): void;
  42368. /**
  42369. * Gets the current depth function
  42370. * @returns a number defining the depth function
  42371. */
  42372. getDepthFunction(): Nullable<number>;
  42373. /**
  42374. * Sets the current depth function
  42375. * @param depthFunc defines the function to use
  42376. */
  42377. setDepthFunction(depthFunc: number): void;
  42378. /**
  42379. * Sets the current depth function to GREATER
  42380. */
  42381. setDepthFunctionToGreater(): void;
  42382. /**
  42383. * Sets the current depth function to GEQUAL
  42384. */
  42385. setDepthFunctionToGreaterOrEqual(): void;
  42386. /**
  42387. * Sets the current depth function to LESS
  42388. */
  42389. setDepthFunctionToLess(): void;
  42390. /**
  42391. * Sets the current depth function to LEQUAL
  42392. */
  42393. setDepthFunctionToLessOrEqual(): void;
  42394. private _cachedStencilBuffer;
  42395. private _cachedStencilFunction;
  42396. private _cachedStencilMask;
  42397. private _cachedStencilOperationPass;
  42398. private _cachedStencilOperationFail;
  42399. private _cachedStencilOperationDepthFail;
  42400. private _cachedStencilReference;
  42401. /**
  42402. * Caches the the state of the stencil buffer
  42403. */
  42404. cacheStencilState(): void;
  42405. /**
  42406. * Restores the state of the stencil buffer
  42407. */
  42408. restoreStencilState(): void;
  42409. /**
  42410. * Directly set the WebGL Viewport
  42411. * @param x defines the x coordinate of the viewport (in screen space)
  42412. * @param y defines the y coordinate of the viewport (in screen space)
  42413. * @param width defines the width of the viewport (in screen space)
  42414. * @param height defines the height of the viewport (in screen space)
  42415. * @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
  42416. */
  42417. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42418. /**
  42419. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42421. * @param y defines the y-coordinate of the corner of the clear rectangle
  42422. * @param width defines the width of the clear rectangle
  42423. * @param height defines the height of the clear rectangle
  42424. * @param clearColor defines the clear color
  42425. */
  42426. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42427. /**
  42428. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42430. * @param y defines the y-coordinate of the corner of the clear rectangle
  42431. * @param width defines the width of the clear rectangle
  42432. * @param height defines the height of the clear rectangle
  42433. */
  42434. enableScissor(x: number, y: number, width: number, height: number): void;
  42435. /**
  42436. * Disable previously set scissor test rectangle
  42437. */
  42438. disableScissor(): void;
  42439. protected _reportDrawCall(): void;
  42440. /**
  42441. * Initializes a webVR display and starts listening to display change events
  42442. * The onVRDisplayChangedObservable will be notified upon these changes
  42443. * @returns The onVRDisplayChangedObservable
  42444. */
  42445. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42446. /** @hidden */
  42447. _prepareVRComponent(): void;
  42448. /** @hidden */
  42449. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42450. /** @hidden */
  42451. _submitVRFrame(): void;
  42452. /**
  42453. * Call this function to leave webVR mode
  42454. * Will do nothing if webVR is not supported or if there is no webVR device
  42455. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42456. */
  42457. disableVR(): void;
  42458. /**
  42459. * Gets a boolean indicating that the system is in VR mode and is presenting
  42460. * @returns true if VR mode is engaged
  42461. */
  42462. isVRPresenting(): boolean;
  42463. /** @hidden */
  42464. _requestVRFrame(): void;
  42465. /** @hidden */
  42466. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42467. /**
  42468. * Gets the source code of the vertex shader associated with a specific webGL program
  42469. * @param program defines the program to use
  42470. * @returns a string containing the source code of the vertex shader associated with the program
  42471. */
  42472. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42473. /**
  42474. * Gets the source code of the fragment shader associated with a specific webGL program
  42475. * @param program defines the program to use
  42476. * @returns a string containing the source code of the fragment shader associated with the program
  42477. */
  42478. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42479. /**
  42480. * Sets a depth stencil texture from a render target to the according uniform.
  42481. * @param channel The texture channel
  42482. * @param uniform The uniform to set
  42483. * @param texture The render target texture containing the depth stencil texture to apply
  42484. * @param name The texture name
  42485. */
  42486. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>, name?: string): void;
  42487. /**
  42488. * Sets a texture to the webGL context from a postprocess
  42489. * @param channel defines the channel to use
  42490. * @param postProcess defines the source postprocess
  42491. * @param name name of the channel
  42492. */
  42493. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42494. /**
  42495. * Binds the output of the passed in post process to the texture channel specified
  42496. * @param channel The channel the texture should be bound to
  42497. * @param postProcess The post process which's output should be bound
  42498. * @param name name of the channel
  42499. */
  42500. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>, name: string): void;
  42501. protected _rebuildBuffers(): void;
  42502. /** @hidden */
  42503. _renderFrame(): void;
  42504. _renderLoop(): void;
  42505. /** @hidden */
  42506. _renderViews(): boolean;
  42507. /**
  42508. * Toggle full screen mode
  42509. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42510. */
  42511. switchFullscreen(requestPointerLock: boolean): void;
  42512. /**
  42513. * Enters full screen mode
  42514. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42515. */
  42516. enterFullscreen(requestPointerLock: boolean): void;
  42517. /**
  42518. * Exits full screen mode
  42519. */
  42520. exitFullscreen(): void;
  42521. /**
  42522. * Enters Pointerlock mode
  42523. */
  42524. enterPointerlock(): void;
  42525. /**
  42526. * Exits Pointerlock mode
  42527. */
  42528. exitPointerlock(): void;
  42529. /**
  42530. * Begin a new frame
  42531. */
  42532. beginFrame(): void;
  42533. /**
  42534. * End the current frame
  42535. */
  42536. endFrame(): void;
  42537. /**
  42538. * Resize the view according to the canvas' size
  42539. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42540. */
  42541. resize(forceSetSize?: boolean): void;
  42542. /**
  42543. * Force a specific size of the canvas
  42544. * @param width defines the new canvas' width
  42545. * @param height defines the new canvas' height
  42546. * @param forceSetSize true to force setting the sizes of the underlying canvas
  42547. * @returns true if the size was changed
  42548. */
  42549. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  42550. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42551. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42552. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42553. _releaseTexture(texture: InternalTexture): void;
  42554. /**
  42555. * @hidden
  42556. * Rescales a texture
  42557. * @param source input texutre
  42558. * @param destination destination texture
  42559. * @param scene scene to use to render the resize
  42560. * @param internalFormat format to use when resizing
  42561. * @param onComplete callback to be called when resize has completed
  42562. */
  42563. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42564. /**
  42565. * Gets the current framerate
  42566. * @returns a number representing the framerate
  42567. */
  42568. getFps(): number;
  42569. /**
  42570. * Gets the time spent between current and previous frame
  42571. * @returns a number representing the delta time in ms
  42572. */
  42573. getDeltaTime(): number;
  42574. private _measureFps;
  42575. /** @hidden */
  42576. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42577. /**
  42578. * Updates the sample count of a render target texture
  42579. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42580. * @param texture defines the texture to update
  42581. * @param samples defines the sample count to set
  42582. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42583. */
  42584. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42585. /**
  42586. * Updates a depth texture Comparison Mode and Function.
  42587. * If the comparison Function is equal to 0, the mode will be set to none.
  42588. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42589. * @param texture The texture to set the comparison function for
  42590. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42591. */
  42592. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42593. /**
  42594. * Creates a webGL buffer to use with instanciation
  42595. * @param capacity defines the size of the buffer
  42596. * @returns the webGL buffer
  42597. */
  42598. createInstancesBuffer(capacity: number): DataBuffer;
  42599. /**
  42600. * Delete a webGL buffer used with instanciation
  42601. * @param buffer defines the webGL buffer to delete
  42602. */
  42603. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42604. private _clientWaitAsync;
  42605. /** @hidden */
  42606. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Nullable<Promise<ArrayBufferView>>;
  42607. dispose(): void;
  42608. private _disableTouchAction;
  42609. /**
  42610. * Display the loading screen
  42611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42612. */
  42613. displayLoadingUI(): void;
  42614. /**
  42615. * Hide the loading screen
  42616. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42617. */
  42618. hideLoadingUI(): void;
  42619. /**
  42620. * Gets the current loading screen object
  42621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42622. */
  42623. get loadingScreen(): ILoadingScreen;
  42624. /**
  42625. * Sets the current loading screen object
  42626. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42627. */
  42628. set loadingScreen(loadingScreen: ILoadingScreen);
  42629. /**
  42630. * Sets the current loading screen text
  42631. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42632. */
  42633. set loadingUIText(text: string);
  42634. /**
  42635. * Sets the current loading screen background color
  42636. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42637. */
  42638. set loadingUIBackgroundColor(color: string);
  42639. /** Pointerlock and fullscreen */
  42640. /**
  42641. * Ask the browser to promote the current element to pointerlock mode
  42642. * @param element defines the DOM element to promote
  42643. */
  42644. static _RequestPointerlock(element: HTMLElement): void;
  42645. /**
  42646. * Asks the browser to exit pointerlock mode
  42647. */
  42648. static _ExitPointerlock(): void;
  42649. /**
  42650. * Ask the browser to promote the current element to fullscreen rendering mode
  42651. * @param element defines the DOM element to promote
  42652. */
  42653. static _RequestFullscreen(element: HTMLElement): void;
  42654. /**
  42655. * Asks the browser to exit fullscreen mode
  42656. */
  42657. static _ExitFullscreen(): void;
  42658. }
  42659. }
  42660. declare module BABYLON {
  42661. /**
  42662. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42663. * during the life time of the application.
  42664. */
  42665. export class EngineStore {
  42666. /** Gets the list of created engines */
  42667. static Instances: Engine[];
  42668. /** @hidden */
  42669. static _LastCreatedScene: Nullable<Scene>;
  42670. /**
  42671. * Gets the latest created engine
  42672. */
  42673. static get LastCreatedEngine(): Nullable<Engine>;
  42674. /**
  42675. * Gets the latest created scene
  42676. */
  42677. static get LastCreatedScene(): Nullable<Scene>;
  42678. /**
  42679. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42680. * @ignorenaming
  42681. */
  42682. static UseFallbackTexture: boolean;
  42683. /**
  42684. * Texture content used if a texture cannot loaded
  42685. * @ignorenaming
  42686. */
  42687. static FallbackTexture: string;
  42688. }
  42689. }
  42690. declare module BABYLON {
  42691. /**
  42692. * Helper class that provides a small promise polyfill
  42693. */
  42694. export class PromisePolyfill {
  42695. /**
  42696. * Static function used to check if the polyfill is required
  42697. * If this is the case then the function will inject the polyfill to window.Promise
  42698. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  42699. */
  42700. static Apply(force?: boolean): void;
  42701. }
  42702. }
  42703. declare module BABYLON {
  42704. /**
  42705. * Interface for screenshot methods with describe argument called `size` as object with options
  42706. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  42707. */
  42708. export interface IScreenshotSize {
  42709. /**
  42710. * number in pixels for canvas height
  42711. */
  42712. height?: number;
  42713. /**
  42714. * multiplier allowing render at a higher or lower resolution
  42715. * If value is defined then height and width will be ignored and taken from camera
  42716. */
  42717. precision?: number;
  42718. /**
  42719. * number in pixels for canvas width
  42720. */
  42721. width?: number;
  42722. }
  42723. }
  42724. declare module BABYLON {
  42725. interface IColor4Like {
  42726. r: float;
  42727. g: float;
  42728. b: float;
  42729. a: float;
  42730. }
  42731. /**
  42732. * Class containing a set of static utilities functions
  42733. */
  42734. export class Tools {
  42735. /**
  42736. * Gets or sets the base URL to use to load assets
  42737. */
  42738. static get BaseUrl(): string;
  42739. static set BaseUrl(value: string);
  42740. /**
  42741. * Enable/Disable Custom HTTP Request Headers globally.
  42742. * default = false
  42743. * @see CustomRequestHeaders
  42744. */
  42745. static UseCustomRequestHeaders: boolean;
  42746. /**
  42747. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  42748. * i.e. when loading files, where the server/service expects an Authorization header
  42749. */
  42750. static CustomRequestHeaders: {
  42751. [key: string]: string;
  42752. };
  42753. /**
  42754. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  42755. */
  42756. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  42757. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  42758. /**
  42759. * Default behaviour for cors in the application.
  42760. * It can be a string if the expected behavior is identical in the entire app.
  42761. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  42762. */
  42763. static get CorsBehavior(): string | ((url: string | string[]) => string);
  42764. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  42765. /**
  42766. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42767. * @ignorenaming
  42768. */
  42769. static get UseFallbackTexture(): boolean;
  42770. static set UseFallbackTexture(value: boolean);
  42771. /**
  42772. * Use this object to register external classes like custom textures or material
  42773. * to allow the laoders to instantiate them
  42774. */
  42775. static get RegisteredExternalClasses(): {
  42776. [key: string]: Object;
  42777. };
  42778. static set RegisteredExternalClasses(classes: {
  42779. [key: string]: Object;
  42780. });
  42781. /**
  42782. * Texture content used if a texture cannot loaded
  42783. * @ignorenaming
  42784. */
  42785. static get fallbackTexture(): string;
  42786. static set fallbackTexture(value: string);
  42787. /**
  42788. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  42789. * @param u defines the coordinate on X axis
  42790. * @param v defines the coordinate on Y axis
  42791. * @param width defines the width of the source data
  42792. * @param height defines the height of the source data
  42793. * @param pixels defines the source byte array
  42794. * @param color defines the output color
  42795. */
  42796. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  42797. /**
  42798. * Interpolates between a and b via alpha
  42799. * @param a The lower value (returned when alpha = 0)
  42800. * @param b The upper value (returned when alpha = 1)
  42801. * @param alpha The interpolation-factor
  42802. * @return The mixed value
  42803. */
  42804. static Mix(a: number, b: number, alpha: number): number;
  42805. /**
  42806. * Tries to instantiate a new object from a given class name
  42807. * @param className defines the class name to instantiate
  42808. * @returns the new object or null if the system was not able to do the instantiation
  42809. */
  42810. static Instantiate(className: string): any;
  42811. /**
  42812. * Provides a slice function that will work even on IE
  42813. * @param data defines the array to slice
  42814. * @param start defines the start of the data (optional)
  42815. * @param end defines the end of the data (optional)
  42816. * @returns the new sliced array
  42817. */
  42818. static Slice<T>(data: T, start?: number, end?: number): T;
  42819. /**
  42820. * Provides a slice function that will work even on IE
  42821. * The difference between this and Slice is that this will force-convert to array
  42822. * @param data defines the array to slice
  42823. * @param start defines the start of the data (optional)
  42824. * @param end defines the end of the data (optional)
  42825. * @returns the new sliced array
  42826. */
  42827. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  42828. /**
  42829. * Polyfill for setImmediate
  42830. * @param action defines the action to execute after the current execution block
  42831. */
  42832. static SetImmediate(action: () => void): void;
  42833. /**
  42834. * Function indicating if a number is an exponent of 2
  42835. * @param value defines the value to test
  42836. * @returns true if the value is an exponent of 2
  42837. */
  42838. static IsExponentOfTwo(value: number): boolean;
  42839. private static _tmpFloatArray;
  42840. /**
  42841. * Returns the nearest 32-bit single precision float representation of a Number
  42842. * @param value A Number. If the parameter is of a different type, it will get converted
  42843. * to a number or to NaN if it cannot be converted
  42844. * @returns number
  42845. */
  42846. static FloatRound(value: number): number;
  42847. /**
  42848. * Extracts the filename from a path
  42849. * @param path defines the path to use
  42850. * @returns the filename
  42851. */
  42852. static GetFilename(path: string): string;
  42853. /**
  42854. * Extracts the "folder" part of a path (everything before the filename).
  42855. * @param uri The URI to extract the info from
  42856. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  42857. * @returns The "folder" part of the path
  42858. */
  42859. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  42860. /**
  42861. * Extracts text content from a DOM element hierarchy
  42862. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  42863. */
  42864. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  42865. /**
  42866. * Convert an angle in radians to degrees
  42867. * @param angle defines the angle to convert
  42868. * @returns the angle in degrees
  42869. */
  42870. static ToDegrees(angle: number): number;
  42871. /**
  42872. * Convert an angle in degrees to radians
  42873. * @param angle defines the angle to convert
  42874. * @returns the angle in radians
  42875. */
  42876. static ToRadians(angle: number): number;
  42877. /**
  42878. * Returns an array if obj is not an array
  42879. * @param obj defines the object to evaluate as an array
  42880. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  42881. * @returns either obj directly if obj is an array or a new array containing obj
  42882. */
  42883. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  42884. /**
  42885. * Gets the pointer prefix to use
  42886. * @param engine defines the engine we are finding the prefix for
  42887. * @returns "pointer" if touch is enabled. Else returns "mouse"
  42888. */
  42889. static GetPointerPrefix(engine: Engine): string;
  42890. /**
  42891. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  42892. * @param url define the url we are trying
  42893. * @param element define the dom element where to configure the cors policy
  42894. */
  42895. static SetCorsBehavior(url: string | string[], element: {
  42896. crossOrigin: string | null;
  42897. }): void;
  42898. /**
  42899. * Removes unwanted characters from an url
  42900. * @param url defines the url to clean
  42901. * @returns the cleaned url
  42902. */
  42903. static CleanUrl(url: string): string;
  42904. /**
  42905. * Gets or sets a function used to pre-process url before using them to load assets
  42906. */
  42907. static get PreprocessUrl(): (url: string) => string;
  42908. static set PreprocessUrl(processor: (url: string) => string);
  42909. /**
  42910. * Loads an image as an HTMLImageElement.
  42911. * @param input url string, ArrayBuffer, or Blob to load
  42912. * @param onLoad callback called when the image successfully loads
  42913. * @param onError callback called when the image fails to load
  42914. * @param offlineProvider offline provider for caching
  42915. * @param mimeType optional mime type
  42916. * @returns the HTMLImageElement of the loaded image
  42917. */
  42918. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  42919. /**
  42920. * Loads a file from a url
  42921. * @param url url string, ArrayBuffer, or Blob to load
  42922. * @param onSuccess callback called when the file successfully loads
  42923. * @param onProgress callback called while file is loading (if the server supports this mode)
  42924. * @param offlineProvider defines the offline provider for caching
  42925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42926. * @param onError callback called when the file fails to load
  42927. * @returns a file request object
  42928. */
  42929. 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;
  42930. /**
  42931. * Loads a file from a url
  42932. * @param url the file url to load
  42933. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  42934. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  42935. */
  42936. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  42937. /**
  42938. * Load a script (identified by an url). When the url returns, the
  42939. * content of this file is added into a new script element, attached to the DOM (body element)
  42940. * @param scriptUrl defines the url of the script to laod
  42941. * @param onSuccess defines the callback called when the script is loaded
  42942. * @param onError defines the callback to call if an error occurs
  42943. * @param scriptId defines the id of the script element
  42944. */
  42945. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  42946. /**
  42947. * Load an asynchronous script (identified by an url). When the url returns, the
  42948. * content of this file is added into a new script element, attached to the DOM (body element)
  42949. * @param scriptUrl defines the url of the script to laod
  42950. * @param scriptId defines the id of the script element
  42951. * @returns a promise request object
  42952. */
  42953. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  42954. /**
  42955. * Loads a file from a blob
  42956. * @param fileToLoad defines the blob to use
  42957. * @param callback defines the callback to call when data is loaded
  42958. * @param progressCallback defines the callback to call during loading process
  42959. * @returns a file request object
  42960. */
  42961. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  42962. /**
  42963. * Reads a file from a File object
  42964. * @param file defines the file to load
  42965. * @param onSuccess defines the callback to call when data is loaded
  42966. * @param onProgress defines the callback to call during loading process
  42967. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  42968. * @param onError defines the callback to call when an error occurs
  42969. * @returns a file request object
  42970. */
  42971. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42972. /**
  42973. * Creates a data url from a given string content
  42974. * @param content defines the content to convert
  42975. * @returns the new data url link
  42976. */
  42977. static FileAsURL(content: string): string;
  42978. /**
  42979. * Format the given number to a specific decimal format
  42980. * @param value defines the number to format
  42981. * @param decimals defines the number of decimals to use
  42982. * @returns the formatted string
  42983. */
  42984. static Format(value: number, decimals?: number): string;
  42985. /**
  42986. * Tries to copy an object by duplicating every property
  42987. * @param source defines the source object
  42988. * @param destination defines the target object
  42989. * @param doNotCopyList defines a list of properties to avoid
  42990. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  42991. */
  42992. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  42993. /**
  42994. * Gets a boolean indicating if the given object has no own property
  42995. * @param obj defines the object to test
  42996. * @returns true if object has no own property
  42997. */
  42998. static IsEmpty(obj: any): boolean;
  42999. /**
  43000. * Function used to register events at window level
  43001. * @param windowElement defines the Window object to use
  43002. * @param events defines the events to register
  43003. */
  43004. static RegisterTopRootEvents(windowElement: Window, events: {
  43005. name: string;
  43006. handler: Nullable<(e: FocusEvent) => any>;
  43007. }[]): void;
  43008. /**
  43009. * Function used to unregister events from window level
  43010. * @param windowElement defines the Window object to use
  43011. * @param events defines the events to unregister
  43012. */
  43013. static UnregisterTopRootEvents(windowElement: Window, events: {
  43014. name: string;
  43015. handler: Nullable<(e: FocusEvent) => any>;
  43016. }[]): void;
  43017. /**
  43018. * @ignore
  43019. */
  43020. static _ScreenshotCanvas: HTMLCanvasElement;
  43021. /**
  43022. * Dumps the current bound framebuffer
  43023. * @param width defines the rendering width
  43024. * @param height defines the rendering height
  43025. * @param engine defines the hosting engine
  43026. * @param successCallback defines the callback triggered once the data are available
  43027. * @param mimeType defines the mime type of the result
  43028. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43029. * @return a void promise
  43030. */
  43031. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): Promise<void>;
  43032. /**
  43033. * Dumps an array buffer
  43034. * @param width defines the rendering width
  43035. * @param height defines the rendering height
  43036. * @param data the data array
  43037. * @param successCallback defines the callback triggered once the data are available
  43038. * @param mimeType defines the mime type of the result
  43039. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43040. * @param invertY true to invert the picture in the Y dimension
  43041. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43042. */
  43043. static DumpData(width: number, height: number, data: ArrayBufferView, successCallback?: (data: string | ArrayBuffer) => void, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): void;
  43044. /**
  43045. * Dumps an array buffer
  43046. * @param width defines the rendering width
  43047. * @param height defines the rendering height
  43048. * @param data the data array
  43049. * @param successCallback defines the callback triggered once the data are available
  43050. * @param mimeType defines the mime type of the result
  43051. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43052. * @param invertY true to invert the picture in the Y dimension
  43053. * @param toArrayBuffer true to convert the data to an ArrayBuffer (encoded as `mimeType`) instead of a base64 string
  43054. * @return a promise that resolve to the final data
  43055. */
  43056. static DumpDataAsync(width: number, height: number, data: ArrayBufferView, mimeType?: string, fileName?: string, invertY?: boolean, toArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  43057. /**
  43058. * Converts the canvas data to blob.
  43059. * This acts as a polyfill for browsers not supporting the to blob function.
  43060. * @param canvas Defines the canvas to extract the data from
  43061. * @param successCallback Defines the callback triggered once the data are available
  43062. * @param mimeType Defines the mime type of the result
  43063. */
  43064. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43065. /**
  43066. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43067. * @param successCallback defines the callback triggered once the data are available
  43068. * @param mimeType defines the mime type of the result
  43069. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43070. * @param canvas canvas to get the data from. If not provided, use the default screenshot canvas
  43071. */
  43072. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string, canvas?: HTMLCanvasElement): void;
  43073. /**
  43074. * Downloads a blob in the browser
  43075. * @param blob defines the blob to download
  43076. * @param fileName defines the name of the downloaded file
  43077. */
  43078. static Download(blob: Blob, fileName: string): void;
  43079. /**
  43080. * Will return the right value of the noPreventDefault variable
  43081. * Needed to keep backwards compatibility to the old API.
  43082. *
  43083. * @param args arguments passed to the attachControl function
  43084. * @returns the correct value for noPreventDefault
  43085. */
  43086. static BackCompatCameraNoPreventDefault(args: IArguments): boolean;
  43087. /**
  43088. * Captures a screenshot of the current rendering
  43089. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43090. * @param engine defines the rendering engine
  43091. * @param camera defines the source camera
  43092. * @param size This parameter can be set to a single number or to an object with the
  43093. * following (optional) properties: precision, width, height. If a single number is passed,
  43094. * it will be used for both width and height. If an object is passed, the screenshot size
  43095. * will be derived from the parameters. The precision property is a multiplier allowing
  43096. * rendering at a higher or lower resolution
  43097. * @param successCallback defines the callback receives a single parameter which contains the
  43098. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43099. * src parameter of an <img> to display it
  43100. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43101. * Check your browser for supported MIME types
  43102. */
  43103. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43104. /**
  43105. * Captures a screenshot of the current rendering
  43106. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43107. * @param engine defines the rendering engine
  43108. * @param camera defines the source camera
  43109. * @param size This parameter can be set to a single number or to an object with the
  43110. * following (optional) properties: precision, width, height. If a single number is passed,
  43111. * it will be used for both width and height. If an object is passed, the screenshot size
  43112. * will be derived from the parameters. The precision property is a multiplier allowing
  43113. * rendering at a higher or lower resolution
  43114. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43115. * Check your browser for supported MIME types
  43116. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43117. * to the src parameter of an <img> to display it
  43118. */
  43119. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43120. /**
  43121. * Generates an image screenshot from the specified camera.
  43122. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43123. * @param engine The engine to use for rendering
  43124. * @param camera The camera to use for rendering
  43125. * @param size This parameter can be set to a single number or to an object with the
  43126. * following (optional) properties: precision, width, height. If a single number is passed,
  43127. * it will be used for both width and height. If an object is passed, the screenshot size
  43128. * will be derived from the parameters. The precision property is a multiplier allowing
  43129. * rendering at a higher or lower resolution
  43130. * @param successCallback The callback receives a single parameter which contains the
  43131. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43132. * src parameter of an <img> to display it
  43133. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43134. * Check your browser for supported MIME types
  43135. * @param samples Texture samples (default: 1)
  43136. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43137. * @param fileName A name for for the downloaded file.
  43138. */
  43139. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43140. /**
  43141. * Generates an image screenshot from the specified camera.
  43142. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43143. * @param engine The engine to use for rendering
  43144. * @param camera The camera to use for rendering
  43145. * @param size This parameter can be set to a single number or to an object with the
  43146. * following (optional) properties: precision, width, height. If a single number is passed,
  43147. * it will be used for both width and height. If an object is passed, the screenshot size
  43148. * will be derived from the parameters. The precision property is a multiplier allowing
  43149. * rendering at a higher or lower resolution
  43150. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43151. * Check your browser for supported MIME types
  43152. * @param samples Texture samples (default: 1)
  43153. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43154. * @param fileName A name for for the downloaded file.
  43155. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43156. * to the src parameter of an <img> to display it
  43157. */
  43158. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43159. /**
  43160. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43161. * Be aware Math.random() could cause collisions, but:
  43162. * "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"
  43163. * @returns a pseudo random id
  43164. */
  43165. static RandomId(): string;
  43166. /**
  43167. * Test if the given uri is a base64 string
  43168. * @param uri The uri to test
  43169. * @return True if the uri is a base64 string or false otherwise
  43170. */
  43171. static IsBase64(uri: string): boolean;
  43172. /**
  43173. * Decode the given base64 uri.
  43174. * @param uri The uri to decode
  43175. * @return The decoded base64 data.
  43176. */
  43177. static DecodeBase64(uri: string): ArrayBuffer;
  43178. /**
  43179. * Gets the absolute url.
  43180. * @param url the input url
  43181. * @return the absolute url
  43182. */
  43183. static GetAbsoluteUrl(url: string): string;
  43184. /**
  43185. * No log
  43186. */
  43187. static readonly NoneLogLevel: number;
  43188. /**
  43189. * Only message logs
  43190. */
  43191. static readonly MessageLogLevel: number;
  43192. /**
  43193. * Only warning logs
  43194. */
  43195. static readonly WarningLogLevel: number;
  43196. /**
  43197. * Only error logs
  43198. */
  43199. static readonly ErrorLogLevel: number;
  43200. /**
  43201. * All logs
  43202. */
  43203. static readonly AllLogLevel: number;
  43204. /**
  43205. * Gets a value indicating the number of loading errors
  43206. * @ignorenaming
  43207. */
  43208. static get errorsCount(): number;
  43209. /**
  43210. * Callback called when a new log is added
  43211. */
  43212. static OnNewCacheEntry: (entry: string) => void;
  43213. /**
  43214. * Log a message to the console
  43215. * @param message defines the message to log
  43216. */
  43217. static Log(message: string): void;
  43218. /**
  43219. * Write a warning message to the console
  43220. * @param message defines the message to log
  43221. */
  43222. static Warn(message: string): void;
  43223. /**
  43224. * Write an error message to the console
  43225. * @param message defines the message to log
  43226. */
  43227. static Error(message: string): void;
  43228. /**
  43229. * Gets current log cache (list of logs)
  43230. */
  43231. static get LogCache(): string;
  43232. /**
  43233. * Clears the log cache
  43234. */
  43235. static ClearLogCache(): void;
  43236. /**
  43237. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43238. */
  43239. static set LogLevels(level: number);
  43240. /**
  43241. * Checks if the window object exists
  43242. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43243. */
  43244. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43245. /**
  43246. * No performance log
  43247. */
  43248. static readonly PerformanceNoneLogLevel: number;
  43249. /**
  43250. * Use user marks to log performance
  43251. */
  43252. static readonly PerformanceUserMarkLogLevel: number;
  43253. /**
  43254. * Log performance to the console
  43255. */
  43256. static readonly PerformanceConsoleLogLevel: number;
  43257. private static _performance;
  43258. /**
  43259. * Sets the current performance log level
  43260. */
  43261. static set PerformanceLogLevel(level: number);
  43262. private static _StartPerformanceCounterDisabled;
  43263. private static _EndPerformanceCounterDisabled;
  43264. private static _StartUserMark;
  43265. private static _EndUserMark;
  43266. private static _StartPerformanceConsole;
  43267. private static _EndPerformanceConsole;
  43268. /**
  43269. * Starts a performance counter
  43270. */
  43271. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43272. /**
  43273. * Ends a specific performance coutner
  43274. */
  43275. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43276. /**
  43277. * Gets either window.performance.now() if supported or Date.now() else
  43278. */
  43279. static get Now(): number;
  43280. /**
  43281. * This method will return the name of the class used to create the instance of the given object.
  43282. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43283. * @param object the object to get the class name from
  43284. * @param isType defines if the object is actually a type
  43285. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43286. */
  43287. static GetClassName(object: any, isType?: boolean): string;
  43288. /**
  43289. * Gets the first element of an array satisfying a given predicate
  43290. * @param array defines the array to browse
  43291. * @param predicate defines the predicate to use
  43292. * @returns null if not found or the element
  43293. */
  43294. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43295. /**
  43296. * This method will return the name of the full name of the class, including its owning module (if any).
  43297. * 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).
  43298. * @param object the object to get the class name from
  43299. * @param isType defines if the object is actually a type
  43300. * @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.
  43301. * @ignorenaming
  43302. */
  43303. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43304. /**
  43305. * Returns a promise that resolves after the given amount of time.
  43306. * @param delay Number of milliseconds to delay
  43307. * @returns Promise that resolves after the given amount of time
  43308. */
  43309. static DelayAsync(delay: number): Promise<void>;
  43310. /**
  43311. * Utility function to detect if the current user agent is Safari
  43312. * @returns whether or not the current user agent is safari
  43313. */
  43314. static IsSafari(): boolean;
  43315. }
  43316. /**
  43317. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43318. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43319. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43320. * @param name The name of the class, case should be preserved
  43321. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43322. */
  43323. export function className(name: string, module?: string): (target: Object) => void;
  43324. /**
  43325. * An implementation of a loop for asynchronous functions.
  43326. */
  43327. export class AsyncLoop {
  43328. /**
  43329. * Defines the number of iterations for the loop
  43330. */
  43331. iterations: number;
  43332. /**
  43333. * Defines the current index of the loop.
  43334. */
  43335. index: number;
  43336. private _done;
  43337. private _fn;
  43338. private _successCallback;
  43339. /**
  43340. * Constructor.
  43341. * @param iterations the number of iterations.
  43342. * @param func the function to run each iteration
  43343. * @param successCallback the callback that will be called upon succesful execution
  43344. * @param offset starting offset.
  43345. */
  43346. constructor(
  43347. /**
  43348. * Defines the number of iterations for the loop
  43349. */
  43350. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43351. /**
  43352. * Execute the next iteration. Must be called after the last iteration was finished.
  43353. */
  43354. executeNext(): void;
  43355. /**
  43356. * Break the loop and run the success callback.
  43357. */
  43358. breakLoop(): void;
  43359. /**
  43360. * Create and run an async loop.
  43361. * @param iterations the number of iterations.
  43362. * @param fn the function to run each iteration
  43363. * @param successCallback the callback that will be called upon succesful execution
  43364. * @param offset starting offset.
  43365. * @returns the created async loop object
  43366. */
  43367. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43368. /**
  43369. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43370. * @param iterations total number of iterations
  43371. * @param syncedIterations number of synchronous iterations in each async iteration.
  43372. * @param fn the function to call each iteration.
  43373. * @param callback a success call back that will be called when iterating stops.
  43374. * @param breakFunction a break condition (optional)
  43375. * @param timeout timeout settings for the setTimeout function. default - 0.
  43376. * @returns the created async loop object
  43377. */
  43378. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43379. }
  43380. }
  43381. declare module BABYLON {
  43382. /**
  43383. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43384. * The underlying implementation relies on an associative array to ensure the best performances.
  43385. * The value can be anything including 'null' but except 'undefined'
  43386. */
  43387. export class StringDictionary<T> {
  43388. /**
  43389. * This will clear this dictionary and copy the content from the 'source' one.
  43390. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43391. * @param source the dictionary to take the content from and copy to this dictionary
  43392. */
  43393. copyFrom(source: StringDictionary<T>): void;
  43394. /**
  43395. * Get a value based from its key
  43396. * @param key the given key to get the matching value from
  43397. * @return the value if found, otherwise undefined is returned
  43398. */
  43399. get(key: string): T | undefined;
  43400. /**
  43401. * Get a value from its key or add it if it doesn't exist.
  43402. * This method will ensure you that a given key/data will be present in the dictionary.
  43403. * @param key the given key to get the matching value from
  43404. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43405. * The factory will only be invoked if there's no data for the given key.
  43406. * @return the value corresponding to the key.
  43407. */
  43408. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43409. /**
  43410. * Get a value from its key if present in the dictionary otherwise add it
  43411. * @param key the key to get the value from
  43412. * @param val if there's no such key/value pair in the dictionary add it with this value
  43413. * @return the value corresponding to the key
  43414. */
  43415. getOrAdd(key: string, val: T): T;
  43416. /**
  43417. * Check if there's a given key in the dictionary
  43418. * @param key the key to check for
  43419. * @return true if the key is present, false otherwise
  43420. */
  43421. contains(key: string): boolean;
  43422. /**
  43423. * Add a new key and its corresponding value
  43424. * @param key the key to add
  43425. * @param value the value corresponding to the key
  43426. * @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
  43427. */
  43428. add(key: string, value: T): boolean;
  43429. /**
  43430. * Update a specific value associated to a key
  43431. * @param key defines the key to use
  43432. * @param value defines the value to store
  43433. * @returns true if the value was updated (or false if the key was not found)
  43434. */
  43435. set(key: string, value: T): boolean;
  43436. /**
  43437. * Get the element of the given key and remove it from the dictionary
  43438. * @param key defines the key to search
  43439. * @returns the value associated with the key or null if not found
  43440. */
  43441. getAndRemove(key: string): Nullable<T>;
  43442. /**
  43443. * Remove a key/value from the dictionary.
  43444. * @param key the key to remove
  43445. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43446. */
  43447. remove(key: string): boolean;
  43448. /**
  43449. * Clear the whole content of the dictionary
  43450. */
  43451. clear(): void;
  43452. /**
  43453. * Gets the current count
  43454. */
  43455. get count(): number;
  43456. /**
  43457. * Execute a callback on each key/val of the dictionary.
  43458. * Note that you can remove any element in this dictionary in the callback implementation
  43459. * @param callback the callback to execute on a given key/value pair
  43460. */
  43461. forEach(callback: (key: string, val: T) => void): void;
  43462. /**
  43463. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43464. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43465. * Note that you can remove any element in this dictionary in the callback implementation
  43466. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43467. * @returns the first item
  43468. */
  43469. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43470. private _count;
  43471. private _data;
  43472. }
  43473. }
  43474. declare module BABYLON {
  43475. /** @hidden */
  43476. export interface ICollisionCoordinator {
  43477. createCollider(): Collider;
  43478. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43479. init(scene: Scene): void;
  43480. }
  43481. /** @hidden */
  43482. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43483. private _scene;
  43484. private _scaledPosition;
  43485. private _scaledVelocity;
  43486. private _finalPosition;
  43487. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43488. createCollider(): Collider;
  43489. init(scene: Scene): void;
  43490. private _collideWithWorld;
  43491. }
  43492. }
  43493. declare module BABYLON {
  43494. /**
  43495. * Class used to manage all inputs for the scene.
  43496. */
  43497. export class InputManager {
  43498. /** The distance in pixel that you have to move to prevent some events */
  43499. static DragMovementThreshold: number;
  43500. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43501. static LongPressDelay: number;
  43502. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43503. static DoubleClickDelay: number;
  43504. /** If you need to check double click without raising a single click at first click, enable this flag */
  43505. static ExclusiveDoubleClickMode: boolean;
  43506. /** 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. */
  43507. private _alreadyAttached;
  43508. private _alreadyAttachedTo;
  43509. private _wheelEventName;
  43510. private _onPointerMove;
  43511. private _onPointerDown;
  43512. private _onPointerUp;
  43513. private _initClickEvent;
  43514. private _initActionManager;
  43515. private _delayedSimpleClick;
  43516. private _delayedSimpleClickTimeout;
  43517. private _previousDelayedSimpleClickTimeout;
  43518. private _meshPickProceed;
  43519. private _previousButtonPressed;
  43520. private _currentPickResult;
  43521. private _previousPickResult;
  43522. private _totalPointersPressed;
  43523. private _doubleClickOccured;
  43524. private _pointerOverMesh;
  43525. private _pickedDownMesh;
  43526. private _pickedUpMesh;
  43527. private _pointerX;
  43528. private _pointerY;
  43529. private _unTranslatedPointerX;
  43530. private _unTranslatedPointerY;
  43531. private _startingPointerPosition;
  43532. private _previousStartingPointerPosition;
  43533. private _startingPointerTime;
  43534. private _previousStartingPointerTime;
  43535. private _pointerCaptures;
  43536. private _meshUnderPointerId;
  43537. private _onKeyDown;
  43538. private _onKeyUp;
  43539. private _keyboardIsAttached;
  43540. private _onCanvasFocusObserver;
  43541. private _onCanvasBlurObserver;
  43542. private _scene;
  43543. /**
  43544. * Creates a new InputManager
  43545. * @param scene defines the hosting scene
  43546. */
  43547. constructor(scene: Scene);
  43548. /**
  43549. * Gets the mesh that is currently under the pointer
  43550. */
  43551. get meshUnderPointer(): Nullable<AbstractMesh>;
  43552. /**
  43553. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43554. * @param pointerId the pointer id to use
  43555. * @returns The mesh under this pointer id or null if not found
  43556. */
  43557. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43558. /**
  43559. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43560. */
  43561. get unTranslatedPointer(): Vector2;
  43562. /**
  43563. * Gets or sets the current on-screen X position of the pointer
  43564. */
  43565. get pointerX(): number;
  43566. set pointerX(value: number);
  43567. /**
  43568. * Gets or sets the current on-screen Y position of the pointer
  43569. */
  43570. get pointerY(): number;
  43571. set pointerY(value: number);
  43572. private _updatePointerPosition;
  43573. private _processPointerMove;
  43574. private _setRayOnPointerInfo;
  43575. private _checkPrePointerObservable;
  43576. /**
  43577. * Use this method to simulate a pointer move on a mesh
  43578. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43579. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43580. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43581. */
  43582. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43583. /**
  43584. * Use this method to simulate a pointer down on a mesh
  43585. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43586. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43587. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43588. */
  43589. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43590. private _processPointerDown;
  43591. /** @hidden */
  43592. _isPointerSwiping(): boolean;
  43593. /**
  43594. * Use this method to simulate a pointer up on a mesh
  43595. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43596. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43597. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43598. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43599. */
  43600. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43601. private _processPointerUp;
  43602. /**
  43603. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43604. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43605. * @returns true if the pointer was captured
  43606. */
  43607. isPointerCaptured(pointerId?: number): boolean;
  43608. /**
  43609. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43610. * @param attachUp defines if you want to attach events to pointerup
  43611. * @param attachDown defines if you want to attach events to pointerdown
  43612. * @param attachMove defines if you want to attach events to pointermove
  43613. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43614. */
  43615. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43616. /**
  43617. * Detaches all event handlers
  43618. */
  43619. detachControl(): void;
  43620. /**
  43621. * Force the value of meshUnderPointer
  43622. * @param mesh defines the mesh to use
  43623. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43624. */
  43625. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43626. /**
  43627. * Gets the mesh under the pointer
  43628. * @returns a Mesh or null if no mesh is under the pointer
  43629. */
  43630. getPointerOverMesh(): Nullable<AbstractMesh>;
  43631. }
  43632. }
  43633. declare module BABYLON {
  43634. /**
  43635. * This class defines the direct association between an animation and a target
  43636. */
  43637. export class TargetedAnimation {
  43638. /**
  43639. * Animation to perform
  43640. */
  43641. animation: Animation;
  43642. /**
  43643. * Target to animate
  43644. */
  43645. target: any;
  43646. /**
  43647. * Returns the string "TargetedAnimation"
  43648. * @returns "TargetedAnimation"
  43649. */
  43650. getClassName(): string;
  43651. /**
  43652. * Serialize the object
  43653. * @returns the JSON object representing the current entity
  43654. */
  43655. serialize(): any;
  43656. }
  43657. /**
  43658. * Use this class to create coordinated animations on multiple targets
  43659. */
  43660. export class AnimationGroup implements IDisposable {
  43661. /** The name of the animation group */
  43662. name: string;
  43663. private _scene;
  43664. private _targetedAnimations;
  43665. private _animatables;
  43666. private _from;
  43667. private _to;
  43668. private _isStarted;
  43669. private _isPaused;
  43670. private _speedRatio;
  43671. private _loopAnimation;
  43672. private _isAdditive;
  43673. /**
  43674. * Gets or sets the unique id of the node
  43675. */
  43676. uniqueId: number;
  43677. /**
  43678. * This observable will notify when one animation have ended
  43679. */
  43680. onAnimationEndObservable: Observable<TargetedAnimation>;
  43681. /**
  43682. * Observer raised when one animation loops
  43683. */
  43684. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43685. /**
  43686. * Observer raised when all animations have looped
  43687. */
  43688. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43689. /**
  43690. * This observable will notify when all animations have ended.
  43691. */
  43692. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43693. /**
  43694. * This observable will notify when all animations have paused.
  43695. */
  43696. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43697. /**
  43698. * This observable will notify when all animations are playing.
  43699. */
  43700. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  43701. /**
  43702. * Gets the first frame
  43703. */
  43704. get from(): number;
  43705. /**
  43706. * Gets the last frame
  43707. */
  43708. get to(): number;
  43709. /**
  43710. * Define if the animations are started
  43711. */
  43712. get isStarted(): boolean;
  43713. /**
  43714. * Gets a value indicating that the current group is playing
  43715. */
  43716. get isPlaying(): boolean;
  43717. /**
  43718. * Gets or sets the speed ratio to use for all animations
  43719. */
  43720. get speedRatio(): number;
  43721. /**
  43722. * Gets or sets the speed ratio to use for all animations
  43723. */
  43724. set speedRatio(value: number);
  43725. /**
  43726. * Gets or sets if all animations should loop or not
  43727. */
  43728. get loopAnimation(): boolean;
  43729. set loopAnimation(value: boolean);
  43730. /**
  43731. * Gets or sets if all animations should be evaluated additively
  43732. */
  43733. get isAdditive(): boolean;
  43734. set isAdditive(value: boolean);
  43735. /**
  43736. * Gets the targeted animations for this animation group
  43737. */
  43738. get targetedAnimations(): Array<TargetedAnimation>;
  43739. /**
  43740. * returning the list of animatables controlled by this animation group.
  43741. */
  43742. get animatables(): Array<Animatable>;
  43743. /**
  43744. * Gets the list of target animations
  43745. */
  43746. get children(): TargetedAnimation[];
  43747. /**
  43748. * Instantiates a new Animation Group.
  43749. * This helps managing several animations at once.
  43750. * @see https://doc.babylonjs.com/how_to/group
  43751. * @param name Defines the name of the group
  43752. * @param scene Defines the scene the group belongs to
  43753. */
  43754. constructor(
  43755. /** The name of the animation group */
  43756. name: string, scene?: Nullable<Scene>);
  43757. /**
  43758. * Add an animation (with its target) in the group
  43759. * @param animation defines the animation we want to add
  43760. * @param target defines the target of the animation
  43761. * @returns the TargetedAnimation object
  43762. */
  43763. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  43764. /**
  43765. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  43766. * It can add constant keys at begin or end
  43767. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  43768. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  43769. * @returns the animation group
  43770. */
  43771. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  43772. private _animationLoopCount;
  43773. private _animationLoopFlags;
  43774. private _processLoop;
  43775. /**
  43776. * Start all animations on given targets
  43777. * @param loop defines if animations must loop
  43778. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  43779. * @param from defines the from key (optional)
  43780. * @param to defines the to key (optional)
  43781. * @param isAdditive defines the additive state for the resulting animatables (optional)
  43782. * @returns the current animation group
  43783. */
  43784. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  43785. /**
  43786. * Pause all animations
  43787. * @returns the animation group
  43788. */
  43789. pause(): AnimationGroup;
  43790. /**
  43791. * Play all animations to initial state
  43792. * This function will start() the animations if they were not started or will restart() them if they were paused
  43793. * @param loop defines if animations must loop
  43794. * @returns the animation group
  43795. */
  43796. play(loop?: boolean): AnimationGroup;
  43797. /**
  43798. * Reset all animations to initial state
  43799. * @returns the animation group
  43800. */
  43801. reset(): AnimationGroup;
  43802. /**
  43803. * Restart animations from key 0
  43804. * @returns the animation group
  43805. */
  43806. restart(): AnimationGroup;
  43807. /**
  43808. * Stop all animations
  43809. * @returns the animation group
  43810. */
  43811. stop(): AnimationGroup;
  43812. /**
  43813. * Set animation weight for all animatables
  43814. * @param weight defines the weight to use
  43815. * @return the animationGroup
  43816. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43817. */
  43818. setWeightForAllAnimatables(weight: number): AnimationGroup;
  43819. /**
  43820. * Synchronize and normalize all animatables with a source animatable
  43821. * @param root defines the root animatable to synchronize with
  43822. * @return the animationGroup
  43823. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  43824. */
  43825. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  43826. /**
  43827. * Goes to a specific frame in this animation group
  43828. * @param frame the frame number to go to
  43829. * @return the animationGroup
  43830. */
  43831. goToFrame(frame: number): AnimationGroup;
  43832. /**
  43833. * Dispose all associated resources
  43834. */
  43835. dispose(): void;
  43836. private _checkAnimationGroupEnded;
  43837. /**
  43838. * Clone the current animation group and returns a copy
  43839. * @param newName defines the name of the new group
  43840. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  43841. * @returns the new aniamtion group
  43842. */
  43843. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  43844. /**
  43845. * Serializes the animationGroup to an object
  43846. * @returns Serialized object
  43847. */
  43848. serialize(): any;
  43849. /**
  43850. * Returns a new AnimationGroup object parsed from the source provided.
  43851. * @param parsedAnimationGroup defines the source
  43852. * @param scene defines the scene that will receive the animationGroup
  43853. * @returns a new AnimationGroup
  43854. */
  43855. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  43856. /**
  43857. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  43858. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  43859. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  43860. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  43861. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  43862. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  43863. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  43864. */
  43865. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  43866. /**
  43867. * Returns the string "AnimationGroup"
  43868. * @returns "AnimationGroup"
  43869. */
  43870. getClassName(): string;
  43871. /**
  43872. * Creates a detailled string about the object
  43873. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  43874. * @returns a string representing the object
  43875. */
  43876. toString(fullDetails?: boolean): string;
  43877. }
  43878. }
  43879. declare module BABYLON {
  43880. /**
  43881. * @hidden
  43882. **/
  43883. export class _TimeToken {
  43884. _startTimeQuery: Nullable<WebGLQuery>;
  43885. _endTimeQuery: Nullable<WebGLQuery>;
  43886. _timeElapsedQuery: Nullable<WebGLQuery>;
  43887. _timeElapsedQueryEnded: boolean;
  43888. }
  43889. }
  43890. declare module BABYLON {
  43891. /** @hidden */
  43892. export enum ExtensionName {
  43893. DepthClamping = "depth-clamping",
  43894. Depth24UnormStencil8 = "depth24unorm-stencil8",
  43895. Depth32FloatStencil8 = "depth32float-stencil8",
  43896. PipelineStatisticsQuery = "pipeline-statistics-query",
  43897. TextureCompressionBC = "texture-compression-bc",
  43898. TimestampQuery = "timestamp-query"
  43899. }
  43900. /** @hidden */
  43901. export enum AddressMode {
  43902. ClampToEdge = "clamp-to-edge",
  43903. Repeat = "repeat",
  43904. MirrorRepeat = "mirror-repeat"
  43905. }
  43906. /** @hidden */
  43907. export enum BindingType {
  43908. UniformBuffer = "uniform-buffer",
  43909. StorageBuffer = "storage-buffer",
  43910. ReadonlyStorageBuffer = "readonly-storage-buffer",
  43911. Sampler = "sampler",
  43912. ComparisonSampler = "comparison-sampler",
  43913. SampledTexture = "sampled-texture",
  43914. ReadonlyStorageTexture = "readonly-storage-texture",
  43915. WriteonlyStorageTexture = "writeonly-storage-texture"
  43916. }
  43917. /** @hidden */
  43918. export enum BlendFactor {
  43919. Zero = "zero",
  43920. One = "one",
  43921. SrcColor = "src-color",
  43922. OneMinusSrcColor = "one-minus-src-color",
  43923. SrcAlpha = "src-alpha",
  43924. OneMinusSrcAlpha = "one-minus-src-alpha",
  43925. DstColor = "dst-color",
  43926. OneMinusDstColor = "one-minus-dst-color",
  43927. DstAlpha = "dst-alpha",
  43928. OneMinusDstAlpha = "one-minus-dst-alpha",
  43929. SrcAlphaSaturated = "src-alpha-saturated",
  43930. BlendColor = "blend-color",
  43931. OneMinusBlendColor = "one-minus-blend-color"
  43932. }
  43933. /** @hidden */
  43934. export enum BlendOperation {
  43935. Add = "add",
  43936. Subtract = "subtract",
  43937. ReverseSubtract = "reverse-subtract",
  43938. Min = "min",
  43939. Max = "max"
  43940. }
  43941. /** @hidden */
  43942. export enum CompareFunction {
  43943. Never = "never",
  43944. Less = "less",
  43945. Equal = "equal",
  43946. LessEqual = "less-equal",
  43947. Greater = "greater",
  43948. NotEqual = "not-equal",
  43949. GreaterEqual = "greater-equal",
  43950. Always = "always"
  43951. }
  43952. /** @hidden */
  43953. export enum CullMode {
  43954. None = "none",
  43955. Front = "front",
  43956. Back = "back"
  43957. }
  43958. /** @hidden */
  43959. export enum FilterMode {
  43960. Nearest = "nearest",
  43961. Linear = "linear"
  43962. }
  43963. /** @hidden */
  43964. export enum FrontFace {
  43965. CCW = "ccw",
  43966. CW = "cw"
  43967. }
  43968. /** @hidden */
  43969. export enum IndexFormat {
  43970. Uint16 = "uint16",
  43971. Uint32 = "uint32"
  43972. }
  43973. /** @hidden */
  43974. export enum InputStepMode {
  43975. Vertex = "vertex",
  43976. Instance = "instance"
  43977. }
  43978. /** @hidden */
  43979. export enum LoadOp {
  43980. Load = "load"
  43981. }
  43982. /** @hidden */
  43983. export enum PrimitiveTopology {
  43984. PointList = "point-list",
  43985. LineList = "line-list",
  43986. LineStrip = "line-strip",
  43987. TriangleList = "triangle-list",
  43988. TriangleStrip = "triangle-strip"
  43989. }
  43990. /** @hidden */
  43991. export enum StencilOperation {
  43992. Keep = "keep",
  43993. Zero = "zero",
  43994. Replace = "replace",
  43995. Invert = "invert",
  43996. IncrementClamp = "increment-clamp",
  43997. DecrementClamp = "decrement-clamp",
  43998. IncrementWrap = "increment-wrap",
  43999. DecrementWrap = "decrement-wrap"
  44000. }
  44001. /** @hidden */
  44002. export enum StoreOp {
  44003. Store = "store",
  44004. Clear = "clear"
  44005. }
  44006. /** @hidden */
  44007. export enum TextureDimension {
  44008. E1d = "1d",
  44009. E2d = "2d",
  44010. E3d = "3d"
  44011. }
  44012. /** @hidden */
  44013. export enum TextureFormat {
  44014. R8Unorm = "r8unorm",
  44015. R8Snorm = "r8snorm",
  44016. R8Uint = "r8uint",
  44017. R8Sint = "r8sint",
  44018. R16Uint = "r16uint",
  44019. R16Sint = "r16sint",
  44020. R16Float = "r16float",
  44021. RG8Unorm = "rg8unorm",
  44022. RG8Snorm = "rg8snorm",
  44023. RG8Uint = "rg8uint",
  44024. RG8Sint = "rg8sint",
  44025. R32Uint = "r32uint",
  44026. R32Sint = "r32sint",
  44027. R32Float = "r32float",
  44028. RG16Uint = "rg16uint",
  44029. RG16Sint = "rg16sint",
  44030. RG16Float = "rg16float",
  44031. RGBA8Unorm = "rgba8unorm",
  44032. RGBA8UnormSRGB = "rgba8unorm-srgb",
  44033. RGBA8Snorm = "rgba8snorm",
  44034. RGBA8Uint = "rgba8uint",
  44035. RGBA8Sint = "rgba8sint",
  44036. BGRA8Unorm = "bgra8unorm",
  44037. BGRA8UnormSRGB = "bgra8unorm-srgb",
  44038. RGB9E5UFloat = "rgb9e5ufloat",
  44039. RGB10A2Unorm = "rgb10a2unorm",
  44040. RG11B10UFloat = "rg11b10ufloat",
  44041. RG32Uint = "rg32uint",
  44042. RG32Sint = "rg32sint",
  44043. RG32Float = "rg32float",
  44044. RGBA16Uint = "rgba16uint",
  44045. RGBA16Sint = "rgba16sint",
  44046. RGBA16Float = "rgba16float",
  44047. RGBA32Uint = "rgba32uint",
  44048. RGBA32Sint = "rgba32sint",
  44049. RGBA32Float = "rgba32float",
  44050. Stencil8 = "stencil8",
  44051. Depth16Unorm = "depth16unorm",
  44052. Depth24Plus = "depth24plus",
  44053. Depth24PlusStencil8 = "depth24plus-stencil8",
  44054. Depth32Float = "depth32float",
  44055. BC1RGBAUNorm = "bc1-rgba-unorm",
  44056. BC1RGBAUnormSRGB = "bc1-rgba-unorm-srgb",
  44057. BC2RGBAUnorm = "bc2-rgba-unorm",
  44058. BC2RGBAUnormSRGB = "bc2-rgba-unorm-srgb",
  44059. BC3RGBAUnorm = "bc3-rgba-unorm",
  44060. BC3RGBAUnormSRGB = "bc3-rgba-unorm-srgb",
  44061. BC4RUnorm = "bc4-r-unorm",
  44062. BC4RSnorm = "bc4-r-snorm",
  44063. BC5RGUnorm = "bc5-rg-unorm",
  44064. BC5RGSnorm = "bc5-rg-snorm",
  44065. BC6HRGBUFloat = "bc6h-rgb-ufloat",
  44066. BC6HRGBFloat = "bc6h-rgb-float",
  44067. BC7RGBAUnorm = "bc7-rgba-unorm",
  44068. BC7RGBAUnormSRGB = "bc7-rgba-unorm-srgb",
  44069. Depth24UnormStencil8 = "depth24unorm-stencil8",
  44070. Depth32FloatStencil8 = "depth32float-stencil8"
  44071. }
  44072. /** @hidden */
  44073. export enum TextureComponentType {
  44074. Float = "float",
  44075. Sint = "sint",
  44076. Uint = "uint",
  44077. DepthComparison = "depth-comparison"
  44078. }
  44079. /** @hidden */
  44080. export enum TextureViewDimension {
  44081. E1d = "1d",
  44082. E2d = "2d",
  44083. E2dArray = "2d-array",
  44084. Cube = "cube",
  44085. CubeArray = "cube-array",
  44086. E3d = "3d"
  44087. }
  44088. /** @hidden */
  44089. export enum VertexFormat {
  44090. Uchar2 = "uchar2",
  44091. Uchar4 = "uchar4",
  44092. Char2 = "char2",
  44093. Char4 = "char4",
  44094. Uchar2Norm = "uchar2norm",
  44095. Uchar4Norm = "uchar4norm",
  44096. Char2Norm = "char2norm",
  44097. Char4Norm = "char4norm",
  44098. Ushort2 = "ushort2",
  44099. Ushort4 = "ushort4",
  44100. Short2 = "short2",
  44101. Short4 = "short4",
  44102. Ushort2Norm = "ushort2norm",
  44103. Ushort4Norm = "ushort4norm",
  44104. Short2Norm = "short2norm",
  44105. Short4Norm = "short4norm",
  44106. Half2 = "half2",
  44107. Half4 = "half4",
  44108. Float = "float",
  44109. Float2 = "float2",
  44110. Float3 = "float3",
  44111. Float4 = "float4",
  44112. Uint = "uint",
  44113. Uint2 = "uint2",
  44114. Uint3 = "uint3",
  44115. Uint4 = "uint4",
  44116. Int = "int",
  44117. Int2 = "int2",
  44118. Int3 = "int3",
  44119. Int4 = "int4"
  44120. }
  44121. /** @hidden */
  44122. export enum TextureAspect {
  44123. All = "all",
  44124. StencilOnly = "stencil-only",
  44125. DepthOnly = "depth-only"
  44126. }
  44127. /** @hidden */
  44128. export enum CompilationMessageType {
  44129. Error = "error",
  44130. Warning = "warning",
  44131. Info = "info"
  44132. }
  44133. /** @hidden */
  44134. export enum QueryType {
  44135. Occlusion = "occlusion"
  44136. }
  44137. /** @hidden */
  44138. export enum BufferUsage {
  44139. MapRead = 1,
  44140. MapWrite = 2,
  44141. CopySrc = 4,
  44142. CopyDst = 8,
  44143. Index = 16,
  44144. Vertex = 32,
  44145. Uniform = 64,
  44146. Storage = 128,
  44147. Indirect = 256,
  44148. QueryResolve = 512
  44149. }
  44150. /** @hidden */
  44151. export enum ColorWrite {
  44152. Red = 1,
  44153. Green = 2,
  44154. Blue = 4,
  44155. Alpha = 8,
  44156. All = 15
  44157. }
  44158. /** @hidden */
  44159. export enum ShaderStage {
  44160. Vertex = 1,
  44161. Fragment = 2,
  44162. Compute = 4
  44163. }
  44164. /** @hidden */
  44165. export enum TextureUsage {
  44166. CopySrc = 1,
  44167. CopyDst = 2,
  44168. Sampled = 4,
  44169. Storage = 8,
  44170. OutputAttachment = 16
  44171. }
  44172. /** @hidden */
  44173. export enum MapMode {
  44174. Read = 1,
  44175. Write = 2
  44176. }
  44177. }
  44178. declare module BABYLON {
  44179. /** @hidden */
  44180. export interface WebGPUBindingInfo {
  44181. setIndex: number;
  44182. bindingIndex: number;
  44183. }
  44184. /** @hidden */
  44185. export interface WebGPUTextureSamplerBindingDescription {
  44186. sampler: WebGPUBindingInfo;
  44187. isTextureArray: boolean;
  44188. textures: Array<WebGPUBindingInfo>;
  44189. }
  44190. /** @hidden
  44191. * If the binding is a UBO, isSampler=isTexture=false
  44192. */
  44193. export interface WebGPUBindingDescription {
  44194. name: string;
  44195. usedInVertex: boolean;
  44196. usedInFragment: boolean;
  44197. isSampler: boolean;
  44198. isComparisonSampler?: boolean;
  44199. isTexture: boolean;
  44200. componentType?: GPUTextureComponentType;
  44201. textureDimension?: GPUTextureViewDimension;
  44202. }
  44203. /**
  44204. * @hidden
  44205. */
  44206. export class WebGPUShaderProcessingContext implements ShaderProcessingContext {
  44207. uboNextBindingIndex: number;
  44208. freeSetIndex: number;
  44209. freeBindingIndex: number;
  44210. availableVaryings: {
  44211. [key: string]: number;
  44212. };
  44213. availableAttributes: {
  44214. [key: string]: number;
  44215. };
  44216. availableUBOs: {
  44217. [key: string]: {
  44218. setIndex: number;
  44219. bindingIndex: number;
  44220. };
  44221. };
  44222. availableSamplers: {
  44223. [key: string]: WebGPUTextureSamplerBindingDescription;
  44224. };
  44225. leftOverUniforms: {
  44226. name: string;
  44227. type: string;
  44228. length: number;
  44229. }[];
  44230. orderedAttributes: string[];
  44231. orderedUBOsAndSamplers: WebGPUBindingDescription[][];
  44232. private _attributeNextLocation;
  44233. private _varyingNextLocation;
  44234. constructor();
  44235. getAttributeNextLocation(dataType: string, arrayLength?: number): number;
  44236. getVaryingNextLocation(dataType: string, arrayLength?: number): number;
  44237. getNextFreeUBOBinding(): {
  44238. setIndex: number;
  44239. bindingIndex: number;
  44240. };
  44241. private _getNextFreeBinding;
  44242. }
  44243. }
  44244. declare module BABYLON {
  44245. /** @hidden */
  44246. export interface IWebGPUPipelineContextSamplerCache {
  44247. samplerBinding: number;
  44248. firstTextureName: string;
  44249. }
  44250. /** @hidden */
  44251. export interface IWebGPUPipelineContextTextureCache {
  44252. textureBinding: number;
  44253. texture: InternalTexture;
  44254. }
  44255. /** @hidden */
  44256. export interface IWebGPUPipelineContextVertexInputsCache {
  44257. indexBuffer: Nullable<GPUBuffer>;
  44258. indexOffset: number;
  44259. vertexStartSlot: number;
  44260. vertexBuffers: GPUBuffer[];
  44261. vertexOffsets: number[];
  44262. }
  44263. /** @hidden */
  44264. export interface IWebGPURenderPipelineStageDescriptor {
  44265. vertexStage: GPUProgrammableStageDescriptor;
  44266. fragmentStage?: GPUProgrammableStageDescriptor;
  44267. }
  44268. /** @hidden */
  44269. export class WebGPUPipelineContext implements IPipelineContext {
  44270. engine: WebGPUEngine;
  44271. shaderProcessingContext: WebGPUShaderProcessingContext;
  44272. leftOverUniformsByName: {
  44273. [name: string]: string;
  44274. };
  44275. sources: {
  44276. vertex: string;
  44277. fragment: string;
  44278. rawVertex: string;
  44279. rawFragment: string;
  44280. };
  44281. stages: Nullable<IWebGPURenderPipelineStageDescriptor>;
  44282. samplers: {
  44283. [name: string]: Nullable<IWebGPUPipelineContextSamplerCache>;
  44284. };
  44285. textures: {
  44286. [name: string]: Nullable<IWebGPUPipelineContextTextureCache>;
  44287. };
  44288. bindGroupLayouts: GPUBindGroupLayout[];
  44289. /**
  44290. * Stores the uniform buffer
  44291. */
  44292. uniformBuffer: Nullable<UniformBuffer>;
  44293. onCompiled?: () => void;
  44294. get isAsync(): boolean;
  44295. get isReady(): boolean;
  44296. /** @hidden */
  44297. _name: string;
  44298. constructor(shaderProcessingContext: WebGPUShaderProcessingContext, engine: WebGPUEngine);
  44299. _handlesSpectorRebuildCallback(onCompiled: (program: any) => void): void;
  44300. _fillEffectInformation(effect: Effect, uniformBuffersNames: {
  44301. [key: string]: number;
  44302. }, uniformsNames: string[], uniforms: {
  44303. [key: string]: Nullable<WebGLUniformLocation>;
  44304. }, samplerList: string[], samplers: {
  44305. [key: string]: number;
  44306. }, attributesNames: string[], attributes: number[]): void;
  44307. /** @hidden */
  44308. /**
  44309. * Build the uniform buffer used in the material.
  44310. */
  44311. buildUniformLayout(): void;
  44312. /**
  44313. * Release all associated resources.
  44314. **/
  44315. dispose(): void;
  44316. /**
  44317. * Sets an integer value on a uniform variable.
  44318. * @param uniformName Name of the variable.
  44319. * @param value Value to be set.
  44320. */
  44321. setInt(uniformName: string, value: number): void;
  44322. /**
  44323. * Sets an int2 value on a uniform variable.
  44324. * @param uniformName Name of the variable.
  44325. * @param x First int in int2.
  44326. * @param y Second int in int2.
  44327. */
  44328. setInt2(uniformName: string, x: number, y: number): void;
  44329. /**
  44330. * Sets an int3 value on a uniform variable.
  44331. * @param uniformName Name of the variable.
  44332. * @param x First int in int3.
  44333. * @param y Second int in int3.
  44334. * @param z Third int in int3.
  44335. */
  44336. setInt3(uniformName: string, x: number, y: number, z: number): void;
  44337. /**
  44338. * Sets an int4 value on a uniform variable.
  44339. * @param uniformName Name of the variable.
  44340. * @param x First int in int4.
  44341. * @param y Second int in int4.
  44342. * @param z Third int in int4.
  44343. * @param w Fourth int in int4.
  44344. */
  44345. setInt4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44346. /**
  44347. * Sets an int array on a uniform variable.
  44348. * @param uniformName Name of the variable.
  44349. * @param array array to be set.
  44350. */
  44351. setIntArray(uniformName: string, array: Int32Array): void;
  44352. /**
  44353. * 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)
  44354. * @param uniformName Name of the variable.
  44355. * @param array array to be set.
  44356. */
  44357. setIntArray2(uniformName: string, array: Int32Array): void;
  44358. /**
  44359. * 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)
  44360. * @param uniformName Name of the variable.
  44361. * @param array array to be set.
  44362. */
  44363. setIntArray3(uniformName: string, array: Int32Array): void;
  44364. /**
  44365. * 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)
  44366. * @param uniformName Name of the variable.
  44367. * @param array array to be set.
  44368. */
  44369. setIntArray4(uniformName: string, array: Int32Array): void;
  44370. /**
  44371. * Sets an array on a uniform variable.
  44372. * @param uniformName Name of the variable.
  44373. * @param array array to be set.
  44374. */
  44375. setArray(uniformName: string, array: number[]): void;
  44376. /**
  44377. * 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)
  44378. * @param uniformName Name of the variable.
  44379. * @param array array to be set.
  44380. */
  44381. setArray2(uniformName: string, array: number[]): void;
  44382. /**
  44383. * 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)
  44384. * @param uniformName Name of the variable.
  44385. * @param array array to be set.
  44386. * @returns this effect.
  44387. */
  44388. setArray3(uniformName: string, array: number[]): void;
  44389. /**
  44390. * 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)
  44391. * @param uniformName Name of the variable.
  44392. * @param array array to be set.
  44393. */
  44394. setArray4(uniformName: string, array: number[]): void;
  44395. /**
  44396. * Sets matrices on a uniform variable.
  44397. * @param uniformName Name of the variable.
  44398. * @param matrices matrices to be set.
  44399. */
  44400. setMatrices(uniformName: string, matrices: Float32Array): void;
  44401. /**
  44402. * Sets matrix on a uniform variable.
  44403. * @param uniformName Name of the variable.
  44404. * @param matrix matrix to be set.
  44405. */
  44406. setMatrix(uniformName: string, matrix: IMatrixLike): void;
  44407. /**
  44408. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  44409. * @param uniformName Name of the variable.
  44410. * @param matrix matrix to be set.
  44411. */
  44412. setMatrix3x3(uniformName: string, matrix: Float32Array): void;
  44413. /**
  44414. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  44415. * @param uniformName Name of the variable.
  44416. * @param matrix matrix to be set.
  44417. */
  44418. setMatrix2x2(uniformName: string, matrix: Float32Array): void;
  44419. /**
  44420. * Sets a float on a uniform variable.
  44421. * @param uniformName Name of the variable.
  44422. * @param value value to be set.
  44423. * @returns this effect.
  44424. */
  44425. setFloat(uniformName: string, value: number): void;
  44426. /**
  44427. * Sets a Vector2 on a uniform variable.
  44428. * @param uniformName Name of the variable.
  44429. * @param vector2 vector2 to be set.
  44430. */
  44431. setVector2(uniformName: string, vector2: IVector2Like): void;
  44432. /**
  44433. * Sets a float2 on a uniform variable.
  44434. * @param uniformName Name of the variable.
  44435. * @param x First float in float2.
  44436. * @param y Second float in float2.
  44437. */
  44438. setFloat2(uniformName: string, x: number, y: number): void;
  44439. /**
  44440. * Sets a Vector3 on a uniform variable.
  44441. * @param uniformName Name of the variable.
  44442. * @param vector3 Value to be set.
  44443. */
  44444. setVector3(uniformName: string, vector3: IVector3Like): void;
  44445. /**
  44446. * Sets a float3 on a uniform variable.
  44447. * @param uniformName Name of the variable.
  44448. * @param x First float in float3.
  44449. * @param y Second float in float3.
  44450. * @param z Third float in float3.
  44451. */
  44452. setFloat3(uniformName: string, x: number, y: number, z: number): void;
  44453. /**
  44454. * Sets a Vector4 on a uniform variable.
  44455. * @param uniformName Name of the variable.
  44456. * @param vector4 Value to be set.
  44457. */
  44458. setVector4(uniformName: string, vector4: IVector4Like): void;
  44459. /**
  44460. * Sets a float4 on a uniform variable.
  44461. * @param uniformName Name of the variable.
  44462. * @param x First float in float4.
  44463. * @param y Second float in float4.
  44464. * @param z Third float in float4.
  44465. * @param w Fourth float in float4.
  44466. * @returns this effect.
  44467. */
  44468. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  44469. /**
  44470. * Sets a Color3 on a uniform variable.
  44471. * @param uniformName Name of the variable.
  44472. * @param color3 Value to be set.
  44473. */
  44474. setColor3(uniformName: string, color3: IColor3Like): void;
  44475. /**
  44476. * Sets a Color4 on a uniform variable.
  44477. * @param uniformName Name of the variable.
  44478. * @param color3 Value to be set.
  44479. * @param alpha Alpha value to be set.
  44480. */
  44481. setColor4(uniformName: string, color3: IColor3Like, alpha: number): void;
  44482. /**
  44483. * Sets a Color4 on a uniform variable
  44484. * @param uniformName defines the name of the variable
  44485. * @param color4 defines the value to be set
  44486. */
  44487. setDirectColor4(uniformName: string, color4: IColor4Like): void;
  44488. _getVertexShaderCode(): string | null;
  44489. _getFragmentShaderCode(): string | null;
  44490. }
  44491. }
  44492. declare module BABYLON {
  44493. /** @hidden */
  44494. export class WebGPUDataBuffer extends DataBuffer {
  44495. private _buffer;
  44496. constructor(resource: GPUBuffer);
  44497. get underlyingResource(): any;
  44498. }
  44499. }
  44500. declare module BABYLON {
  44501. /**
  44502. * Class used to inline functions in shader code
  44503. */
  44504. export class ShaderCodeInliner {
  44505. private static readonly _RegexpFindFunctionNameAndType;
  44506. private _sourceCode;
  44507. private _functionDescr;
  44508. private _numMaxIterations;
  44509. /** Gets or sets the token used to mark the functions to inline */
  44510. inlineToken: string;
  44511. /** Gets or sets the debug mode */
  44512. debug: boolean;
  44513. /** Gets the code after the inlining process */
  44514. get code(): string;
  44515. /**
  44516. * Initializes the inliner
  44517. * @param sourceCode shader code source to inline
  44518. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  44519. */
  44520. constructor(sourceCode: string, numMaxIterations?: number);
  44521. /**
  44522. * Start the processing of the shader code
  44523. */
  44524. processCode(): void;
  44525. private _collectFunctions;
  44526. private _processInlining;
  44527. private _extractBetweenMarkers;
  44528. private _skipWhitespaces;
  44529. private _isIdentifierChar;
  44530. private _removeComments;
  44531. private _replaceFunctionCallsByCode;
  44532. private _findBackward;
  44533. private _escapeRegExp;
  44534. private _replaceNames;
  44535. }
  44536. }
  44537. declare module BABYLON {
  44538. /** @hidden */
  44539. export class WebGPUShaderProcessor implements IShaderProcessor {
  44540. protected _missingVaryings: Array<string>;
  44541. protected _textureArrayProcessing: Array<string>;
  44542. protected _preProcessors: {
  44543. [key: string]: string;
  44544. };
  44545. private _getArraySize;
  44546. initializeShaders(processingContext: Nullable<ShaderProcessingContext>): void;
  44547. varyingProcessor(varying: string, isFragment: boolean, preProcessors: {
  44548. [key: string]: string;
  44549. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44550. attributeProcessor(attribute: string, preProcessors: {
  44551. [key: string]: string;
  44552. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44553. uniformProcessor(uniform: string, isFragment: boolean, preProcessors: {
  44554. [key: string]: string;
  44555. }, processingContext: Nullable<ShaderProcessingContext>): string;
  44556. uniformBufferProcessor(uniformBuffer: string, isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44557. postProcessor(code: string, defines: string[], isFragment: boolean, processingContext: Nullable<ShaderProcessingContext>): string;
  44558. private _applyTextureArrayProcessing;
  44559. finalizeShaders(vertexCode: string, fragmentCode: string, processingContext: Nullable<ShaderProcessingContext>): {
  44560. vertexCode: string;
  44561. fragmentCode: string;
  44562. };
  44563. }
  44564. }
  44565. declare module BABYLON {
  44566. /** @hidden */
  44567. export class WebGPUBufferManager {
  44568. private _device;
  44569. private _deferredReleaseBuffers;
  44570. private static _IsGPUBuffer;
  44571. constructor(device: GPUDevice);
  44572. createRawBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags, mappedAtCreation?: boolean): GPUBuffer;
  44573. createBuffer(viewOrSize: ArrayBufferView | number, flags: GPUBufferUsageFlags): DataBuffer;
  44574. setSubData(dataBuffer: WebGPUDataBuffer, dstByteOffset: number, src: ArrayBufferView, srcByteOffset?: number, byteLength?: number): void;
  44575. private _FromHalfFloat;
  44576. private _GetHalfFloatAsFloatRGBAArrayBuffer;
  44577. readDataFromBuffer(gpuBuffer: GPUBuffer, size: number, width: number, height: number, bytesPerRow: number, bytesPerRowAligned: number, floatFormat?: number, offset?: number, buffer?: Nullable<ArrayBufferView>, destroyBuffer?: boolean): Promise<ArrayBufferView>;
  44578. releaseBuffer(buffer: DataBuffer | GPUBuffer): boolean;
  44579. destroyDeferredBuffers(): void;
  44580. }
  44581. }
  44582. declare module BABYLON {
  44583. /** @hidden */
  44584. export class WebGPUHardwareTexture implements HardwareTextureWrapper {
  44585. private _webgpuTexture;
  44586. private _webgpuMSAATexture;
  44587. get underlyingResource(): Nullable<GPUTexture>;
  44588. get msaaTexture(): Nullable<GPUTexture>;
  44589. set msaaTexture(texture: Nullable<GPUTexture>);
  44590. view: Nullable<GPUTextureView>;
  44591. format: GPUTextureFormat;
  44592. textureUsages: number;
  44593. constructor(existingTexture?: Nullable<GPUTexture>);
  44594. set(hardwareTexture: GPUTexture): void;
  44595. setMSAATexture(hardwareTexture: GPUTexture): void;
  44596. setUsage(textureSource: number, generateMipMaps: boolean, isCube: boolean, width: number, height: number): void;
  44597. createView(descriptor?: GPUTextureViewDescriptor): void;
  44598. reset(): void;
  44599. release(): void;
  44600. }
  44601. }
  44602. declare module BABYLON {
  44603. /** @hidden */
  44604. export class WebGPUTextureHelper {
  44605. private _device;
  44606. private _glslang;
  44607. private _bufferManager;
  44608. private _mipmapSampler;
  44609. private _invertYPreMultiplyAlphaSampler;
  44610. private _pipelines;
  44611. private _compiledShaders;
  44612. private _deferredReleaseTextures;
  44613. private _commandEncoderForCreation;
  44614. static ComputeNumMipmapLevels(width: number, height: number): number;
  44615. constructor(device: GPUDevice, glslang: any, bufferManager: WebGPUBufferManager);
  44616. private _getPipeline;
  44617. private static _GetTextureTypeFromFormat;
  44618. private static _GetBlockInformationFromFormat;
  44619. private static _IsHardwareTexture;
  44620. private static _IsInternalTexture;
  44621. static GetCompareFunction(compareFunction: Nullable<number>): GPUCompareFunction;
  44622. static IsImageBitmap(imageBitmap: ImageBitmap | {
  44623. width: number;
  44624. height: number;
  44625. }): imageBitmap is ImageBitmap;
  44626. static IsImageBitmapArray(imageBitmap: ImageBitmap[] | {
  44627. width: number;
  44628. height: number;
  44629. }): imageBitmap is ImageBitmap[];
  44630. setCommandEncoder(encoder: GPUCommandEncoder): void;
  44631. static IsCompressedFormat(format: GPUTextureFormat): boolean;
  44632. static GetWebGPUTextureFormat(type: number, format: number): GPUTextureFormat;
  44633. invertYPreMultiplyAlpha(gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44634. clear(format: GPUTextureFormat, color: IColor4Like, passEncoder: GPURenderPassEncoder): void;
  44635. createTexture(imageBitmap: ImageBitmap | {
  44636. width: number;
  44637. height: number;
  44638. layers: number;
  44639. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, is3D?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44640. createCubeTexture(imageBitmaps: ImageBitmap[] | {
  44641. width: number;
  44642. height: number;
  44643. }, hasMipmaps?: boolean, generateMipmaps?: boolean, invertY?: boolean, premultiplyAlpha?: boolean, format?: GPUTextureFormat, sampleCount?: number, commandEncoder?: GPUCommandEncoder, usage?: number): GPUTexture;
  44644. generateCubeMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, commandEncoder?: GPUCommandEncoder): void;
  44645. generateMipmaps(gpuTexture: GPUTexture, format: GPUTextureFormat, mipLevelCount: number, faceIndex?: number, commandEncoder?: GPUCommandEncoder): void;
  44646. createGPUTextureForInternalTexture(texture: InternalTexture, width?: number, height?: number, depth?: number): WebGPUHardwareTexture;
  44647. createMSAATexture(texture: InternalTexture, samples: number): void;
  44648. updateCubeTextures(imageBitmaps: ImageBitmap[] | Uint8Array[], gpuTexture: GPUTexture, width: number, height: number, format: GPUTextureFormat, invertY?: boolean, premultiplyAlpha?: boolean, offsetX?: number, offsetY?: number, commandEncoder?: GPUCommandEncoder): void;
  44649. 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;
  44650. readPixels(texture: GPUTexture, x: number, y: number, width: number, height: number, format: GPUTextureFormat, faceIndex?: number, mipLevel?: number, buffer?: Nullable<ArrayBufferView>): Promise<ArrayBufferView>;
  44651. releaseTexture(texture: InternalTexture | GPUTexture): void;
  44652. destroyDeferredTextures(): void;
  44653. }
  44654. }
  44655. declare module BABYLON {
  44656. /** @hidden */
  44657. export class WebGPURenderPassWrapper {
  44658. renderPassDescriptor: Nullable<GPURenderPassDescriptor>;
  44659. renderPass: Nullable<GPURenderPassEncoder>;
  44660. colorAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44661. depthAttachmentViewDescriptor: Nullable<GPUTextureViewDescriptor>;
  44662. colorAttachmentGPUTextures: WebGPUHardwareTexture[];
  44663. depthTextureFormat: GPUTextureFormat | undefined;
  44664. constructor();
  44665. reset(fullReset?: boolean): void;
  44666. }
  44667. }
  44668. declare module BABYLON {
  44669. /** @hidden */
  44670. export class WebGPUCacheSampler {
  44671. private _samplers;
  44672. private _device;
  44673. constructor(device: GPUDevice);
  44674. private static _GetSamplerHashCode;
  44675. private static _GetSamplerFilterDescriptor;
  44676. private static _GetWrappingMode;
  44677. private static _GetSamplerWrappingDescriptor;
  44678. private static _GetSamplerDescriptor;
  44679. getSampler(internalTexture: InternalTexture, bypassCache?: boolean): GPUSampler;
  44680. }
  44681. }
  44682. declare module BABYLON {
  44683. /** @hidden */
  44684. export class WebGPUShaderManager {
  44685. private _shaders;
  44686. private _device;
  44687. constructor(device: GPUDevice);
  44688. getCompiledShaders(name: string): IWebGPURenderPipelineStageDescriptor;
  44689. }
  44690. }
  44691. declare module BABYLON {
  44692. /** @hidden */
  44693. export var clearQuadVertexShader: {
  44694. name: string;
  44695. shader: string;
  44696. };
  44697. }
  44698. declare module BABYLON {
  44699. /** @hidden */
  44700. export var clearQuadPixelShader: {
  44701. name: string;
  44702. shader: string;
  44703. };
  44704. }
  44705. declare module BABYLON {
  44706. /**
  44707. * Options to load the associated Glslang library
  44708. */
  44709. export interface GlslangOptions {
  44710. /**
  44711. * Defines an existing instance of Glslang (usefull in modules who do not access the global instance).
  44712. */
  44713. glslang?: any;
  44714. /**
  44715. * Defines the URL of the glslang JS File.
  44716. */
  44717. jsPath?: string;
  44718. /**
  44719. * Defines the URL of the glslang WASM File.
  44720. */
  44721. wasmPath?: string;
  44722. }
  44723. /**
  44724. * Options to create the WebGPU engine
  44725. */
  44726. export interface WebGPUEngineOptions extends GPURequestAdapterOptions {
  44727. /**
  44728. * If delta time between frames should be constant
  44729. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44730. */
  44731. deterministicLockstep?: boolean;
  44732. /**
  44733. * Maximum about of steps between frames (Default: 4)
  44734. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44735. */
  44736. lockstepMaxSteps?: number;
  44737. /**
  44738. * Defines the seconds between each deterministic lock step
  44739. */
  44740. timeStep?: number;
  44741. /**
  44742. * Defines that engine should ignore modifying touch action attribute and style
  44743. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  44744. */
  44745. doNotHandleTouchAction?: boolean;
  44746. /**
  44747. * Defines if webaudio should be initialized as well
  44748. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  44749. */
  44750. audioEngine?: boolean;
  44751. /**
  44752. * Defines the category of adapter to use.
  44753. * Is it the discrete or integrated device.
  44754. */
  44755. powerPreference?: GPUPowerPreference;
  44756. /**
  44757. * Defines the device descriptor used to create a device.
  44758. */
  44759. deviceDescriptor?: GPUDeviceDescriptor;
  44760. /**
  44761. * Defines the requested Swap Chain Format.
  44762. */
  44763. swapChainFormat?: GPUTextureFormat;
  44764. /**
  44765. * Defines wether MSAA is enabled on the canvas.
  44766. */
  44767. antialiasing?: boolean;
  44768. /**
  44769. * Defines wether the stencil buffer should be enabled.
  44770. */
  44771. stencil?: boolean;
  44772. /**
  44773. * Defines wether we should generate debug markers in the gpu command lists (can be seen with PIX for eg)
  44774. */
  44775. enableGPUDebugMarkers?: boolean;
  44776. /**
  44777. * Options to load the associated Glslang library
  44778. */
  44779. glslangOptions?: GlslangOptions;
  44780. }
  44781. /**
  44782. * The web GPU engine class provides support for WebGPU version of babylon.js.
  44783. */
  44784. export class WebGPUEngine extends Engine {
  44785. private static readonly _glslangDefaultOptions;
  44786. private readonly _uploadEncoderDescriptor;
  44787. private readonly _renderEncoderDescriptor;
  44788. private readonly _renderTargetEncoderDescriptor;
  44789. private readonly _clearDepthValue;
  44790. private readonly _clearReverseDepthValue;
  44791. private readonly _clearStencilValue;
  44792. private readonly _defaultSampleCount;
  44793. private _canvas;
  44794. private _options;
  44795. private _glslang;
  44796. private _adapter;
  44797. private _adapterSupportedExtensions;
  44798. private _device;
  44799. private _deviceEnabledExtensions;
  44800. private _context;
  44801. private _swapChain;
  44802. private _swapChainTexture;
  44803. private _mainPassSampleCount;
  44804. private _textureHelper;
  44805. private _bufferManager;
  44806. private _shaderManager;
  44807. private _cacheSampler;
  44808. private _emptyVertexBuffer;
  44809. private _lastCachedWrapU;
  44810. private _lastCachedWrapV;
  44811. private _lastCachedWrapR;
  44812. private _mrtAttachments;
  44813. private _counters;
  44814. private _mainTexture;
  44815. private _depthTexture;
  44816. private _mainTextureExtends;
  44817. private _depthTextureFormat;
  44818. private _colorFormat;
  44819. private _uploadEncoder;
  44820. private _renderEncoder;
  44821. private _renderTargetEncoder;
  44822. private _commandBuffers;
  44823. private _currentRenderPass;
  44824. private _mainRenderPassWrapper;
  44825. private _rttRenderPassWrapper;
  44826. private _pendingDebugCommands;
  44827. private _currentVertexBuffers;
  44828. private _currentIndexBuffer;
  44829. private __colorWrite;
  44830. private _uniformsBuffers;
  44831. private _forceEnableEffect;
  44832. /** @hidden */
  44833. dbgShowShaderCode: boolean;
  44834. /** @hidden */
  44835. dbgSanityChecks: boolean;
  44836. /** @hidden */
  44837. dbgGenerateLogs: boolean;
  44838. /** @hidden */
  44839. dbgVerboseLogsForFirstFrames: boolean;
  44840. /** @hidden */
  44841. dbgVerboseLogsNumFrames: number;
  44842. /** @hidden */
  44843. dbgShowWarningsNotImplemented: boolean;
  44844. /**
  44845. * Gets a boolean indicating if the engine can be instanciated (ie. if a WebGPU context can be found)
  44846. * @returns true if the engine can be created
  44847. */
  44848. static get IsSupported(): boolean;
  44849. /**
  44850. * Gets a boolean indicating that the engine supports uniform buffers
  44851. */
  44852. get supportsUniformBuffers(): boolean;
  44853. /** Gets the supported extensions by the WebGPU adapter */
  44854. get supportedExtensions(): Immutable<GPUExtensionName[]>;
  44855. /** Gets the currently enabled extensions on the WebGPU device */
  44856. get enabledExtensions(): Immutable<GPUExtensionName[]>;
  44857. /**
  44858. * Returns the name of the engine
  44859. */
  44860. get name(): string;
  44861. /**
  44862. * Returns a string describing the current engine
  44863. */
  44864. get description(): string;
  44865. /**
  44866. * Returns the version of the engine
  44867. */
  44868. get version(): number;
  44869. /**
  44870. * Create a new instance of the gpu engine asynchronously
  44871. * @param canvas Defines the canvas to use to display the result
  44872. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44873. * @returns a promise that resolves with the created engine
  44874. */
  44875. static CreateAsync(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions): Promise<WebGPUEngine>;
  44876. /**
  44877. * Create a new instance of the gpu engine.
  44878. * @param canvas Defines the canvas to use to display the result
  44879. * @param options Defines the options passed to the engine to create the GPU context dependencies
  44880. */
  44881. constructor(canvas: HTMLCanvasElement, options?: WebGPUEngineOptions);
  44882. /**
  44883. * Initializes the WebGPU context and dependencies.
  44884. * @param glslangOptions Defines the GLSLang compiler options if necessary
  44885. * @returns a promise notifying the readiness of the engine.
  44886. */
  44887. initAsync(glslangOptions?: GlslangOptions): Promise<void>;
  44888. private _initGlslang;
  44889. private _initializeLimits;
  44890. private _initializeContextAndSwapChain;
  44891. private _initializeMainAttachments;
  44892. /**
  44893. * Force a specific size of the canvas
  44894. * @param width defines the new canvas' width
  44895. * @param height defines the new canvas' height
  44896. * @param forceSetSize true to force setting the sizes of the underlying canvas
  44897. * @returns true if the size was changed
  44898. */
  44899. setSize(width: number, height: number, forceSetSize?: boolean): boolean;
  44900. /**
  44901. * Gets a shader processor implementation fitting with the current engine type.
  44902. * @returns The shader processor implementation.
  44903. */
  44904. protected _getShaderProcessor(): Nullable<IShaderProcessor>;
  44905. /** @hidden */
  44906. _getShaderProcessingContext(): Nullable<ShaderProcessingContext>;
  44907. /**
  44908. * Force the entire cache to be cleared
  44909. * You should not have to use this function unless your engine needs to share the WebGPU context with another engine
  44910. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  44911. */
  44912. wipeCaches(bruteForce?: boolean): void;
  44913. /**
  44914. * Enable or disable color writing
  44915. * @param enable defines the state to set
  44916. */
  44917. setColorWrite(enable: boolean): void;
  44918. /**
  44919. * Gets a boolean indicating if color writing is enabled
  44920. * @returns the current color writing state
  44921. */
  44922. getColorWrite(): boolean;
  44923. private _viewportsCurrent;
  44924. private _resetCurrentViewport;
  44925. private _applyViewport;
  44926. /** @hidden */
  44927. _viewport(x: number, y: number, width: number, height: number): void;
  44928. private _scissorsCurrent;
  44929. protected _scissorCached: {
  44930. x: number;
  44931. y: number;
  44932. z: number;
  44933. w: number;
  44934. };
  44935. private _resetCurrentScissor;
  44936. private _applyScissor;
  44937. private _scissorIsActive;
  44938. enableScissor(x: number, y: number, width: number, height: number): void;
  44939. disableScissor(): void;
  44940. /**
  44941. * Clear the current render buffer or the current render target (if any is set up)
  44942. * @param color defines the color to use
  44943. * @param backBuffer defines if the back buffer must be cleared
  44944. * @param depth defines if the depth buffer must be cleared
  44945. * @param stencil defines if the stencil buffer must be cleared
  44946. */
  44947. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  44948. /**
  44949. * Clears a list of attachments
  44950. * @param attachments list of the attachments
  44951. * @param colorMain clear color for the main attachment (the first one)
  44952. * @param colorOthers clear color for the other attachments
  44953. * @param clearDepth true to clear the depth buffer. Used only for the first attachment
  44954. * @param clearStencil true to clear the stencil buffer. Used only for the first attachment
  44955. */
  44956. clearAttachments(attachments: number[], colorMain: Nullable<IColor4Like>, colorOthers: Nullable<IColor4Like>, clearDepth: boolean, clearStencil: boolean): void;
  44957. /**
  44958. * Creates a vertex buffer
  44959. * @param data the data for the vertex buffer
  44960. * @returns the new buffer
  44961. */
  44962. createVertexBuffer(data: DataArray): DataBuffer;
  44963. /**
  44964. * Creates a vertex buffer
  44965. * @param data the data for the dynamic vertex buffer
  44966. * @returns the new buffer
  44967. */
  44968. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  44969. /**
  44970. * Updates a vertex buffer.
  44971. * @param vertexBuffer the vertex buffer to update
  44972. * @param data the data used to update the vertex buffer
  44973. * @param byteOffset the byte offset of the data
  44974. * @param byteLength the byte length of the data
  44975. */
  44976. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  44977. /**
  44978. * Creates a new index buffer
  44979. * @param indices defines the content of the index buffer
  44980. * @param updatable defines if the index buffer must be updatable - not used in WebGPU
  44981. * @returns a new buffer
  44982. */
  44983. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  44984. /**
  44985. * Update an index buffer
  44986. * @param indexBuffer defines the target index buffer
  44987. * @param indices defines the data to update
  44988. * @param offset defines the offset in the target index buffer where update should start
  44989. */
  44990. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  44991. /** @hidden */
  44992. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  44993. /** @hidden */
  44994. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  44995. /**
  44996. * Bind a list of vertex buffers with the engine
  44997. * @param vertexBuffers defines the list of vertex buffers to bind
  44998. * @param indexBuffer defines the index buffer to bind
  44999. * @param effect defines the effect associated with the vertex buffers
  45000. */
  45001. bindBuffers(vertexBuffers: {
  45002. [key: string]: Nullable<VertexBuffer>;
  45003. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  45004. /** @hidden */
  45005. _releaseBuffer(buffer: DataBuffer): boolean;
  45006. createUniformBuffer(elements: FloatArray): DataBuffer;
  45007. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  45008. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  45009. bindUniformBufferBase(buffer: DataBuffer, location: number, name: string): void;
  45010. /**
  45011. * Create a new effect (used to store vertex/fragment shaders)
  45012. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  45013. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  45014. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  45015. * @param samplers defines an array of string used to represent textures
  45016. * @param defines defines the string containing the defines to use to compile the shaders
  45017. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  45018. * @param onCompiled defines a function to call when the effect creation is successful
  45019. * @param onError defines a function to call when the effect creation has failed
  45020. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  45021. * @returns the new Effect
  45022. */
  45023. 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;
  45024. private _compileRawShaderToSpirV;
  45025. private _compileShaderToSpirV;
  45026. private _createPipelineStageDescriptor;
  45027. private _compileRawPipelineStageDescriptor;
  45028. private _compilePipelineStageDescriptor;
  45029. /** @hidden */
  45030. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45031. /** @hidden */
  45032. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  45033. /**
  45034. * Creates a new pipeline context
  45035. * @param shaderProcessingContext defines the shader processing context used during the processing if available
  45036. * @returns the new pipeline
  45037. */
  45038. createPipelineContext(shaderProcessingContext: Nullable<ShaderProcessingContext>): IPipelineContext;
  45039. /** @hidden */
  45040. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>, key: string): void;
  45041. /**
  45042. * Gets the list of active attributes for a given WebGPU program
  45043. * @param pipelineContext defines the pipeline context to use
  45044. * @param attributesNames defines the list of attribute names to get
  45045. * @returns an array of indices indicating the offset of each attribute
  45046. */
  45047. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45048. /**
  45049. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45050. * @param effect defines the effect to activate
  45051. */
  45052. enableEffect(effect: Nullable<Effect>): void;
  45053. /** @hidden */
  45054. _releaseEffect(effect: Effect): void;
  45055. /**
  45056. * 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
  45057. */
  45058. releaseEffects(): void;
  45059. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  45060. /**
  45061. * Gets a boolean indicating that only power of 2 textures are supported
  45062. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  45063. */
  45064. get needPOTTextures(): boolean;
  45065. /** @hidden */
  45066. _createHardwareTexture(): HardwareTextureWrapper;
  45067. /** @hidden */
  45068. _releaseTexture(texture: InternalTexture): void;
  45069. /** @hidden */
  45070. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  45071. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  45072. /**
  45073. * Usually called from Texture.ts.
  45074. * Passed information to create a hardware texture
  45075. * @param url defines a value which contains one of the following:
  45076. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45077. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45078. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45079. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45080. * @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)
  45081. * @param scene needed for loading to the correct scene
  45082. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45083. * @param onLoad optional callback to be called upon successful completion
  45084. * @param onError optional callback to be called upon failure
  45085. * @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
  45086. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45087. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45088. * @param forcedExtension defines the extension to use to pick the right loader
  45089. * @param mimeType defines an optional mime type
  45090. * @param loaderOptions options to be passed to the loader
  45091. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45092. */
  45093. 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;
  45094. /** @hidden */
  45095. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  45096. /**
  45097. * Creates a cube texture
  45098. * @param rootUrl defines the url where the files to load is located
  45099. * @param scene defines the current scene
  45100. * @param files defines the list of files to load (1 per face)
  45101. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  45102. * @param onLoad defines an optional callback raised when the texture is loaded
  45103. * @param onError defines an optional callback raised if there is an issue to load the texture
  45104. * @param format defines the format of the data
  45105. * @param forcedExtension defines the extension to use to pick the right loader
  45106. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  45107. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  45108. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  45109. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  45110. * @param loaderOptions options to be passed to the loader
  45111. * @returns the cube texture as an InternalTexture
  45112. */
  45113. 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;
  45114. /**
  45115. * Creates a raw texture
  45116. * @param data defines the data to store in the texture
  45117. * @param width defines the width of the texture
  45118. * @param height defines the height of the texture
  45119. * @param format defines the format of the data
  45120. * @param generateMipMaps defines if the engine should generate the mip levels
  45121. * @param invertY defines if data must be stored with Y axis inverted
  45122. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  45123. * @param compression defines the compression used (null by default)
  45124. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45125. * @returns the raw texture inside an InternalTexture
  45126. */
  45127. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  45128. /**
  45129. * Creates a new raw cube texture
  45130. * @param data defines the array of data to use to create each face
  45131. * @param size defines the size of the textures
  45132. * @param format defines the format of the data
  45133. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45134. * @param generateMipMaps defines if the engine should generate the mip levels
  45135. * @param invertY defines if data must be stored with Y axis inverted
  45136. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45137. * @param compression defines the compression used (null by default)
  45138. * @returns the cube texture as an InternalTexture
  45139. */
  45140. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  45141. /**
  45142. * Creates a new raw cube texture from a specified url
  45143. * @param url defines the url where the data is located
  45144. * @param scene defines the current scene
  45145. * @param size defines the size of the textures
  45146. * @param format defines the format of the data
  45147. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  45148. * @param noMipmap defines if the engine should avoid generating the mip levels
  45149. * @param callback defines a callback used to extract texture data from loaded data
  45150. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  45151. * @param onLoad defines a callback called when texture is loaded
  45152. * @param onError defines a callback called if there is an error
  45153. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45154. * @param invertY defines if data must be stored with Y axis inverted
  45155. * @returns the cube texture as an InternalTexture
  45156. */
  45157. 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;
  45158. /**
  45159. * Creates a new raw 2D array texture
  45160. * @param data defines the data used to create the texture
  45161. * @param width defines the width of the texture
  45162. * @param height defines the height of the texture
  45163. * @param depth defines the number of layers of the texture
  45164. * @param format defines the format of the texture
  45165. * @param generateMipMaps defines if the engine must generate mip levels
  45166. * @param invertY defines if data must be stored with Y axis inverted
  45167. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45168. * @param compression defines the compressed used (can be null)
  45169. * @param textureType defines the compressed used (can be null)
  45170. * @returns a new raw 2D array texture (stored in an InternalTexture)
  45171. */
  45172. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45173. /**
  45174. * Creates a new raw 3D texture
  45175. * @param data defines the data used to create the texture
  45176. * @param width defines the width of the texture
  45177. * @param height defines the height of the texture
  45178. * @param depth defines the depth of the texture
  45179. * @param format defines the format of the texture
  45180. * @param generateMipMaps defines if the engine must generate mip levels
  45181. * @param invertY defines if data must be stored with Y axis inverted
  45182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  45183. * @param compression defines the compressed used (can be null)
  45184. * @param textureType defines the compressed used (can be null)
  45185. * @returns a new raw 3D texture (stored in an InternalTexture)
  45186. */
  45187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  45188. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  45189. /**
  45190. * Update the sampling mode of a given texture
  45191. * @param samplingMode defines the required sampling mode
  45192. * @param texture defines the texture to update
  45193. * @param generateMipMaps defines whether to generate mipmaps for the texture
  45194. */
  45195. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  45196. /**
  45197. * Update the sampling mode of a given texture
  45198. * @param texture defines the texture to update
  45199. * @param wrapU defines the texture wrap mode of the u coordinates
  45200. * @param wrapV defines the texture wrap mode of the v coordinates
  45201. * @param wrapR defines the texture wrap mode of the r coordinates
  45202. */
  45203. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  45204. /**
  45205. * Update the dimensions of a texture
  45206. * @param texture texture to update
  45207. * @param width new width of the texture
  45208. * @param height new height of the texture
  45209. * @param depth new depth of the texture
  45210. */
  45211. updateTextureDimensions(texture: InternalTexture, width: number, height: number, depth?: number): void;
  45212. private _setInternalTexture;
  45213. /**
  45214. * Sets a texture to the according uniform.
  45215. * @param channel The texture channel
  45216. * @param unused unused parameter
  45217. * @param texture The texture to apply
  45218. * @param name The name of the uniform in the effect
  45219. */
  45220. setTexture(channel: number, unused: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>, name: string): void;
  45221. /**
  45222. * Sets an array of texture to the WebGPU context
  45223. * @param channel defines the channel where the texture array must be set
  45224. * @param unused unused parameter
  45225. * @param textures defines the array of textures to bind
  45226. * @param name name of the channel
  45227. */
  45228. setTextureArray(channel: number, unused: Nullable<WebGLUniformLocation>, textures: BaseTexture[], name: string): void;
  45229. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean, name?: string, baseName?: string, textureIndex?: number): boolean;
  45230. /** @hidden */
  45231. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  45232. /** @hidden */
  45233. _bindTexture(channel: number, texture: InternalTexture, name: string): void;
  45234. private _generateMipmaps;
  45235. /**
  45236. * Update the content of a texture
  45237. * @param texture defines the texture to update
  45238. * @param canvas defines the source containing the data
  45239. * @param invertY defines if data must be stored with Y axis inverted
  45240. * @param premulAlpha defines if alpha is stored as premultiplied
  45241. * @param format defines the format of the data
  45242. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45243. */
  45244. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  45245. /**
  45246. * Update a portion of an internal texture
  45247. * @param texture defines the texture to update
  45248. * @param imageData defines the data to store into the texture
  45249. * @param xOffset defines the x coordinates of the update rectangle
  45250. * @param yOffset defines the y coordinates of the update rectangle
  45251. * @param width defines the width of the update rectangle
  45252. * @param height defines the height of the update rectangle
  45253. * @param faceIndex defines the face index if texture is a cube (0 by default)
  45254. * @param lod defines the lod level to update (0 by default)
  45255. */
  45256. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  45257. /**
  45258. * Update a video texture
  45259. * @param texture defines the texture to update
  45260. * @param video defines the video element to use
  45261. * @param invertY defines if data must be stored with Y axis inverted
  45262. */
  45263. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  45264. /** @hidden */
  45265. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45266. /** @hidden */
  45267. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  45268. /** @hidden */
  45269. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45270. /** @hidden */
  45271. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  45272. /**
  45273. * Update a raw texture
  45274. * @param texture defines the texture to update
  45275. * @param bufferView defines the data to store in the texture
  45276. * @param format defines the format of the data
  45277. * @param invertY defines if data must be stored with Y axis inverted
  45278. * @param compression defines the compression used (null by default)
  45279. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45280. */
  45281. updateRawTexture(texture: Nullable<InternalTexture>, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  45282. /**
  45283. * Update a raw cube texture
  45284. * @param texture defines the texture to udpdate
  45285. * @param bufferView defines the data to store
  45286. * @param format defines the data format
  45287. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  45288. * @param invertY defines if data must be stored with Y axis inverted
  45289. * @param compression defines the compression used (null by default)
  45290. * @param level defines which level of the texture to update
  45291. */
  45292. updateRawCubeTexture(texture: InternalTexture, bufferView: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  45293. /**
  45294. * Update a raw 2D array texture
  45295. * @param texture defines the texture to update
  45296. * @param bufferView defines the data to store
  45297. * @param format defines the data format
  45298. * @param invertY defines if data must be stored with Y axis inverted
  45299. * @param compression defines the used compression (can be null)
  45300. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45301. */
  45302. updateRawTexture2DArray(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45303. /**
  45304. * Update a raw 3D texture
  45305. * @param texture defines the texture to update
  45306. * @param bufferView defines the data to store
  45307. * @param format defines the data format
  45308. * @param invertY defines if data must be stored with Y axis inverted
  45309. * @param compression defines the used compression (can be null)
  45310. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  45311. */
  45312. updateRawTexture3D(texture: InternalTexture, bufferView: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, textureType?: number): void;
  45313. /**
  45314. * Reads pixels from the current frame buffer. Please note that this function can be slow
  45315. * @param x defines the x coordinate of the rectangle where pixels must be read
  45316. * @param y defines the y coordinate of the rectangle where pixels must be read
  45317. * @param width defines the width of the rectangle where pixels must be read
  45318. * @param height defines the height of the rectangle where pixels must be read
  45319. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  45320. * @param flushRenderer true to flush the renderer from the pending commands before reading the pixels
  45321. * @returns a ArrayBufferView promise (Uint8Array) containing RGBA colors
  45322. */
  45323. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45324. /** @hidden */
  45325. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>, flushRenderer?: boolean): Promise<ArrayBufferView>;
  45326. /**
  45327. * Creates a new render target texture
  45328. * @param size defines the size of the texture
  45329. * @param options defines the options used to create the texture
  45330. * @returns a new render target texture stored in an InternalTexture
  45331. */
  45332. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45333. /**
  45334. * Create a multi render target texture
  45335. * @param size defines the size of the texture
  45336. * @param options defines the creation options
  45337. * @returns the cube texture as an InternalTexture
  45338. */
  45339. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45340. /**
  45341. * Creates a new render target cube texture
  45342. * @param size defines the size of the texture
  45343. * @param options defines the options used to create the texture
  45344. * @returns a new render target cube texture stored in an InternalTexture
  45345. */
  45346. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  45347. /** @hidden */
  45348. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  45349. width: number;
  45350. height: number;
  45351. layers?: number;
  45352. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number, samples?: number): void;
  45353. /** @hidden */
  45354. _createDepthStencilTexture(size: number | {
  45355. width: number;
  45356. height: number;
  45357. layers?: number;
  45358. }, options: DepthTextureCreationOptions): InternalTexture;
  45359. /** @hidden */
  45360. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  45361. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  45362. /**
  45363. * Update the sample count for a given multiple render target texture
  45364. * @param textures defines the textures to update
  45365. * @param samples defines the sample count to set
  45366. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45367. */
  45368. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  45369. /**
  45370. * Begin a new frame
  45371. */
  45372. beginFrame(): void;
  45373. /**
  45374. * End the current frame
  45375. */
  45376. endFrame(): void;
  45377. /**
  45378. * Force a WebGPU flush (ie. a flush of all waiting commands)
  45379. */
  45380. flushFramebuffer(): void;
  45381. private _startRenderTargetRenderPass;
  45382. private _endRenderTargetRenderPass;
  45383. private _getCurrentRenderPass;
  45384. private _currentRenderPassIsMRT;
  45385. private _startMainRenderPass;
  45386. private _endMainRenderPass;
  45387. /**
  45388. * Restores the WebGPU state to only draw on the main color attachment
  45389. */
  45390. restoreSingleAttachment(): void;
  45391. /**
  45392. * Creates a layout object to draw/clear on specific textures in a MRT
  45393. * @param textureStatus textureStatus[i] indicates if the i-th is active
  45394. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  45395. */
  45396. buildTextureLayout(textureStatus: boolean[]): number[];
  45397. /**
  45398. * Select a subsets of attachments to draw to.
  45399. * @param attachments index of attachments
  45400. */
  45401. bindAttachments(attachments: number[]): void;
  45402. /**
  45403. * Binds the frame buffer to the specified texture.
  45404. * @param texture The texture to render to or null for the default canvas
  45405. * @param faceIndex The face of the texture to render to in case of cube texture
  45406. * @param requiredWidth The width of the target to render to
  45407. * @param requiredHeight The height of the target to render to
  45408. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45409. * @param lodLevel defines the lod level to bind to the frame buffer
  45410. * @param layer defines the 2d array index to bind to frame buffer to
  45411. */
  45412. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  45413. /**
  45414. * Unbind the current render target texture from the WebGPU context
  45415. * @param texture defines the render target texture to unbind
  45416. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45417. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45418. */
  45419. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45420. /**
  45421. * Unbind a list of render target textures from the WebGPU context
  45422. * @param textures defines the render target textures to unbind
  45423. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45424. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45425. */
  45426. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45427. /**
  45428. * Unbind the current render target and bind the default framebuffer
  45429. */
  45430. restoreDefaultFramebuffer(): void;
  45431. setZOffset(value: number): void;
  45432. private _setColorFormat;
  45433. private _setDepthTextureFormat;
  45434. setDepthBuffer(enable: boolean): void;
  45435. setDepthWrite(enable: boolean): void;
  45436. setStencilBuffer(enable: boolean): void;
  45437. setStencilMask(mask: number): void;
  45438. setStencilFunction(stencilFunc: number): void;
  45439. setStencilFunctionReference(reference: number): void;
  45440. setStencilFunctionMask(mask: number): void;
  45441. setStencilOperationFail(operation: number): void;
  45442. setStencilOperationDepthFail(operation: number): void;
  45443. setStencilOperationPass(operation: number): void;
  45444. setDitheringState(value: boolean): void;
  45445. setRasterizerState(value: boolean): void;
  45446. setDepthFunction(depthFunc: number): void;
  45447. setDepthFunctionToGreater(): void;
  45448. setDepthFunctionToGreaterOrEqual(): void;
  45449. setDepthFunctionToLess(): void;
  45450. setDepthFunctionToLessOrEqual(): void;
  45451. private _indexFormatInRenderPass;
  45452. private _getTopology;
  45453. private _getOpFunction;
  45454. private _getDepthStencilStateDescriptor;
  45455. /**
  45456. * Set various states to the context
  45457. * @param culling defines backface culling state
  45458. * @param zOffset defines the value to apply to zOffset (0 by default)
  45459. * @param force defines if states must be applied even if cache is up to date
  45460. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45461. */
  45462. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45463. private _getFrontFace;
  45464. private _getCullMode;
  45465. private _getRasterizationStateDescriptor;
  45466. private _getWriteMask;
  45467. /**
  45468. * Sets the current alpha mode
  45469. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45470. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45471. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45472. */
  45473. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45474. private _getAphaBlendOperation;
  45475. private _getAphaBlendFactor;
  45476. private _getAphaBlendState;
  45477. private _getColorBlendState;
  45478. private _getColorStateDescriptors;
  45479. private _getStages;
  45480. private _getVertexInputDescriptorFormat;
  45481. private _getVertexInputDescriptor;
  45482. private _getPipelineLayout;
  45483. private _getRenderPipeline;
  45484. private _getVertexInputsToRender;
  45485. private _getBindGroupsToRender;
  45486. private _bindVertexInputs;
  45487. private _setRenderBindGroups;
  45488. private _setRenderPipeline;
  45489. /**
  45490. * Draw a list of indexed primitives
  45491. * @param fillMode defines the primitive to use
  45492. * @param indexStart defines the starting index
  45493. * @param indexCount defines the number of index to draw
  45494. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45495. */
  45496. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45497. /**
  45498. * Draw a list of unindexed primitives
  45499. * @param fillMode defines the primitive to use
  45500. * @param verticesStart defines the index of first vertex to draw
  45501. * @param verticesCount defines the count of vertices to draw
  45502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45503. */
  45504. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45505. private _bundleEncoder;
  45506. /**
  45507. * Start recording all the gpu calls into a bundle.
  45508. */
  45509. startRecordBundle(): void;
  45510. /**
  45511. * Stops recording the bundle.
  45512. * @returns the recorded bundle
  45513. */
  45514. stopRecordBundle(): GPURenderBundle;
  45515. /**
  45516. * Execute the previously recorded bundle.
  45517. * @param bundles defines the bundle to replay
  45518. */
  45519. executeBundles(bundles: GPURenderBundle[]): void;
  45520. /**
  45521. * Dispose and release all associated resources
  45522. */
  45523. dispose(): void;
  45524. /**
  45525. * Gets the current render width
  45526. * @param useScreen defines if screen size must be used (or the current render target if any)
  45527. * @returns a number defining the current render width
  45528. */
  45529. getRenderWidth(useScreen?: boolean): number;
  45530. /**
  45531. * Gets the current render height
  45532. * @param useScreen defines if screen size must be used (or the current render target if any)
  45533. * @returns a number defining the current render height
  45534. */
  45535. getRenderHeight(useScreen?: boolean): number;
  45536. /**
  45537. * Gets the HTML canvas attached with the current WebGPU context
  45538. * @returns a HTML canvas
  45539. */
  45540. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  45541. /** @hidden */
  45542. _debugPushGroup(groupName: string, targetObject?: number): void;
  45543. /** @hidden */
  45544. _debugPopGroup(targetObject?: number): void;
  45545. /** @hidden */
  45546. _debugInsertMarker(text: string, targetObject?: number): void;
  45547. private _debugFlushPendingCommands;
  45548. /**
  45549. * Get the current error code of the WebGPU context
  45550. * @returns the error code
  45551. */
  45552. getError(): number;
  45553. /** @hidden */
  45554. bindSamplers(effect: Effect): void;
  45555. /** @hidden */
  45556. _bindTextureDirectly(target: number, texture: InternalTexture, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  45557. /** @hidden */
  45558. _releaseFramebufferObjects(texture: InternalTexture): void;
  45559. /** @hidden */
  45560. applyStates(): void;
  45561. /**
  45562. * Gets a boolean indicating if all created effects are ready
  45563. * @returns always true - No parallel shader compilation
  45564. */
  45565. areAllEffectsReady(): boolean;
  45566. /** @hidden */
  45567. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  45568. /** @hidden */
  45569. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  45570. /** @hidden */
  45571. _getUnpackAlignement(): number;
  45572. /** @hidden */
  45573. _unpackFlipY(value: boolean): void;
  45574. /** @hidden */
  45575. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  45576. min: number;
  45577. mag: number;
  45578. };
  45579. /** @hidden */
  45580. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  45581. /** @hidden */
  45582. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45583. /** @hidden */
  45584. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45585. /** @hidden */
  45586. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45587. /** @hidden */
  45588. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45589. /** @hidden */
  45590. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  45591. /** @hidden */
  45592. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  45593. /** @hidden */
  45594. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  45595. /** @hidden */
  45596. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  45597. /** @hidden */
  45598. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  45599. /** @hidden */
  45600. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  45601. /** @hidden */
  45602. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45603. /** @hidden */
  45604. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  45605. /** @hidden */
  45606. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  45607. /** @hidden */
  45608. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  45609. /** @hidden */
  45610. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  45611. /** @hidden */
  45612. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  45613. }
  45614. }
  45615. declare module BABYLON {
  45616. /**
  45617. * Define an interface for all classes that will hold resources
  45618. */
  45619. export interface IDisposable {
  45620. /**
  45621. * Releases all held resources
  45622. */
  45623. dispose(): void;
  45624. }
  45625. /** Interface defining initialization parameters for Scene class */
  45626. export interface SceneOptions {
  45627. /**
  45628. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  45629. * It will improve performance when the number of geometries becomes important.
  45630. */
  45631. useGeometryUniqueIdsMap?: boolean;
  45632. /**
  45633. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  45634. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45635. */
  45636. useMaterialMeshMap?: boolean;
  45637. /**
  45638. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  45639. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  45640. */
  45641. useClonedMeshMap?: boolean;
  45642. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  45643. virtual?: boolean;
  45644. }
  45645. /**
  45646. * Represents a scene to be rendered by the engine.
  45647. * @see https://doc.babylonjs.com/features/scene
  45648. */
  45649. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  45650. /** The fog is deactivated */
  45651. static readonly FOGMODE_NONE: number;
  45652. /** The fog density is following an exponential function */
  45653. static readonly FOGMODE_EXP: number;
  45654. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  45655. static readonly FOGMODE_EXP2: number;
  45656. /** The fog density is following a linear function. */
  45657. static readonly FOGMODE_LINEAR: number;
  45658. /**
  45659. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  45660. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45661. */
  45662. static MinDeltaTime: number;
  45663. /**
  45664. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  45665. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45666. */
  45667. static MaxDeltaTime: number;
  45668. /**
  45669. * Factory used to create the default material.
  45670. * @param name The name of the material to create
  45671. * @param scene The scene to create the material for
  45672. * @returns The default material
  45673. */
  45674. static DefaultMaterialFactory(scene: Scene): Material;
  45675. /**
  45676. * Factory used to create the a collision coordinator.
  45677. * @returns The collision coordinator
  45678. */
  45679. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  45680. /** @hidden */
  45681. _inputManager: InputManager;
  45682. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  45683. cameraToUseForPointers: Nullable<Camera>;
  45684. /** @hidden */
  45685. readonly _isScene: boolean;
  45686. /** @hidden */
  45687. _blockEntityCollection: boolean;
  45688. /**
  45689. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  45690. */
  45691. autoClear: boolean;
  45692. /**
  45693. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  45694. */
  45695. autoClearDepthAndStencil: boolean;
  45696. /**
  45697. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  45698. */
  45699. clearColor: Color4;
  45700. /**
  45701. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  45702. */
  45703. ambientColor: Color3;
  45704. /**
  45705. * This is use to store the default BRDF lookup for PBR materials in your scene.
  45706. * It should only be one of the following (if not the default embedded one):
  45707. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45708. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  45709. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45710. * The material properties need to be setup according to the type of texture in use.
  45711. */
  45712. environmentBRDFTexture: BaseTexture;
  45713. /**
  45714. * Texture used in all pbr material as the reflection texture.
  45715. * As in the majority of the scene they are the same (exception for multi room and so on),
  45716. * this is easier to reference from here than from all the materials.
  45717. */
  45718. get environmentTexture(): Nullable<BaseTexture>;
  45719. /**
  45720. * Texture used in all pbr material as the reflection texture.
  45721. * As in the majority of the scene they are the same (exception for multi room and so on),
  45722. * this is easier to set here than in all the materials.
  45723. */
  45724. set environmentTexture(value: Nullable<BaseTexture>);
  45725. /** @hidden */
  45726. protected _environmentIntensity: number;
  45727. /**
  45728. * Intensity of the environment in all pbr material.
  45729. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45730. * As in the majority of the scene they are the same (exception for multi room and so on),
  45731. * this is easier to reference from here than from all the materials.
  45732. */
  45733. get environmentIntensity(): number;
  45734. /**
  45735. * Intensity of the environment in all pbr material.
  45736. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  45737. * As in the majority of the scene they are the same (exception for multi room and so on),
  45738. * this is easier to set here than in all the materials.
  45739. */
  45740. set environmentIntensity(value: number);
  45741. /** @hidden */
  45742. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45743. /**
  45744. * Default image processing configuration used either in the rendering
  45745. * Forward main pass or through the imageProcessingPostProcess if present.
  45746. * As in the majority of the scene they are the same (exception for multi camera),
  45747. * this is easier to reference from here than from all the materials and post process.
  45748. *
  45749. * No setter as we it is a shared configuration, you can set the values instead.
  45750. */
  45751. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  45752. private _forceWireframe;
  45753. /**
  45754. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  45755. */
  45756. set forceWireframe(value: boolean);
  45757. get forceWireframe(): boolean;
  45758. private _skipFrustumClipping;
  45759. /**
  45760. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  45761. */
  45762. set skipFrustumClipping(value: boolean);
  45763. get skipFrustumClipping(): boolean;
  45764. private _forcePointsCloud;
  45765. /**
  45766. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  45767. */
  45768. set forcePointsCloud(value: boolean);
  45769. get forcePointsCloud(): boolean;
  45770. /**
  45771. * Gets or sets the active clipplane 1
  45772. */
  45773. clipPlane: Nullable<Plane>;
  45774. /**
  45775. * Gets or sets the active clipplane 2
  45776. */
  45777. clipPlane2: Nullable<Plane>;
  45778. /**
  45779. * Gets or sets the active clipplane 3
  45780. */
  45781. clipPlane3: Nullable<Plane>;
  45782. /**
  45783. * Gets or sets the active clipplane 4
  45784. */
  45785. clipPlane4: Nullable<Plane>;
  45786. /**
  45787. * Gets or sets the active clipplane 5
  45788. */
  45789. clipPlane5: Nullable<Plane>;
  45790. /**
  45791. * Gets or sets the active clipplane 6
  45792. */
  45793. clipPlane6: Nullable<Plane>;
  45794. /**
  45795. * Gets or sets a boolean indicating if animations are enabled
  45796. */
  45797. animationsEnabled: boolean;
  45798. private _animationPropertiesOverride;
  45799. /**
  45800. * Gets or sets the animation properties override
  45801. */
  45802. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  45803. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  45804. /**
  45805. * Gets or sets a boolean indicating if a constant deltatime has to be used
  45806. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  45807. */
  45808. useConstantAnimationDeltaTime: boolean;
  45809. /**
  45810. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  45811. * Please note that it requires to run a ray cast through the scene on every frame
  45812. */
  45813. constantlyUpdateMeshUnderPointer: boolean;
  45814. /**
  45815. * Defines the HTML cursor to use when hovering over interactive elements
  45816. */
  45817. hoverCursor: string;
  45818. /**
  45819. * Defines the HTML default cursor to use (empty by default)
  45820. */
  45821. defaultCursor: string;
  45822. /**
  45823. * Defines whether cursors are handled by the scene.
  45824. */
  45825. doNotHandleCursors: boolean;
  45826. /**
  45827. * This is used to call preventDefault() on pointer down
  45828. * in order to block unwanted artifacts like system double clicks
  45829. */
  45830. preventDefaultOnPointerDown: boolean;
  45831. /**
  45832. * This is used to call preventDefault() on pointer up
  45833. * in order to block unwanted artifacts like system double clicks
  45834. */
  45835. preventDefaultOnPointerUp: boolean;
  45836. /**
  45837. * Gets or sets user defined metadata
  45838. */
  45839. metadata: any;
  45840. /**
  45841. * For internal use only. Please do not use.
  45842. */
  45843. reservedDataStore: any;
  45844. /**
  45845. * Gets the name of the plugin used to load this scene (null by default)
  45846. */
  45847. loadingPluginName: string;
  45848. /**
  45849. * Use this array to add regular expressions used to disable offline support for specific urls
  45850. */
  45851. disableOfflineSupportExceptionRules: RegExp[];
  45852. /**
  45853. * An event triggered when the scene is disposed.
  45854. */
  45855. onDisposeObservable: Observable<Scene>;
  45856. private _onDisposeObserver;
  45857. /** Sets a function to be executed when this scene is disposed. */
  45858. set onDispose(callback: () => void);
  45859. /**
  45860. * An event triggered before rendering the scene (right after animations and physics)
  45861. */
  45862. onBeforeRenderObservable: Observable<Scene>;
  45863. private _onBeforeRenderObserver;
  45864. /** Sets a function to be executed before rendering this scene */
  45865. set beforeRender(callback: Nullable<() => void>);
  45866. /**
  45867. * An event triggered after rendering the scene
  45868. */
  45869. onAfterRenderObservable: Observable<Scene>;
  45870. /**
  45871. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  45872. */
  45873. onAfterRenderCameraObservable: Observable<Camera>;
  45874. private _onAfterRenderObserver;
  45875. /** Sets a function to be executed after rendering this scene */
  45876. set afterRender(callback: Nullable<() => void>);
  45877. /**
  45878. * An event triggered before animating the scene
  45879. */
  45880. onBeforeAnimationsObservable: Observable<Scene>;
  45881. /**
  45882. * An event triggered after animations processing
  45883. */
  45884. onAfterAnimationsObservable: Observable<Scene>;
  45885. /**
  45886. * An event triggered before draw calls are ready to be sent
  45887. */
  45888. onBeforeDrawPhaseObservable: Observable<Scene>;
  45889. /**
  45890. * An event triggered after draw calls have been sent
  45891. */
  45892. onAfterDrawPhaseObservable: Observable<Scene>;
  45893. /**
  45894. * An event triggered when the scene is ready
  45895. */
  45896. onReadyObservable: Observable<Scene>;
  45897. /**
  45898. * An event triggered before rendering a camera
  45899. */
  45900. onBeforeCameraRenderObservable: Observable<Camera>;
  45901. private _onBeforeCameraRenderObserver;
  45902. /** Sets a function to be executed before rendering a camera*/
  45903. set beforeCameraRender(callback: () => void);
  45904. /**
  45905. * An event triggered after rendering a camera
  45906. */
  45907. onAfterCameraRenderObservable: Observable<Camera>;
  45908. private _onAfterCameraRenderObserver;
  45909. /** Sets a function to be executed after rendering a camera*/
  45910. set afterCameraRender(callback: () => void);
  45911. /**
  45912. * An event triggered when active meshes evaluation is about to start
  45913. */
  45914. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  45915. /**
  45916. * An event triggered when active meshes evaluation is done
  45917. */
  45918. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  45919. /**
  45920. * An event triggered when particles rendering is about to start
  45921. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45922. */
  45923. onBeforeParticlesRenderingObservable: Observable<Scene>;
  45924. /**
  45925. * An event triggered when particles rendering is done
  45926. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  45927. */
  45928. onAfterParticlesRenderingObservable: Observable<Scene>;
  45929. /**
  45930. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  45931. */
  45932. onDataLoadedObservable: Observable<Scene>;
  45933. /**
  45934. * An event triggered when a camera is created
  45935. */
  45936. onNewCameraAddedObservable: Observable<Camera>;
  45937. /**
  45938. * An event triggered when a camera is removed
  45939. */
  45940. onCameraRemovedObservable: Observable<Camera>;
  45941. /**
  45942. * An event triggered when a light is created
  45943. */
  45944. onNewLightAddedObservable: Observable<Light>;
  45945. /**
  45946. * An event triggered when a light is removed
  45947. */
  45948. onLightRemovedObservable: Observable<Light>;
  45949. /**
  45950. * An event triggered when a geometry is created
  45951. */
  45952. onNewGeometryAddedObservable: Observable<Geometry>;
  45953. /**
  45954. * An event triggered when a geometry is removed
  45955. */
  45956. onGeometryRemovedObservable: Observable<Geometry>;
  45957. /**
  45958. * An event triggered when a transform node is created
  45959. */
  45960. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  45961. /**
  45962. * An event triggered when a transform node is removed
  45963. */
  45964. onTransformNodeRemovedObservable: Observable<TransformNode>;
  45965. /**
  45966. * An event triggered when a mesh is created
  45967. */
  45968. onNewMeshAddedObservable: Observable<AbstractMesh>;
  45969. /**
  45970. * An event triggered when a mesh is removed
  45971. */
  45972. onMeshRemovedObservable: Observable<AbstractMesh>;
  45973. /**
  45974. * An event triggered when a skeleton is created
  45975. */
  45976. onNewSkeletonAddedObservable: Observable<Skeleton>;
  45977. /**
  45978. * An event triggered when a skeleton is removed
  45979. */
  45980. onSkeletonRemovedObservable: Observable<Skeleton>;
  45981. /**
  45982. * An event triggered when a material is created
  45983. */
  45984. onNewMaterialAddedObservable: Observable<Material>;
  45985. /**
  45986. * An event triggered when a multi material is created
  45987. */
  45988. onNewMultiMaterialAddedObservable: Observable<MultiMaterial>;
  45989. /**
  45990. * An event triggered when a material is removed
  45991. */
  45992. onMaterialRemovedObservable: Observable<Material>;
  45993. /**
  45994. * An event triggered when a multi material is removed
  45995. */
  45996. onMultiMaterialRemovedObservable: Observable<MultiMaterial>;
  45997. /**
  45998. * An event triggered when a texture is created
  45999. */
  46000. onNewTextureAddedObservable: Observable<BaseTexture>;
  46001. /**
  46002. * An event triggered when a texture is removed
  46003. */
  46004. onTextureRemovedObservable: Observable<BaseTexture>;
  46005. /**
  46006. * An event triggered when render targets are about to be rendered
  46007. * Can happen multiple times per frame.
  46008. */
  46009. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  46010. /**
  46011. * An event triggered when render targets were rendered.
  46012. * Can happen multiple times per frame.
  46013. */
  46014. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  46015. /**
  46016. * An event triggered before calculating deterministic simulation step
  46017. */
  46018. onBeforeStepObservable: Observable<Scene>;
  46019. /**
  46020. * An event triggered after calculating deterministic simulation step
  46021. */
  46022. onAfterStepObservable: Observable<Scene>;
  46023. /**
  46024. * An event triggered when the activeCamera property is updated
  46025. */
  46026. onActiveCameraChanged: Observable<Scene>;
  46027. /**
  46028. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  46029. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46030. * 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)
  46031. */
  46032. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46033. /**
  46034. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  46035. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  46036. * 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)
  46037. */
  46038. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  46039. /**
  46040. * This Observable will when a mesh has been imported into the scene.
  46041. */
  46042. onMeshImportedObservable: Observable<AbstractMesh>;
  46043. /**
  46044. * This Observable will when an animation file has been imported into the scene.
  46045. */
  46046. onAnimationFileImportedObservable: Observable<Scene>;
  46047. /**
  46048. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  46049. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  46050. */
  46051. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  46052. /** @hidden */
  46053. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  46054. /**
  46055. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  46056. */
  46057. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  46058. /**
  46059. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  46060. */
  46061. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  46062. /**
  46063. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  46064. */
  46065. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  46066. /** Callback called when a pointer move is detected */
  46067. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46068. /** Callback called when a pointer down is detected */
  46069. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  46070. /** Callback called when a pointer up is detected */
  46071. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  46072. /** Callback called when a pointer pick is detected */
  46073. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  46074. /**
  46075. * 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).
  46076. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  46077. */
  46078. onPrePointerObservable: Observable<PointerInfoPre>;
  46079. /**
  46080. * Observable event triggered each time an input event is received from the rendering canvas
  46081. */
  46082. onPointerObservable: Observable<PointerInfo>;
  46083. /**
  46084. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  46085. */
  46086. get unTranslatedPointer(): Vector2;
  46087. /**
  46088. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  46089. */
  46090. static get DragMovementThreshold(): number;
  46091. static set DragMovementThreshold(value: number);
  46092. /**
  46093. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  46094. */
  46095. static get LongPressDelay(): number;
  46096. static set LongPressDelay(value: number);
  46097. /**
  46098. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  46099. */
  46100. static get DoubleClickDelay(): number;
  46101. static set DoubleClickDelay(value: number);
  46102. /** If you need to check double click without raising a single click at first click, enable this flag */
  46103. static get ExclusiveDoubleClickMode(): boolean;
  46104. static set ExclusiveDoubleClickMode(value: boolean);
  46105. /** @hidden */
  46106. _mirroredCameraPosition: Nullable<Vector3>;
  46107. /**
  46108. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  46109. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  46110. */
  46111. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  46112. /**
  46113. * Observable event triggered each time an keyboard event is received from the hosting window
  46114. */
  46115. onKeyboardObservable: Observable<KeyboardInfo>;
  46116. private _useRightHandedSystem;
  46117. /**
  46118. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  46119. */
  46120. set useRightHandedSystem(value: boolean);
  46121. get useRightHandedSystem(): boolean;
  46122. private _timeAccumulator;
  46123. private _currentStepId;
  46124. private _currentInternalStep;
  46125. /**
  46126. * Sets the step Id used by deterministic lock step
  46127. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46128. * @param newStepId defines the step Id
  46129. */
  46130. setStepId(newStepId: number): void;
  46131. /**
  46132. * Gets the step Id used by deterministic lock step
  46133. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46134. * @returns the step Id
  46135. */
  46136. getStepId(): number;
  46137. /**
  46138. * Gets the internal step used by deterministic lock step
  46139. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  46140. * @returns the internal step
  46141. */
  46142. getInternalStep(): number;
  46143. private _fogEnabled;
  46144. /**
  46145. * Gets or sets a boolean indicating if fog is enabled on this scene
  46146. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46147. * (Default is true)
  46148. */
  46149. set fogEnabled(value: boolean);
  46150. get fogEnabled(): boolean;
  46151. private _fogMode;
  46152. /**
  46153. * Gets or sets the fog mode to use
  46154. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46155. * | mode | value |
  46156. * | --- | --- |
  46157. * | FOGMODE_NONE | 0 |
  46158. * | FOGMODE_EXP | 1 |
  46159. * | FOGMODE_EXP2 | 2 |
  46160. * | FOGMODE_LINEAR | 3 |
  46161. */
  46162. set fogMode(value: number);
  46163. get fogMode(): number;
  46164. /**
  46165. * Gets or sets the fog color to use
  46166. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46167. * (Default is Color3(0.2, 0.2, 0.3))
  46168. */
  46169. fogColor: Color3;
  46170. /**
  46171. * Gets or sets the fog density to use
  46172. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46173. * (Default is 0.1)
  46174. */
  46175. fogDensity: number;
  46176. /**
  46177. * Gets or sets the fog start distance to use
  46178. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46179. * (Default is 0)
  46180. */
  46181. fogStart: number;
  46182. /**
  46183. * Gets or sets the fog end distance to use
  46184. * @see https://doc.babylonjs.com/babylon101/environment#fog
  46185. * (Default is 1000)
  46186. */
  46187. fogEnd: number;
  46188. /**
  46189. * Flag indicating that the frame buffer binding is handled by another component
  46190. */
  46191. prePass: boolean;
  46192. private _shadowsEnabled;
  46193. /**
  46194. * Gets or sets a boolean indicating if shadows are enabled on this scene
  46195. */
  46196. set shadowsEnabled(value: boolean);
  46197. get shadowsEnabled(): boolean;
  46198. private _lightsEnabled;
  46199. /**
  46200. * Gets or sets a boolean indicating if lights are enabled on this scene
  46201. */
  46202. set lightsEnabled(value: boolean);
  46203. get lightsEnabled(): boolean;
  46204. /** All of the active cameras added to this scene. */
  46205. activeCameras: Nullable<Camera[]>;
  46206. /** @hidden */
  46207. _activeCamera: Nullable<Camera>;
  46208. /** Gets or sets the current active camera */
  46209. get activeCamera(): Nullable<Camera>;
  46210. set activeCamera(value: Nullable<Camera>);
  46211. private _defaultMaterial;
  46212. /** The default material used on meshes when no material is affected */
  46213. get defaultMaterial(): Material;
  46214. /** The default material used on meshes when no material is affected */
  46215. set defaultMaterial(value: Material);
  46216. private _texturesEnabled;
  46217. /**
  46218. * Gets or sets a boolean indicating if textures are enabled on this scene
  46219. */
  46220. set texturesEnabled(value: boolean);
  46221. get texturesEnabled(): boolean;
  46222. /**
  46223. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  46224. */
  46225. physicsEnabled: boolean;
  46226. /**
  46227. * Gets or sets a boolean indicating if particles are enabled on this scene
  46228. */
  46229. particlesEnabled: boolean;
  46230. /**
  46231. * Gets or sets a boolean indicating if sprites are enabled on this scene
  46232. */
  46233. spritesEnabled: boolean;
  46234. private _skeletonsEnabled;
  46235. /**
  46236. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  46237. */
  46238. set skeletonsEnabled(value: boolean);
  46239. get skeletonsEnabled(): boolean;
  46240. /**
  46241. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  46242. */
  46243. lensFlaresEnabled: boolean;
  46244. /**
  46245. * Gets or sets a boolean indicating if collisions are enabled on this scene
  46246. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46247. */
  46248. collisionsEnabled: boolean;
  46249. private _collisionCoordinator;
  46250. /** @hidden */
  46251. get collisionCoordinator(): ICollisionCoordinator;
  46252. /**
  46253. * Defines the gravity applied to this scene (used only for collisions)
  46254. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  46255. */
  46256. gravity: Vector3;
  46257. /**
  46258. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  46259. */
  46260. postProcessesEnabled: boolean;
  46261. /**
  46262. * Gets the current postprocess manager
  46263. */
  46264. postProcessManager: PostProcessManager;
  46265. /**
  46266. * Gets or sets a boolean indicating if render targets are enabled on this scene
  46267. */
  46268. renderTargetsEnabled: boolean;
  46269. /**
  46270. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  46271. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  46272. */
  46273. dumpNextRenderTargets: boolean;
  46274. /**
  46275. * The list of user defined render targets added to the scene
  46276. */
  46277. customRenderTargets: RenderTargetTexture[];
  46278. /**
  46279. * Defines if texture loading must be delayed
  46280. * If true, textures will only be loaded when they need to be rendered
  46281. */
  46282. useDelayedTextureLoading: boolean;
  46283. /**
  46284. * Gets the list of meshes imported to the scene through SceneLoader
  46285. */
  46286. importedMeshesFiles: String[];
  46287. /**
  46288. * Gets or sets a boolean indicating if probes are enabled on this scene
  46289. */
  46290. probesEnabled: boolean;
  46291. /**
  46292. * Gets or sets the current offline provider to use to store scene data
  46293. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  46294. */
  46295. offlineProvider: IOfflineProvider;
  46296. /**
  46297. * Gets or sets the action manager associated with the scene
  46298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46299. */
  46300. actionManager: AbstractActionManager;
  46301. private _meshesForIntersections;
  46302. /**
  46303. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  46304. */
  46305. proceduralTexturesEnabled: boolean;
  46306. private _engine;
  46307. private _totalVertices;
  46308. /** @hidden */
  46309. _activeIndices: PerfCounter;
  46310. /** @hidden */
  46311. _activeParticles: PerfCounter;
  46312. /** @hidden */
  46313. _activeBones: PerfCounter;
  46314. private _animationRatio;
  46315. /** @hidden */
  46316. _animationTimeLast: number;
  46317. /** @hidden */
  46318. _animationTime: number;
  46319. /**
  46320. * Gets or sets a general scale for animation speed
  46321. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  46322. */
  46323. animationTimeScale: number;
  46324. /** @hidden */
  46325. _cachedMaterial: Nullable<Material>;
  46326. /** @hidden */
  46327. _cachedEffect: Nullable<Effect>;
  46328. /** @hidden */
  46329. _cachedVisibility: Nullable<number>;
  46330. private _renderId;
  46331. private _frameId;
  46332. private _executeWhenReadyTimeoutId;
  46333. private _intermediateRendering;
  46334. private _viewUpdateFlag;
  46335. private _projectionUpdateFlag;
  46336. /** @hidden */
  46337. _toBeDisposed: Nullable<IDisposable>[];
  46338. private _activeRequests;
  46339. /** @hidden */
  46340. _pendingData: any[];
  46341. private _isDisposed;
  46342. /**
  46343. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  46344. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  46345. */
  46346. dispatchAllSubMeshesOfActiveMeshes: boolean;
  46347. private _activeMeshes;
  46348. private _processedMaterials;
  46349. private _renderTargets;
  46350. /** @hidden */
  46351. _activeParticleSystems: SmartArray<IParticleSystem>;
  46352. private _activeSkeletons;
  46353. private _softwareSkinnedMeshes;
  46354. private _renderingManager;
  46355. /** @hidden */
  46356. _activeAnimatables: Animatable[];
  46357. private _transformMatrix;
  46358. private _sceneUbo;
  46359. /** @hidden */
  46360. _viewMatrix: Matrix;
  46361. /** @hidden */
  46362. _projectionMatrix: Matrix;
  46363. /** @hidden */
  46364. _forcedViewPosition: Nullable<Vector3>;
  46365. /** @hidden */
  46366. _frustumPlanes: Plane[];
  46367. /**
  46368. * Gets the list of frustum planes (built from the active camera)
  46369. */
  46370. get frustumPlanes(): Plane[];
  46371. /**
  46372. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  46373. * This is useful if there are more lights that the maximum simulteanous authorized
  46374. */
  46375. requireLightSorting: boolean;
  46376. /** @hidden */
  46377. readonly useMaterialMeshMap: boolean;
  46378. /** @hidden */
  46379. readonly useClonedMeshMap: boolean;
  46380. private _externalData;
  46381. private _uid;
  46382. /**
  46383. * @hidden
  46384. * Backing store of defined scene components.
  46385. */
  46386. _components: ISceneComponent[];
  46387. /**
  46388. * @hidden
  46389. * Backing store of defined scene components.
  46390. */
  46391. _serializableComponents: ISceneSerializableComponent[];
  46392. /**
  46393. * List of components to register on the next registration step.
  46394. */
  46395. private _transientComponents;
  46396. /**
  46397. * Registers the transient components if needed.
  46398. */
  46399. private _registerTransientComponents;
  46400. /**
  46401. * @hidden
  46402. * Add a component to the scene.
  46403. * Note that the ccomponent could be registered on th next frame if this is called after
  46404. * the register component stage.
  46405. * @param component Defines the component to add to the scene
  46406. */
  46407. _addComponent(component: ISceneComponent): void;
  46408. /**
  46409. * @hidden
  46410. * Gets a component from the scene.
  46411. * @param name defines the name of the component to retrieve
  46412. * @returns the component or null if not present
  46413. */
  46414. _getComponent(name: string): Nullable<ISceneComponent>;
  46415. /**
  46416. * @hidden
  46417. * Defines the actions happening before camera updates.
  46418. */
  46419. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  46420. /**
  46421. * @hidden
  46422. * Defines the actions happening before clear the canvas.
  46423. */
  46424. _beforeClearStage: Stage<SimpleStageAction>;
  46425. /**
  46426. * @hidden
  46427. * Defines the actions when collecting render targets for the frame.
  46428. */
  46429. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46430. /**
  46431. * @hidden
  46432. * Defines the actions happening for one camera in the frame.
  46433. */
  46434. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  46435. /**
  46436. * @hidden
  46437. * Defines the actions happening during the per mesh ready checks.
  46438. */
  46439. _isReadyForMeshStage: Stage<MeshStageAction>;
  46440. /**
  46441. * @hidden
  46442. * Defines the actions happening before evaluate active mesh checks.
  46443. */
  46444. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  46445. /**
  46446. * @hidden
  46447. * Defines the actions happening during the evaluate sub mesh checks.
  46448. */
  46449. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  46450. /**
  46451. * @hidden
  46452. * Defines the actions happening during the active mesh stage.
  46453. */
  46454. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  46455. /**
  46456. * @hidden
  46457. * Defines the actions happening during the per camera render target step.
  46458. */
  46459. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  46460. /**
  46461. * @hidden
  46462. * Defines the actions happening just before the active camera is drawing.
  46463. */
  46464. _beforeCameraDrawStage: Stage<CameraStageAction>;
  46465. /**
  46466. * @hidden
  46467. * Defines the actions happening just before a render target is drawing.
  46468. */
  46469. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46470. /**
  46471. * @hidden
  46472. * Defines the actions happening just before a rendering group is drawing.
  46473. */
  46474. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46475. /**
  46476. * @hidden
  46477. * Defines the actions happening just before a mesh is drawing.
  46478. */
  46479. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46480. /**
  46481. * @hidden
  46482. * Defines the actions happening just after a mesh has been drawn.
  46483. */
  46484. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  46485. /**
  46486. * @hidden
  46487. * Defines the actions happening just after a rendering group has been drawn.
  46488. */
  46489. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  46490. /**
  46491. * @hidden
  46492. * Defines the actions happening just after the active camera has been drawn.
  46493. */
  46494. _afterCameraDrawStage: Stage<CameraStageAction>;
  46495. /**
  46496. * @hidden
  46497. * Defines the actions happening just after a render target has been drawn.
  46498. */
  46499. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  46500. /**
  46501. * @hidden
  46502. * Defines the actions happening just after rendering all cameras and computing intersections.
  46503. */
  46504. _afterRenderStage: Stage<SimpleStageAction>;
  46505. /**
  46506. * @hidden
  46507. * Defines the actions happening when a pointer move event happens.
  46508. */
  46509. _pointerMoveStage: Stage<PointerMoveStageAction>;
  46510. /**
  46511. * @hidden
  46512. * Defines the actions happening when a pointer down event happens.
  46513. */
  46514. _pointerDownStage: Stage<PointerUpDownStageAction>;
  46515. /**
  46516. * @hidden
  46517. * Defines the actions happening when a pointer up event happens.
  46518. */
  46519. _pointerUpStage: Stage<PointerUpDownStageAction>;
  46520. /**
  46521. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  46522. */
  46523. private geometriesByUniqueId;
  46524. private _renderBundles;
  46525. /**
  46526. * Creates a new Scene
  46527. * @param engine defines the engine to use to render this scene
  46528. * @param options defines the scene options
  46529. */
  46530. constructor(engine: Engine, options?: SceneOptions);
  46531. /**
  46532. * Gets a string identifying the name of the class
  46533. * @returns "Scene" string
  46534. */
  46535. getClassName(): string;
  46536. private _defaultMeshCandidates;
  46537. /**
  46538. * @hidden
  46539. */
  46540. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  46541. private _defaultSubMeshCandidates;
  46542. /**
  46543. * @hidden
  46544. */
  46545. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  46546. /**
  46547. * Sets the default candidate providers for the scene.
  46548. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  46549. * and getCollidingSubMeshCandidates to their default function
  46550. */
  46551. setDefaultCandidateProviders(): void;
  46552. /**
  46553. * Gets the mesh that is currently under the pointer
  46554. */
  46555. get meshUnderPointer(): Nullable<AbstractMesh>;
  46556. /**
  46557. * Gets or sets the current on-screen X position of the pointer
  46558. */
  46559. get pointerX(): number;
  46560. set pointerX(value: number);
  46561. /**
  46562. * Gets or sets the current on-screen Y position of the pointer
  46563. */
  46564. get pointerY(): number;
  46565. set pointerY(value: number);
  46566. /**
  46567. * Gets the cached material (ie. the latest rendered one)
  46568. * @returns the cached material
  46569. */
  46570. getCachedMaterial(): Nullable<Material>;
  46571. /**
  46572. * Gets the cached effect (ie. the latest rendered one)
  46573. * @returns the cached effect
  46574. */
  46575. getCachedEffect(): Nullable<Effect>;
  46576. /**
  46577. * Gets the cached visibility state (ie. the latest rendered one)
  46578. * @returns the cached visibility state
  46579. */
  46580. getCachedVisibility(): Nullable<number>;
  46581. /**
  46582. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  46583. * @param material defines the current material
  46584. * @param effect defines the current effect
  46585. * @param visibility defines the current visibility state
  46586. * @returns true if one parameter is not cached
  46587. */
  46588. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  46589. /**
  46590. * Gets the engine associated with the scene
  46591. * @returns an Engine
  46592. */
  46593. getEngine(): Engine;
  46594. /**
  46595. * Gets the total number of vertices rendered per frame
  46596. * @returns the total number of vertices rendered per frame
  46597. */
  46598. getTotalVertices(): number;
  46599. /**
  46600. * Gets the performance counter for total vertices
  46601. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46602. */
  46603. get totalVerticesPerfCounter(): PerfCounter;
  46604. /**
  46605. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  46606. * @returns the total number of active indices rendered per frame
  46607. */
  46608. getActiveIndices(): number;
  46609. /**
  46610. * Gets the performance counter for active indices
  46611. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46612. */
  46613. get totalActiveIndicesPerfCounter(): PerfCounter;
  46614. /**
  46615. * Gets the total number of active particles rendered per frame
  46616. * @returns the total number of active particles rendered per frame
  46617. */
  46618. getActiveParticles(): number;
  46619. /**
  46620. * Gets the performance counter for active particles
  46621. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46622. */
  46623. get activeParticlesPerfCounter(): PerfCounter;
  46624. /**
  46625. * Gets the total number of active bones rendered per frame
  46626. * @returns the total number of active bones rendered per frame
  46627. */
  46628. getActiveBones(): number;
  46629. /**
  46630. * Gets the performance counter for active bones
  46631. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  46632. */
  46633. get activeBonesPerfCounter(): PerfCounter;
  46634. /**
  46635. * Gets the array of active meshes
  46636. * @returns an array of AbstractMesh
  46637. */
  46638. getActiveMeshes(): SmartArray<AbstractMesh>;
  46639. /**
  46640. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  46641. * @returns a number
  46642. */
  46643. getAnimationRatio(): number;
  46644. /**
  46645. * Gets an unique Id for the current render phase
  46646. * @returns a number
  46647. */
  46648. getRenderId(): number;
  46649. /**
  46650. * Gets an unique Id for the current frame
  46651. * @returns a number
  46652. */
  46653. getFrameId(): number;
  46654. /** Call this function if you want to manually increment the render Id*/
  46655. incrementRenderId(): void;
  46656. private _createUbo;
  46657. /**
  46658. * Use this method to simulate a pointer move on a mesh
  46659. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46660. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46661. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46662. * @returns the current scene
  46663. */
  46664. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46665. /**
  46666. * Use this method to simulate a pointer down on a mesh
  46667. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46668. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46669. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46670. * @returns the current scene
  46671. */
  46672. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  46673. /**
  46674. * Use this method to simulate a pointer up on a mesh
  46675. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  46676. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  46677. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  46678. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  46679. * @returns the current scene
  46680. */
  46681. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  46682. /**
  46683. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  46684. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  46685. * @returns true if the pointer was captured
  46686. */
  46687. isPointerCaptured(pointerId?: number): boolean;
  46688. /**
  46689. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  46690. * @param attachUp defines if you want to attach events to pointerup
  46691. * @param attachDown defines if you want to attach events to pointerdown
  46692. * @param attachMove defines if you want to attach events to pointermove
  46693. */
  46694. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  46695. /** Detaches all event handlers*/
  46696. detachControl(): void;
  46697. /**
  46698. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  46699. * Delay loaded resources are not taking in account
  46700. * @return true if all required resources are ready
  46701. */
  46702. isReady(): boolean;
  46703. /** Resets all cached information relative to material (including effect and visibility) */
  46704. resetCachedMaterial(): void;
  46705. /**
  46706. * Registers a function to be called before every frame render
  46707. * @param func defines the function to register
  46708. */
  46709. registerBeforeRender(func: () => void): void;
  46710. /**
  46711. * Unregisters a function called before every frame render
  46712. * @param func defines the function to unregister
  46713. */
  46714. unregisterBeforeRender(func: () => void): void;
  46715. /**
  46716. * Registers a function to be called after every frame render
  46717. * @param func defines the function to register
  46718. */
  46719. registerAfterRender(func: () => void): void;
  46720. /**
  46721. * Unregisters a function called after every frame render
  46722. * @param func defines the function to unregister
  46723. */
  46724. unregisterAfterRender(func: () => void): void;
  46725. private _executeOnceBeforeRender;
  46726. /**
  46727. * The provided function will run before render once and will be disposed afterwards.
  46728. * A timeout delay can be provided so that the function will be executed in N ms.
  46729. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  46730. * @param func The function to be executed.
  46731. * @param timeout optional delay in ms
  46732. */
  46733. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  46734. /** @hidden */
  46735. _addPendingData(data: any): void;
  46736. /** @hidden */
  46737. _removePendingData(data: any): void;
  46738. /**
  46739. * Returns the number of items waiting to be loaded
  46740. * @returns the number of items waiting to be loaded
  46741. */
  46742. getWaitingItemsCount(): number;
  46743. /**
  46744. * Returns a boolean indicating if the scene is still loading data
  46745. */
  46746. get isLoading(): boolean;
  46747. /**
  46748. * Registers a function to be executed when the scene is ready
  46749. * @param {Function} func - the function to be executed
  46750. */
  46751. executeWhenReady(func: () => void): void;
  46752. /**
  46753. * Returns a promise that resolves when the scene is ready
  46754. * @returns A promise that resolves when the scene is ready
  46755. */
  46756. whenReadyAsync(): Promise<void>;
  46757. /** @hidden */
  46758. _checkIsReady(): void;
  46759. /**
  46760. * Gets all animatable attached to the scene
  46761. */
  46762. get animatables(): Animatable[];
  46763. /**
  46764. * Resets the last animation time frame.
  46765. * Useful to override when animations start running when loading a scene for the first time.
  46766. */
  46767. resetLastAnimationTimeFrame(): void;
  46768. /**
  46769. * Gets the current view matrix
  46770. * @returns a Matrix
  46771. */
  46772. getViewMatrix(): Matrix;
  46773. /**
  46774. * Gets the current projection matrix
  46775. * @returns a Matrix
  46776. */
  46777. getProjectionMatrix(): Matrix;
  46778. /**
  46779. * Gets the current transform matrix
  46780. * @returns a Matrix made of View * Projection
  46781. */
  46782. getTransformMatrix(): Matrix;
  46783. /**
  46784. * Sets the current transform matrix
  46785. * @param viewL defines the View matrix to use
  46786. * @param projectionL defines the Projection matrix to use
  46787. * @param viewR defines the right View matrix to use (if provided)
  46788. * @param projectionR defines the right Projection matrix to use (if provided)
  46789. */
  46790. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  46791. /**
  46792. * Gets the uniform buffer used to store scene data
  46793. * @returns a UniformBuffer
  46794. */
  46795. getSceneUniformBuffer(): UniformBuffer;
  46796. /**
  46797. * Gets an unique (relatively to the current scene) Id
  46798. * @returns an unique number for the scene
  46799. */
  46800. getUniqueId(): number;
  46801. /**
  46802. * Add a mesh to the list of scene's meshes
  46803. * @param newMesh defines the mesh to add
  46804. * @param recursive if all child meshes should also be added to the scene
  46805. */
  46806. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  46807. /**
  46808. * Remove a mesh for the list of scene's meshes
  46809. * @param toRemove defines the mesh to remove
  46810. * @param recursive if all child meshes should also be removed from the scene
  46811. * @returns the index where the mesh was in the mesh list
  46812. */
  46813. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  46814. /**
  46815. * Add a transform node to the list of scene's transform nodes
  46816. * @param newTransformNode defines the transform node to add
  46817. */
  46818. addTransformNode(newTransformNode: TransformNode): void;
  46819. /**
  46820. * Remove a transform node for the list of scene's transform nodes
  46821. * @param toRemove defines the transform node to remove
  46822. * @returns the index where the transform node was in the transform node list
  46823. */
  46824. removeTransformNode(toRemove: TransformNode): number;
  46825. /**
  46826. * Remove a skeleton for the list of scene's skeletons
  46827. * @param toRemove defines the skeleton to remove
  46828. * @returns the index where the skeleton was in the skeleton list
  46829. */
  46830. removeSkeleton(toRemove: Skeleton): number;
  46831. /**
  46832. * Remove a morph target for the list of scene's morph targets
  46833. * @param toRemove defines the morph target to remove
  46834. * @returns the index where the morph target was in the morph target list
  46835. */
  46836. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  46837. /**
  46838. * Remove a light for the list of scene's lights
  46839. * @param toRemove defines the light to remove
  46840. * @returns the index where the light was in the light list
  46841. */
  46842. removeLight(toRemove: Light): number;
  46843. /**
  46844. * Remove a camera for the list of scene's cameras
  46845. * @param toRemove defines the camera to remove
  46846. * @returns the index where the camera was in the camera list
  46847. */
  46848. removeCamera(toRemove: Camera): number;
  46849. /**
  46850. * Remove a particle system for the list of scene's particle systems
  46851. * @param toRemove defines the particle system to remove
  46852. * @returns the index where the particle system was in the particle system list
  46853. */
  46854. removeParticleSystem(toRemove: IParticleSystem): number;
  46855. /**
  46856. * Remove a animation for the list of scene's animations
  46857. * @param toRemove defines the animation to remove
  46858. * @returns the index where the animation was in the animation list
  46859. */
  46860. removeAnimation(toRemove: Animation): number;
  46861. /**
  46862. * Will stop the animation of the given target
  46863. * @param target - the target
  46864. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  46865. * @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)
  46866. */
  46867. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  46868. /**
  46869. * Removes the given animation group from this scene.
  46870. * @param toRemove The animation group to remove
  46871. * @returns The index of the removed animation group
  46872. */
  46873. removeAnimationGroup(toRemove: AnimationGroup): number;
  46874. /**
  46875. * Removes the given multi-material from this scene.
  46876. * @param toRemove The multi-material to remove
  46877. * @returns The index of the removed multi-material
  46878. */
  46879. removeMultiMaterial(toRemove: MultiMaterial): number;
  46880. /**
  46881. * Removes the given material from this scene.
  46882. * @param toRemove The material to remove
  46883. * @returns The index of the removed material
  46884. */
  46885. removeMaterial(toRemove: Material): number;
  46886. /**
  46887. * Removes the given action manager from this scene.
  46888. * @param toRemove The action manager to remove
  46889. * @returns The index of the removed action manager
  46890. */
  46891. removeActionManager(toRemove: AbstractActionManager): number;
  46892. /**
  46893. * Removes the given texture from this scene.
  46894. * @param toRemove The texture to remove
  46895. * @returns The index of the removed texture
  46896. */
  46897. removeTexture(toRemove: BaseTexture): number;
  46898. /**
  46899. * Adds the given light to this scene
  46900. * @param newLight The light to add
  46901. */
  46902. addLight(newLight: Light): void;
  46903. /**
  46904. * Sorts the list list based on light priorities
  46905. */
  46906. sortLightsByPriority(): void;
  46907. /**
  46908. * Adds the given camera to this scene
  46909. * @param newCamera The camera to add
  46910. */
  46911. addCamera(newCamera: Camera): void;
  46912. /**
  46913. * Adds the given skeleton to this scene
  46914. * @param newSkeleton The skeleton to add
  46915. */
  46916. addSkeleton(newSkeleton: Skeleton): void;
  46917. /**
  46918. * Adds the given particle system to this scene
  46919. * @param newParticleSystem The particle system to add
  46920. */
  46921. addParticleSystem(newParticleSystem: IParticleSystem): void;
  46922. /**
  46923. * Adds the given animation to this scene
  46924. * @param newAnimation The animation to add
  46925. */
  46926. addAnimation(newAnimation: Animation): void;
  46927. /**
  46928. * Adds the given animation group to this scene.
  46929. * @param newAnimationGroup The animation group to add
  46930. */
  46931. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  46932. /**
  46933. * Adds the given multi-material to this scene
  46934. * @param newMultiMaterial The multi-material to add
  46935. */
  46936. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  46937. /**
  46938. * Adds the given material to this scene
  46939. * @param newMaterial The material to add
  46940. */
  46941. addMaterial(newMaterial: Material): void;
  46942. /**
  46943. * Adds the given morph target to this scene
  46944. * @param newMorphTargetManager The morph target to add
  46945. */
  46946. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  46947. /**
  46948. * Adds the given geometry to this scene
  46949. * @param newGeometry The geometry to add
  46950. */
  46951. addGeometry(newGeometry: Geometry): void;
  46952. /**
  46953. * Adds the given action manager to this scene
  46954. * @param newActionManager The action manager to add
  46955. */
  46956. addActionManager(newActionManager: AbstractActionManager): void;
  46957. /**
  46958. * Adds the given texture to this scene.
  46959. * @param newTexture The texture to add
  46960. */
  46961. addTexture(newTexture: BaseTexture): void;
  46962. /**
  46963. * Switch active camera
  46964. * @param newCamera defines the new active camera
  46965. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  46966. */
  46967. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  46968. /**
  46969. * sets the active camera of the scene using its ID
  46970. * @param id defines the camera's ID
  46971. * @return the new active camera or null if none found.
  46972. */
  46973. setActiveCameraByID(id: string): Nullable<Camera>;
  46974. /**
  46975. * sets the active camera of the scene using its name
  46976. * @param name defines the camera's name
  46977. * @returns the new active camera or null if none found.
  46978. */
  46979. setActiveCameraByName(name: string): Nullable<Camera>;
  46980. /**
  46981. * get an animation group using its name
  46982. * @param name defines the material's name
  46983. * @return the animation group or null if none found.
  46984. */
  46985. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  46986. /**
  46987. * Get a material using its unique id
  46988. * @param uniqueId defines the material's unique id
  46989. * @return the material or null if none found.
  46990. */
  46991. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  46992. /**
  46993. * get a material using its id
  46994. * @param id defines the material's ID
  46995. * @return the material or null if none found.
  46996. */
  46997. getMaterialByID(id: string): Nullable<Material>;
  46998. /**
  46999. * Gets a the last added material using a given id
  47000. * @param id defines the material's ID
  47001. * @return the last material with the given id or null if none found.
  47002. */
  47003. getLastMaterialByID(id: string): Nullable<Material>;
  47004. /**
  47005. * Gets a material using its name
  47006. * @param name defines the material's name
  47007. * @return the material or null if none found.
  47008. */
  47009. getMaterialByName(name: string): Nullable<Material>;
  47010. /**
  47011. * Get a texture using its unique id
  47012. * @param uniqueId defines the texture's unique id
  47013. * @return the texture or null if none found.
  47014. */
  47015. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  47016. /**
  47017. * Gets a camera using its id
  47018. * @param id defines the id to look for
  47019. * @returns the camera or null if not found
  47020. */
  47021. getCameraByID(id: string): Nullable<Camera>;
  47022. /**
  47023. * Gets a camera using its unique id
  47024. * @param uniqueId defines the unique id to look for
  47025. * @returns the camera or null if not found
  47026. */
  47027. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  47028. /**
  47029. * Gets a camera using its name
  47030. * @param name defines the camera's name
  47031. * @return the camera or null if none found.
  47032. */
  47033. getCameraByName(name: string): Nullable<Camera>;
  47034. /**
  47035. * Gets a bone using its id
  47036. * @param id defines the bone's id
  47037. * @return the bone or null if not found
  47038. */
  47039. getBoneByID(id: string): Nullable<Bone>;
  47040. /**
  47041. * Gets a bone using its id
  47042. * @param name defines the bone's name
  47043. * @return the bone or null if not found
  47044. */
  47045. getBoneByName(name: string): Nullable<Bone>;
  47046. /**
  47047. * Gets a light node using its name
  47048. * @param name defines the the light's name
  47049. * @return the light or null if none found.
  47050. */
  47051. getLightByName(name: string): Nullable<Light>;
  47052. /**
  47053. * Gets a light node using its id
  47054. * @param id defines the light's id
  47055. * @return the light or null if none found.
  47056. */
  47057. getLightByID(id: string): Nullable<Light>;
  47058. /**
  47059. * Gets a light node using its scene-generated unique ID
  47060. * @param uniqueId defines the light's unique id
  47061. * @return the light or null if none found.
  47062. */
  47063. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  47064. /**
  47065. * Gets a particle system by id
  47066. * @param id defines the particle system id
  47067. * @return the corresponding system or null if none found
  47068. */
  47069. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  47070. /**
  47071. * Gets a geometry using its ID
  47072. * @param id defines the geometry's id
  47073. * @return the geometry or null if none found.
  47074. */
  47075. getGeometryByID(id: string): Nullable<Geometry>;
  47076. private _getGeometryByUniqueID;
  47077. /**
  47078. * Add a new geometry to this scene
  47079. * @param geometry defines the geometry to be added to the scene.
  47080. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  47081. * @return a boolean defining if the geometry was added or not
  47082. */
  47083. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  47084. /**
  47085. * Removes an existing geometry
  47086. * @param geometry defines the geometry to be removed from the scene
  47087. * @return a boolean defining if the geometry was removed or not
  47088. */
  47089. removeGeometry(geometry: Geometry): boolean;
  47090. /**
  47091. * Gets the list of geometries attached to the scene
  47092. * @returns an array of Geometry
  47093. */
  47094. getGeometries(): Geometry[];
  47095. /**
  47096. * Gets the first added mesh found of a given ID
  47097. * @param id defines the id to search for
  47098. * @return the mesh found or null if not found at all
  47099. */
  47100. getMeshByID(id: string): Nullable<AbstractMesh>;
  47101. /**
  47102. * Gets a list of meshes using their id
  47103. * @param id defines the id to search for
  47104. * @returns a list of meshes
  47105. */
  47106. getMeshesByID(id: string): Array<AbstractMesh>;
  47107. /**
  47108. * Gets the first added transform node found of a given ID
  47109. * @param id defines the id to search for
  47110. * @return the found transform node or null if not found at all.
  47111. */
  47112. getTransformNodeByID(id: string): Nullable<TransformNode>;
  47113. /**
  47114. * Gets a transform node with its auto-generated unique id
  47115. * @param uniqueId efines the unique id to search for
  47116. * @return the found transform node or null if not found at all.
  47117. */
  47118. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  47119. /**
  47120. * Gets a list of transform nodes using their id
  47121. * @param id defines the id to search for
  47122. * @returns a list of transform nodes
  47123. */
  47124. getTransformNodesByID(id: string): Array<TransformNode>;
  47125. /**
  47126. * Gets a mesh with its auto-generated unique id
  47127. * @param uniqueId defines the unique id to search for
  47128. * @return the found mesh or null if not found at all.
  47129. */
  47130. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  47131. /**
  47132. * Gets a the last added mesh using a given id
  47133. * @param id defines the id to search for
  47134. * @return the found mesh or null if not found at all.
  47135. */
  47136. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  47137. /**
  47138. * Gets a the last added node (Mesh, Camera, Light) using a given id
  47139. * @param id defines the id to search for
  47140. * @return the found node or null if not found at all
  47141. */
  47142. getLastEntryByID(id: string): Nullable<Node>;
  47143. /**
  47144. * Gets a node (Mesh, Camera, Light) using a given id
  47145. * @param id defines the id to search for
  47146. * @return the found node or null if not found at all
  47147. */
  47148. getNodeByID(id: string): Nullable<Node>;
  47149. /**
  47150. * Gets a node (Mesh, Camera, Light) using a given name
  47151. * @param name defines the name to search for
  47152. * @return the found node or null if not found at all.
  47153. */
  47154. getNodeByName(name: string): Nullable<Node>;
  47155. /**
  47156. * Gets a mesh using a given name
  47157. * @param name defines the name to search for
  47158. * @return the found mesh or null if not found at all.
  47159. */
  47160. getMeshByName(name: string): Nullable<AbstractMesh>;
  47161. /**
  47162. * Gets a transform node using a given name
  47163. * @param name defines the name to search for
  47164. * @return the found transform node or null if not found at all.
  47165. */
  47166. getTransformNodeByName(name: string): Nullable<TransformNode>;
  47167. /**
  47168. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  47169. * @param id defines the id to search for
  47170. * @return the found skeleton or null if not found at all.
  47171. */
  47172. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  47173. /**
  47174. * Gets a skeleton using a given auto generated unique id
  47175. * @param uniqueId defines the unique id to search for
  47176. * @return the found skeleton or null if not found at all.
  47177. */
  47178. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  47179. /**
  47180. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  47181. * @param id defines the id to search for
  47182. * @return the found skeleton or null if not found at all.
  47183. */
  47184. getSkeletonById(id: string): Nullable<Skeleton>;
  47185. /**
  47186. * Gets a skeleton using a given name
  47187. * @param name defines the name to search for
  47188. * @return the found skeleton or null if not found at all.
  47189. */
  47190. getSkeletonByName(name: string): Nullable<Skeleton>;
  47191. /**
  47192. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  47193. * @param id defines the id to search for
  47194. * @return the found morph target manager or null if not found at all.
  47195. */
  47196. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  47197. /**
  47198. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  47199. * @param id defines the id to search for
  47200. * @return the found morph target or null if not found at all.
  47201. */
  47202. getMorphTargetById(id: string): Nullable<MorphTarget>;
  47203. /**
  47204. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  47205. * @param name defines the name to search for
  47206. * @return the found morph target or null if not found at all.
  47207. */
  47208. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  47209. /**
  47210. * Gets a post process using a given name (if many are found, this function will pick the first one)
  47211. * @param name defines the name to search for
  47212. * @return the found post process or null if not found at all.
  47213. */
  47214. getPostProcessByName(name: string): Nullable<PostProcess>;
  47215. /**
  47216. * Gets a boolean indicating if the given mesh is active
  47217. * @param mesh defines the mesh to look for
  47218. * @returns true if the mesh is in the active list
  47219. */
  47220. isActiveMesh(mesh: AbstractMesh): boolean;
  47221. /**
  47222. * Return a unique id as a string which can serve as an identifier for the scene
  47223. */
  47224. get uid(): string;
  47225. /**
  47226. * Add an externaly attached data from its key.
  47227. * This method call will fail and return false, if such key already exists.
  47228. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  47229. * @param key the unique key that identifies the data
  47230. * @param data the data object to associate to the key for this Engine instance
  47231. * @return true if no such key were already present and the data was added successfully, false otherwise
  47232. */
  47233. addExternalData<T>(key: string, data: T): boolean;
  47234. /**
  47235. * Get an externaly attached data from its key
  47236. * @param key the unique key that identifies the data
  47237. * @return the associated data, if present (can be null), or undefined if not present
  47238. */
  47239. getExternalData<T>(key: string): Nullable<T>;
  47240. /**
  47241. * Get an externaly attached data from its key, create it using a factory if it's not already present
  47242. * @param key the unique key that identifies the data
  47243. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  47244. * @return the associated data, can be null if the factory returned null.
  47245. */
  47246. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  47247. /**
  47248. * Remove an externaly attached data from the Engine instance
  47249. * @param key the unique key that identifies the data
  47250. * @return true if the data was successfully removed, false if it doesn't exist
  47251. */
  47252. removeExternalData(key: string): boolean;
  47253. private _evaluateSubMesh;
  47254. /**
  47255. * Clear the processed materials smart array preventing retention point in material dispose.
  47256. */
  47257. freeProcessedMaterials(): void;
  47258. private _preventFreeActiveMeshesAndRenderingGroups;
  47259. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  47260. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  47261. * when disposing several meshes in a row or a hierarchy of meshes.
  47262. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  47263. */
  47264. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  47265. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  47266. /**
  47267. * Clear the active meshes smart array preventing retention point in mesh dispose.
  47268. */
  47269. freeActiveMeshes(): void;
  47270. /**
  47271. * Clear the info related to rendering groups preventing retention points during dispose.
  47272. */
  47273. freeRenderingGroups(): void;
  47274. /** @hidden */
  47275. _isInIntermediateRendering(): boolean;
  47276. /**
  47277. * Lambda returning the list of potentially active meshes.
  47278. */
  47279. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  47280. /**
  47281. * Lambda returning the list of potentially active sub meshes.
  47282. */
  47283. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  47284. /**
  47285. * Lambda returning the list of potentially intersecting sub meshes.
  47286. */
  47287. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  47288. /**
  47289. * Lambda returning the list of potentially colliding sub meshes.
  47290. */
  47291. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  47292. /** @hidden */
  47293. _activeMeshesFrozen: boolean;
  47294. private _skipEvaluateActiveMeshesCompletely;
  47295. /**
  47296. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  47297. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  47298. * @param onSuccess optional success callback
  47299. * @param onError optional error callback
  47300. * @returns the current scene
  47301. */
  47302. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  47303. /**
  47304. * Use this function to restart evaluating active meshes on every frame
  47305. * @returns the current scene
  47306. */
  47307. unfreezeActiveMeshes(): Scene;
  47308. private _evaluateActiveMeshes;
  47309. private _activeMesh;
  47310. /**
  47311. * Update the transform matrix to update from the current active camera
  47312. * @param force defines a boolean used to force the update even if cache is up to date
  47313. */
  47314. updateTransformMatrix(force?: boolean): void;
  47315. private _bindFrameBuffer;
  47316. /** @hidden */
  47317. _allowPostProcessClearColor: boolean;
  47318. /** @hidden */
  47319. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  47320. private _processSubCameras;
  47321. private _checkIntersections;
  47322. /** @hidden */
  47323. _advancePhysicsEngineStep(step: number): void;
  47324. /**
  47325. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  47326. */
  47327. getDeterministicFrameTime: () => number;
  47328. /** @hidden */
  47329. _animate(): void;
  47330. /** Execute all animations (for a frame) */
  47331. animate(): void;
  47332. /**
  47333. * Render the scene
  47334. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  47335. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  47336. */
  47337. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  47338. /**
  47339. * Freeze all materials
  47340. * A frozen material will not be updatable but should be faster to render
  47341. */
  47342. freezeMaterials(): void;
  47343. /**
  47344. * Unfreeze all materials
  47345. * A frozen material will not be updatable but should be faster to render
  47346. */
  47347. unfreezeMaterials(): void;
  47348. /**
  47349. * Releases all held ressources
  47350. */
  47351. dispose(): void;
  47352. /**
  47353. * Gets if the scene is already disposed
  47354. */
  47355. get isDisposed(): boolean;
  47356. /**
  47357. * Call this function to reduce memory footprint of the scene.
  47358. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  47359. */
  47360. clearCachedVertexData(): void;
  47361. /**
  47362. * This function will remove the local cached buffer data from texture.
  47363. * It will save memory but will prevent the texture from being rebuilt
  47364. */
  47365. cleanCachedTextureBuffer(): void;
  47366. /**
  47367. * Get the world extend vectors with an optional filter
  47368. *
  47369. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  47370. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  47371. */
  47372. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  47373. min: Vector3;
  47374. max: Vector3;
  47375. };
  47376. /**
  47377. * Creates a ray that can be used to pick in the scene
  47378. * @param x defines the x coordinate of the origin (on-screen)
  47379. * @param y defines the y coordinate of the origin (on-screen)
  47380. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47381. * @param camera defines the camera to use for the picking
  47382. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47383. * @returns a Ray
  47384. */
  47385. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  47386. /**
  47387. * Creates a ray that can be used to pick in the scene
  47388. * @param x defines the x coordinate of the origin (on-screen)
  47389. * @param y defines the y coordinate of the origin (on-screen)
  47390. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  47391. * @param result defines the ray where to store the picking ray
  47392. * @param camera defines the camera to use for the picking
  47393. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  47394. * @returns the current scene
  47395. */
  47396. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  47397. /**
  47398. * Creates a ray that can be used to pick in the scene
  47399. * @param x defines the x coordinate of the origin (on-screen)
  47400. * @param y defines the y coordinate of the origin (on-screen)
  47401. * @param camera defines the camera to use for the picking
  47402. * @returns a Ray
  47403. */
  47404. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  47405. /**
  47406. * Creates a ray that can be used to pick in the scene
  47407. * @param x defines the x coordinate of the origin (on-screen)
  47408. * @param y defines the y coordinate of the origin (on-screen)
  47409. * @param result defines the ray where to store the picking ray
  47410. * @param camera defines the camera to use for the picking
  47411. * @returns the current scene
  47412. */
  47413. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  47414. /** Launch a ray to try to pick a mesh in the scene
  47415. * @param x position on screen
  47416. * @param y position on screen
  47417. * @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
  47418. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47419. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47420. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47421. * @returns a PickingInfo
  47422. */
  47423. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47424. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  47425. * @param x position on screen
  47426. * @param y position on screen
  47427. * @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
  47428. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47429. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47430. * @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)
  47431. */
  47432. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  47433. /** Use the given ray to pick a mesh in the scene
  47434. * @param ray The ray to use to pick meshes
  47435. * @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
  47436. * @param fastCheck defines if the first intersection will be used (and not the closest)
  47437. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47438. * @returns a PickingInfo
  47439. */
  47440. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  47441. /**
  47442. * Launch a ray to try to pick a mesh in the scene
  47443. * @param x X position on screen
  47444. * @param y Y position on screen
  47445. * @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
  47446. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  47447. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47448. * @returns an array of PickingInfo
  47449. */
  47450. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47451. /**
  47452. * Launch a ray to try to pick a mesh in the scene
  47453. * @param ray Ray to use
  47454. * @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
  47455. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  47456. * @returns an array of PickingInfo
  47457. */
  47458. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  47459. /**
  47460. * Force the value of meshUnderPointer
  47461. * @param mesh defines the mesh to use
  47462. * @param pointerId optional pointer id when using more than one pointer
  47463. */
  47464. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  47465. /**
  47466. * Gets the mesh under the pointer
  47467. * @returns a Mesh or null if no mesh is under the pointer
  47468. */
  47469. getPointerOverMesh(): Nullable<AbstractMesh>;
  47470. /** @hidden */
  47471. _rebuildGeometries(): void;
  47472. /** @hidden */
  47473. _rebuildTextures(): void;
  47474. private _getByTags;
  47475. /**
  47476. * Get a list of meshes by tags
  47477. * @param tagsQuery defines the tags query to use
  47478. * @param forEach defines a predicate used to filter results
  47479. * @returns an array of Mesh
  47480. */
  47481. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  47482. /**
  47483. * Get a list of cameras by tags
  47484. * @param tagsQuery defines the tags query to use
  47485. * @param forEach defines a predicate used to filter results
  47486. * @returns an array of Camera
  47487. */
  47488. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  47489. /**
  47490. * Get a list of lights by tags
  47491. * @param tagsQuery defines the tags query to use
  47492. * @param forEach defines a predicate used to filter results
  47493. * @returns an array of Light
  47494. */
  47495. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  47496. /**
  47497. * Get a list of materials by tags
  47498. * @param tagsQuery defines the tags query to use
  47499. * @param forEach defines a predicate used to filter results
  47500. * @returns an array of Material
  47501. */
  47502. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  47503. /**
  47504. * Get a list of transform nodes by tags
  47505. * @param tagsQuery defines the tags query to use
  47506. * @param forEach defines a predicate used to filter results
  47507. * @returns an array of TransformNode
  47508. */
  47509. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  47510. /**
  47511. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  47512. * This allowed control for front to back rendering or reversly depending of the special needs.
  47513. *
  47514. * @param renderingGroupId The rendering group id corresponding to its index
  47515. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  47516. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  47517. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  47518. */
  47519. 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;
  47520. /**
  47521. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  47522. *
  47523. * @param renderingGroupId The rendering group id corresponding to its index
  47524. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  47525. * @param depth Automatically clears depth between groups if true and autoClear is true.
  47526. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  47527. */
  47528. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  47529. /**
  47530. * Gets the current auto clear configuration for one rendering group of the rendering
  47531. * manager.
  47532. * @param index the rendering group index to get the information for
  47533. * @returns The auto clear setup for the requested rendering group
  47534. */
  47535. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  47536. private _blockMaterialDirtyMechanism;
  47537. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  47538. get blockMaterialDirtyMechanism(): boolean;
  47539. set blockMaterialDirtyMechanism(value: boolean);
  47540. /**
  47541. * Will flag all materials as dirty to trigger new shader compilation
  47542. * @param flag defines the flag used to specify which material part must be marked as dirty
  47543. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  47544. */
  47545. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  47546. /** @hidden */
  47547. _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;
  47548. /** @hidden */
  47549. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47550. /** @hidden */
  47551. _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;
  47552. /** @hidden */
  47553. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  47554. /** @hidden */
  47555. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  47556. /** @hidden */
  47557. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  47558. }
  47559. }
  47560. declare module BABYLON {
  47561. /**
  47562. * Set of assets to keep when moving a scene into an asset container.
  47563. */
  47564. export class KeepAssets extends AbstractScene {
  47565. }
  47566. /**
  47567. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  47568. */
  47569. export class InstantiatedEntries {
  47570. /**
  47571. * List of new root nodes (eg. nodes with no parent)
  47572. */
  47573. rootNodes: TransformNode[];
  47574. /**
  47575. * List of new skeletons
  47576. */
  47577. skeletons: Skeleton[];
  47578. /**
  47579. * List of new animation groups
  47580. */
  47581. animationGroups: AnimationGroup[];
  47582. }
  47583. /**
  47584. * Container with a set of assets that can be added or removed from a scene.
  47585. */
  47586. export class AssetContainer extends AbstractScene {
  47587. private _wasAddedToScene;
  47588. /**
  47589. * The scene the AssetContainer belongs to.
  47590. */
  47591. scene: Scene;
  47592. /**
  47593. * Instantiates an AssetContainer.
  47594. * @param scene The scene the AssetContainer belongs to.
  47595. */
  47596. constructor(scene: Scene);
  47597. /**
  47598. * Instantiate or clone all meshes and add the new ones to the scene.
  47599. * Skeletons and animation groups will all be cloned
  47600. * @param nameFunction defines an optional function used to get new names for clones
  47601. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  47602. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  47603. */
  47604. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  47605. /**
  47606. * Adds all the assets from the container to the scene.
  47607. */
  47608. addAllToScene(): void;
  47609. /**
  47610. * Removes all the assets in the container from the scene
  47611. */
  47612. removeAllFromScene(): void;
  47613. /**
  47614. * Disposes all the assets in the container
  47615. */
  47616. dispose(): void;
  47617. private _moveAssets;
  47618. /**
  47619. * Removes all the assets contained in the scene and adds them to the container.
  47620. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  47621. */
  47622. moveAllFromScene(keepAssets?: KeepAssets): void;
  47623. /**
  47624. * 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.
  47625. * @returns the root mesh
  47626. */
  47627. createRootMesh(): Mesh;
  47628. /**
  47629. * Merge animations (direct and animation groups) from this asset container into a scene
  47630. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  47631. * @param animatables set of animatables to retarget to a node from the scene
  47632. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  47633. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  47634. */
  47635. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  47636. }
  47637. }
  47638. declare module BABYLON {
  47639. /**
  47640. * Defines how the parser contract is defined.
  47641. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  47642. */
  47643. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  47644. /**
  47645. * Defines how the individual parser contract is defined.
  47646. * These parser can parse an individual asset
  47647. */
  47648. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  47649. /**
  47650. * Base class of the scene acting as a container for the different elements composing a scene.
  47651. * This class is dynamically extended by the different components of the scene increasing
  47652. * flexibility and reducing coupling
  47653. */
  47654. export abstract class AbstractScene {
  47655. /**
  47656. * Stores the list of available parsers in the application.
  47657. */
  47658. private static _BabylonFileParsers;
  47659. /**
  47660. * Stores the list of available individual parsers in the application.
  47661. */
  47662. private static _IndividualBabylonFileParsers;
  47663. /**
  47664. * Adds a parser in the list of available ones
  47665. * @param name Defines the name of the parser
  47666. * @param parser Defines the parser to add
  47667. */
  47668. static AddParser(name: string, parser: BabylonFileParser): void;
  47669. /**
  47670. * Gets a general parser from the list of avaialble ones
  47671. * @param name Defines the name of the parser
  47672. * @returns the requested parser or null
  47673. */
  47674. static GetParser(name: string): Nullable<BabylonFileParser>;
  47675. /**
  47676. * Adds n individual parser in the list of available ones
  47677. * @param name Defines the name of the parser
  47678. * @param parser Defines the parser to add
  47679. */
  47680. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  47681. /**
  47682. * Gets an individual parser from the list of avaialble ones
  47683. * @param name Defines the name of the parser
  47684. * @returns the requested parser or null
  47685. */
  47686. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  47687. /**
  47688. * Parser json data and populate both a scene and its associated container object
  47689. * @param jsonData Defines the data to parse
  47690. * @param scene Defines the scene to parse the data for
  47691. * @param container Defines the container attached to the parsing sequence
  47692. * @param rootUrl Defines the root url of the data
  47693. */
  47694. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  47695. /**
  47696. * Gets the list of root nodes (ie. nodes with no parent)
  47697. */
  47698. rootNodes: Node[];
  47699. /** All of the cameras added to this scene
  47700. * @see https://doc.babylonjs.com/babylon101/cameras
  47701. */
  47702. cameras: Camera[];
  47703. /**
  47704. * All of the lights added to this scene
  47705. * @see https://doc.babylonjs.com/babylon101/lights
  47706. */
  47707. lights: Light[];
  47708. /**
  47709. * All of the (abstract) meshes added to this scene
  47710. */
  47711. meshes: AbstractMesh[];
  47712. /**
  47713. * The list of skeletons added to the scene
  47714. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  47715. */
  47716. skeletons: Skeleton[];
  47717. /**
  47718. * All of the particle systems added to this scene
  47719. * @see https://doc.babylonjs.com/babylon101/particles
  47720. */
  47721. particleSystems: IParticleSystem[];
  47722. /**
  47723. * Gets a list of Animations associated with the scene
  47724. */
  47725. animations: Animation[];
  47726. /**
  47727. * All of the animation groups added to this scene
  47728. * @see https://doc.babylonjs.com/how_to/group
  47729. */
  47730. animationGroups: AnimationGroup[];
  47731. /**
  47732. * All of the multi-materials added to this scene
  47733. * @see https://doc.babylonjs.com/how_to/multi_materials
  47734. */
  47735. multiMaterials: MultiMaterial[];
  47736. /**
  47737. * All of the materials added to this scene
  47738. * In the context of a Scene, it is not supposed to be modified manually.
  47739. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  47740. * Note also that the order of the Material within the array is not significant and might change.
  47741. * @see https://doc.babylonjs.com/babylon101/materials
  47742. */
  47743. materials: Material[];
  47744. /**
  47745. * The list of morph target managers added to the scene
  47746. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  47747. */
  47748. morphTargetManagers: MorphTargetManager[];
  47749. /**
  47750. * The list of geometries used in the scene.
  47751. */
  47752. geometries: Geometry[];
  47753. /**
  47754. * All of the tranform nodes added to this scene
  47755. * In the context of a Scene, it is not supposed to be modified manually.
  47756. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  47757. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  47758. * @see https://doc.babylonjs.com/how_to/transformnode
  47759. */
  47760. transformNodes: TransformNode[];
  47761. /**
  47762. * ActionManagers available on the scene.
  47763. */
  47764. actionManagers: AbstractActionManager[];
  47765. /**
  47766. * Textures to keep.
  47767. */
  47768. textures: BaseTexture[];
  47769. /** @hidden */
  47770. protected _environmentTexture: Nullable<BaseTexture>;
  47771. /**
  47772. * Texture used in all pbr material as the reflection texture.
  47773. * As in the majority of the scene they are the same (exception for multi room and so on),
  47774. * this is easier to reference from here than from all the materials.
  47775. */
  47776. get environmentTexture(): Nullable<BaseTexture>;
  47777. set environmentTexture(value: Nullable<BaseTexture>);
  47778. /**
  47779. * The list of postprocesses added to the scene
  47780. */
  47781. postProcesses: PostProcess[];
  47782. /**
  47783. * @returns all meshes, lights, cameras, transformNodes and bones
  47784. */
  47785. getNodes(): Array<Node>;
  47786. }
  47787. }
  47788. declare module BABYLON {
  47789. /**
  47790. * Interface used to define options for Sound class
  47791. */
  47792. export interface ISoundOptions {
  47793. /**
  47794. * Does the sound autoplay once loaded.
  47795. */
  47796. autoplay?: boolean;
  47797. /**
  47798. * Does the sound loop after it finishes playing once.
  47799. */
  47800. loop?: boolean;
  47801. /**
  47802. * Sound's volume
  47803. */
  47804. volume?: number;
  47805. /**
  47806. * Is it a spatial sound?
  47807. */
  47808. spatialSound?: boolean;
  47809. /**
  47810. * Maximum distance to hear that sound
  47811. */
  47812. maxDistance?: number;
  47813. /**
  47814. * Uses user defined attenuation function
  47815. */
  47816. useCustomAttenuation?: boolean;
  47817. /**
  47818. * Define the roll off factor of spatial sounds.
  47819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47820. */
  47821. rolloffFactor?: number;
  47822. /**
  47823. * Define the reference distance the sound should be heard perfectly.
  47824. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47825. */
  47826. refDistance?: number;
  47827. /**
  47828. * Define the distance attenuation model the sound will follow.
  47829. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47830. */
  47831. distanceModel?: string;
  47832. /**
  47833. * Defines the playback speed (1 by default)
  47834. */
  47835. playbackRate?: number;
  47836. /**
  47837. * Defines if the sound is from a streaming source
  47838. */
  47839. streaming?: boolean;
  47840. /**
  47841. * Defines an optional length (in seconds) inside the sound file
  47842. */
  47843. length?: number;
  47844. /**
  47845. * Defines an optional offset (in seconds) inside the sound file
  47846. */
  47847. offset?: number;
  47848. /**
  47849. * If true, URLs will not be required to state the audio file codec to use.
  47850. */
  47851. skipCodecCheck?: boolean;
  47852. }
  47853. }
  47854. declare module BABYLON {
  47855. /**
  47856. * Defines a sound that can be played in the application.
  47857. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  47858. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47859. */
  47860. export class Sound {
  47861. /**
  47862. * The name of the sound in the scene.
  47863. */
  47864. name: string;
  47865. /**
  47866. * Does the sound autoplay once loaded.
  47867. */
  47868. autoplay: boolean;
  47869. private _loop;
  47870. /**
  47871. * Does the sound loop after it finishes playing once.
  47872. */
  47873. get loop(): boolean;
  47874. set loop(value: boolean);
  47875. /**
  47876. * Does the sound use a custom attenuation curve to simulate the falloff
  47877. * happening when the source gets further away from the camera.
  47878. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  47879. */
  47880. useCustomAttenuation: boolean;
  47881. /**
  47882. * The sound track id this sound belongs to.
  47883. */
  47884. soundTrackId: number;
  47885. /**
  47886. * Is this sound currently played.
  47887. */
  47888. isPlaying: boolean;
  47889. /**
  47890. * Is this sound currently paused.
  47891. */
  47892. isPaused: boolean;
  47893. /**
  47894. * Does this sound enables spatial sound.
  47895. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47896. */
  47897. spatialSound: boolean;
  47898. /**
  47899. * Define the reference distance the sound should be heard perfectly.
  47900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47901. */
  47902. refDistance: number;
  47903. /**
  47904. * Define the roll off factor of spatial sounds.
  47905. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47906. */
  47907. rolloffFactor: number;
  47908. /**
  47909. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  47910. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47911. */
  47912. maxDistance: number;
  47913. /**
  47914. * Define the distance attenuation model the sound will follow.
  47915. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  47916. */
  47917. distanceModel: string;
  47918. /**
  47919. * @hidden
  47920. * Back Compat
  47921. **/
  47922. onended: () => any;
  47923. /**
  47924. * Gets or sets an object used to store user defined information for the sound.
  47925. */
  47926. metadata: any;
  47927. /**
  47928. * Observable event when the current playing sound finishes.
  47929. */
  47930. onEndedObservable: Observable<Sound>;
  47931. /**
  47932. * Gets the current time for the sound.
  47933. */
  47934. get currentTime(): number;
  47935. private _panningModel;
  47936. private _playbackRate;
  47937. private _streaming;
  47938. private _startTime;
  47939. private _startOffset;
  47940. private _position;
  47941. /** @hidden */
  47942. _positionInEmitterSpace: boolean;
  47943. private _localDirection;
  47944. private _volume;
  47945. private _isReadyToPlay;
  47946. private _isDirectional;
  47947. private _readyToPlayCallback;
  47948. private _audioBuffer;
  47949. private _soundSource;
  47950. private _streamingSource;
  47951. private _soundPanner;
  47952. private _soundGain;
  47953. private _inputAudioNode;
  47954. private _outputAudioNode;
  47955. private _coneInnerAngle;
  47956. private _coneOuterAngle;
  47957. private _coneOuterGain;
  47958. private _scene;
  47959. private _connectedTransformNode;
  47960. private _customAttenuationFunction;
  47961. private _registerFunc;
  47962. private _isOutputConnected;
  47963. private _htmlAudioElement;
  47964. private _urlType;
  47965. private _length?;
  47966. private _offset?;
  47967. /** @hidden */
  47968. static _SceneComponentInitialization: (scene: Scene) => void;
  47969. /**
  47970. * Create a sound and attach it to a scene
  47971. * @param name Name of your sound
  47972. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  47973. * @param scene defines the scene the sound belongs to
  47974. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  47975. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  47976. */
  47977. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  47978. /**
  47979. * Release the sound and its associated resources
  47980. */
  47981. dispose(): void;
  47982. /**
  47983. * Gets if the sounds is ready to be played or not.
  47984. * @returns true if ready, otherwise false
  47985. */
  47986. isReady(): boolean;
  47987. /**
  47988. * Get the current class name.
  47989. * @returns current class name
  47990. */
  47991. getClassName(): string;
  47992. private _soundLoaded;
  47993. /**
  47994. * Sets the data of the sound from an audiobuffer
  47995. * @param audioBuffer The audioBuffer containing the data
  47996. */
  47997. setAudioBuffer(audioBuffer: AudioBuffer): void;
  47998. /**
  47999. * Updates the current sounds options such as maxdistance, loop...
  48000. * @param options A JSON object containing values named as the object properties
  48001. */
  48002. updateOptions(options: ISoundOptions): void;
  48003. private _createSpatialParameters;
  48004. private _updateSpatialParameters;
  48005. /**
  48006. * Switch the panning model to HRTF:
  48007. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48008. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48009. */
  48010. switchPanningModelToHRTF(): void;
  48011. /**
  48012. * Switch the panning model to Equal Power:
  48013. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48015. */
  48016. switchPanningModelToEqualPower(): void;
  48017. private _switchPanningModel;
  48018. /**
  48019. * Connect this sound to a sound track audio node like gain...
  48020. * @param soundTrackAudioNode the sound track audio node to connect to
  48021. */
  48022. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  48023. /**
  48024. * Transform this sound into a directional source
  48025. * @param coneInnerAngle Size of the inner cone in degree
  48026. * @param coneOuterAngle Size of the outer cone in degree
  48027. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  48028. */
  48029. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  48030. /**
  48031. * Gets or sets the inner angle for the directional cone.
  48032. */
  48033. get directionalConeInnerAngle(): number;
  48034. /**
  48035. * Gets or sets the inner angle for the directional cone.
  48036. */
  48037. set directionalConeInnerAngle(value: number);
  48038. /**
  48039. * Gets or sets the outer angle for the directional cone.
  48040. */
  48041. get directionalConeOuterAngle(): number;
  48042. /**
  48043. * Gets or sets the outer angle for the directional cone.
  48044. */
  48045. set directionalConeOuterAngle(value: number);
  48046. /**
  48047. * Sets the position of the emitter if spatial sound is enabled
  48048. * @param newPosition Defines the new posisiton
  48049. */
  48050. setPosition(newPosition: Vector3): void;
  48051. /**
  48052. * Sets the local direction of the emitter if spatial sound is enabled
  48053. * @param newLocalDirection Defines the new local direction
  48054. */
  48055. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  48056. private _updateDirection;
  48057. /** @hidden */
  48058. updateDistanceFromListener(): void;
  48059. /**
  48060. * Sets a new custom attenuation function for the sound.
  48061. * @param callback Defines the function used for the attenuation
  48062. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  48063. */
  48064. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  48065. /**
  48066. * Play the sound
  48067. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  48068. * @param offset (optional) Start the sound at a specific time in seconds
  48069. * @param length (optional) Sound duration (in seconds)
  48070. */
  48071. play(time?: number, offset?: number, length?: number): void;
  48072. private _onended;
  48073. /**
  48074. * Stop the sound
  48075. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  48076. */
  48077. stop(time?: number): void;
  48078. /**
  48079. * Put the sound in pause
  48080. */
  48081. pause(): void;
  48082. /**
  48083. * Sets a dedicated volume for this sounds
  48084. * @param newVolume Define the new volume of the sound
  48085. * @param time Define time for gradual change to new volume
  48086. */
  48087. setVolume(newVolume: number, time?: number): void;
  48088. /**
  48089. * Set the sound play back rate
  48090. * @param newPlaybackRate Define the playback rate the sound should be played at
  48091. */
  48092. setPlaybackRate(newPlaybackRate: number): void;
  48093. /**
  48094. * Gets the volume of the sound.
  48095. * @returns the volume of the sound
  48096. */
  48097. getVolume(): number;
  48098. /**
  48099. * Attach the sound to a dedicated mesh
  48100. * @param transformNode The transform node to connect the sound with
  48101. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48102. */
  48103. attachToMesh(transformNode: TransformNode): void;
  48104. /**
  48105. * Detach the sound from the previously attached mesh
  48106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  48107. */
  48108. detachFromMesh(): void;
  48109. private _onRegisterAfterWorldMatrixUpdate;
  48110. /**
  48111. * Clone the current sound in the scene.
  48112. * @returns the new sound clone
  48113. */
  48114. clone(): Nullable<Sound>;
  48115. /**
  48116. * Gets the current underlying audio buffer containing the data
  48117. * @returns the audio buffer
  48118. */
  48119. getAudioBuffer(): Nullable<AudioBuffer>;
  48120. /**
  48121. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  48122. * @returns the source node
  48123. */
  48124. getSoundSource(): Nullable<AudioBufferSourceNode>;
  48125. /**
  48126. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  48127. * @returns the gain node
  48128. */
  48129. getSoundGain(): Nullable<GainNode>;
  48130. /**
  48131. * Serializes the Sound in a JSON representation
  48132. * @returns the JSON representation of the sound
  48133. */
  48134. serialize(): any;
  48135. /**
  48136. * Parse a JSON representation of a sound to innstantiate in a given scene
  48137. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  48138. * @param scene Define the scene the new parsed sound should be created in
  48139. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  48140. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  48141. * @returns the newly parsed sound
  48142. */
  48143. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  48144. }
  48145. }
  48146. declare module BABYLON {
  48147. /**
  48148. * This defines an action helpful to play a defined sound on a triggered action.
  48149. */
  48150. export class PlaySoundAction extends Action {
  48151. private _sound;
  48152. /**
  48153. * Instantiate the action
  48154. * @param triggerOptions defines the trigger options
  48155. * @param sound defines the sound to play
  48156. * @param condition defines the trigger related conditions
  48157. */
  48158. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48159. /** @hidden */
  48160. _prepare(): void;
  48161. /**
  48162. * Execute the action and play the sound.
  48163. */
  48164. execute(): void;
  48165. /**
  48166. * Serializes the actions and its related information.
  48167. * @param parent defines the object to serialize in
  48168. * @returns the serialized object
  48169. */
  48170. serialize(parent: any): any;
  48171. }
  48172. /**
  48173. * This defines an action helpful to stop a defined sound on a triggered action.
  48174. */
  48175. export class StopSoundAction extends Action {
  48176. private _sound;
  48177. /**
  48178. * Instantiate the action
  48179. * @param triggerOptions defines the trigger options
  48180. * @param sound defines the sound to stop
  48181. * @param condition defines the trigger related conditions
  48182. */
  48183. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  48184. /** @hidden */
  48185. _prepare(): void;
  48186. /**
  48187. * Execute the action and stop the sound.
  48188. */
  48189. execute(): void;
  48190. /**
  48191. * Serializes the actions and its related information.
  48192. * @param parent defines the object to serialize in
  48193. * @returns the serialized object
  48194. */
  48195. serialize(parent: any): any;
  48196. }
  48197. }
  48198. declare module BABYLON {
  48199. /**
  48200. * This defines an action responsible to change the value of a property
  48201. * by interpolating between its current value and the newly set one once triggered.
  48202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  48203. */
  48204. export class InterpolateValueAction extends Action {
  48205. /**
  48206. * Defines the path of the property where the value should be interpolated
  48207. */
  48208. propertyPath: string;
  48209. /**
  48210. * Defines the target value at the end of the interpolation.
  48211. */
  48212. value: any;
  48213. /**
  48214. * Defines the time it will take for the property to interpolate to the value.
  48215. */
  48216. duration: number;
  48217. /**
  48218. * Defines if the other scene animations should be stopped when the action has been triggered
  48219. */
  48220. stopOtherAnimations?: boolean;
  48221. /**
  48222. * Defines a callback raised once the interpolation animation has been done.
  48223. */
  48224. onInterpolationDone?: () => void;
  48225. /**
  48226. * Observable triggered once the interpolation animation has been done.
  48227. */
  48228. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  48229. private _target;
  48230. private _effectiveTarget;
  48231. private _property;
  48232. /**
  48233. * Instantiate the action
  48234. * @param triggerOptions defines the trigger options
  48235. * @param target defines the object containing the value to interpolate
  48236. * @param propertyPath defines the path to the property in the target object
  48237. * @param value defines the target value at the end of the interpolation
  48238. * @param duration deines the time it will take for the property to interpolate to the value.
  48239. * @param condition defines the trigger related conditions
  48240. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  48241. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  48242. */
  48243. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  48244. /** @hidden */
  48245. _prepare(): void;
  48246. /**
  48247. * Execute the action starts the value interpolation.
  48248. */
  48249. execute(): void;
  48250. /**
  48251. * Serializes the actions and its related information.
  48252. * @param parent defines the object to serialize in
  48253. * @returns the serialized object
  48254. */
  48255. serialize(parent: any): any;
  48256. }
  48257. }
  48258. declare module BABYLON {
  48259. /**
  48260. * This represents the default audio engine used in babylon.
  48261. * It is responsible to play, synchronize and analyse sounds throughout the application.
  48262. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48263. */
  48264. export class AudioEngine implements IAudioEngine {
  48265. private _audioContext;
  48266. private _audioContextInitialized;
  48267. private _muteButton;
  48268. private _hostElement;
  48269. /**
  48270. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  48271. */
  48272. canUseWebAudio: boolean;
  48273. /**
  48274. * The master gain node defines the global audio volume of your audio engine.
  48275. */
  48276. masterGain: GainNode;
  48277. /**
  48278. * Defines if Babylon should emit a warning if WebAudio is not supported.
  48279. * @ignoreNaming
  48280. */
  48281. WarnedWebAudioUnsupported: boolean;
  48282. /**
  48283. * Gets whether or not mp3 are supported by your browser.
  48284. */
  48285. isMP3supported: boolean;
  48286. /**
  48287. * Gets whether or not ogg are supported by your browser.
  48288. */
  48289. isOGGsupported: boolean;
  48290. /**
  48291. * Gets whether audio has been unlocked on the device.
  48292. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  48293. * a user interaction has happened.
  48294. */
  48295. unlocked: boolean;
  48296. /**
  48297. * Defines if the audio engine relies on a custom unlocked button.
  48298. * In this case, the embedded button will not be displayed.
  48299. */
  48300. useCustomUnlockedButton: boolean;
  48301. /**
  48302. * Event raised when audio has been unlocked on the browser.
  48303. */
  48304. onAudioUnlockedObservable: Observable<IAudioEngine>;
  48305. /**
  48306. * Event raised when audio has been locked on the browser.
  48307. */
  48308. onAudioLockedObservable: Observable<IAudioEngine>;
  48309. /**
  48310. * Gets the current AudioContext if available.
  48311. */
  48312. get audioContext(): Nullable<AudioContext>;
  48313. private _connectedAnalyser;
  48314. /**
  48315. * Instantiates a new audio engine.
  48316. *
  48317. * There should be only one per page as some browsers restrict the number
  48318. * of audio contexts you can create.
  48319. * @param hostElement defines the host element where to display the mute icon if necessary
  48320. */
  48321. constructor(hostElement?: Nullable<HTMLElement>);
  48322. /**
  48323. * Flags the audio engine in Locked state.
  48324. * This happens due to new browser policies preventing audio to autoplay.
  48325. */
  48326. lock(): void;
  48327. /**
  48328. * Unlocks the audio engine once a user action has been done on the dom.
  48329. * This is helpful to resume play once browser policies have been satisfied.
  48330. */
  48331. unlock(): void;
  48332. private _resumeAudioContext;
  48333. private _initializeAudioContext;
  48334. private _tryToRun;
  48335. private _triggerRunningState;
  48336. private _triggerSuspendedState;
  48337. private _displayMuteButton;
  48338. private _moveButtonToTopLeft;
  48339. private _onResize;
  48340. private _hideMuteButton;
  48341. /**
  48342. * Destroy and release the resources associated with the audio ccontext.
  48343. */
  48344. dispose(): void;
  48345. /**
  48346. * Gets the global volume sets on the master gain.
  48347. * @returns the global volume if set or -1 otherwise
  48348. */
  48349. getGlobalVolume(): number;
  48350. /**
  48351. * Sets the global volume of your experience (sets on the master gain).
  48352. * @param newVolume Defines the new global volume of the application
  48353. */
  48354. setGlobalVolume(newVolume: number): void;
  48355. /**
  48356. * Connect the audio engine to an audio analyser allowing some amazing
  48357. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48358. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48359. * @param analyser The analyser to connect to the engine
  48360. */
  48361. connectToAnalyser(analyser: Analyser): void;
  48362. }
  48363. }
  48364. declare module BABYLON {
  48365. /**
  48366. * Options allowed during the creation of a sound track.
  48367. */
  48368. export interface ISoundTrackOptions {
  48369. /**
  48370. * The volume the sound track should take during creation
  48371. */
  48372. volume?: number;
  48373. /**
  48374. * Define if the sound track is the main sound track of the scene
  48375. */
  48376. mainTrack?: boolean;
  48377. }
  48378. /**
  48379. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  48380. * It will be also used in a future release to apply effects on a specific track.
  48381. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48382. */
  48383. export class SoundTrack {
  48384. /**
  48385. * The unique identifier of the sound track in the scene.
  48386. */
  48387. id: number;
  48388. /**
  48389. * The list of sounds included in the sound track.
  48390. */
  48391. soundCollection: Array<Sound>;
  48392. private _outputAudioNode;
  48393. private _scene;
  48394. private _connectedAnalyser;
  48395. private _options;
  48396. private _isInitialized;
  48397. /**
  48398. * Creates a new sound track.
  48399. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  48400. * @param scene Define the scene the sound track belongs to
  48401. * @param options
  48402. */
  48403. constructor(scene: Scene, options?: ISoundTrackOptions);
  48404. private _initializeSoundTrackAudioGraph;
  48405. /**
  48406. * Release the sound track and its associated resources
  48407. */
  48408. dispose(): void;
  48409. /**
  48410. * Adds a sound to this sound track
  48411. * @param sound define the cound to add
  48412. * @ignoreNaming
  48413. */
  48414. addSound(sound: Sound): void;
  48415. /**
  48416. * Removes a sound to this sound track
  48417. * @param sound define the cound to remove
  48418. * @ignoreNaming
  48419. */
  48420. removeSound(sound: Sound): void;
  48421. /**
  48422. * Set a global volume for the full sound track.
  48423. * @param newVolume Define the new volume of the sound track
  48424. */
  48425. setVolume(newVolume: number): void;
  48426. /**
  48427. * Switch the panning model to HRTF:
  48428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  48429. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48430. */
  48431. switchPanningModelToHRTF(): void;
  48432. /**
  48433. * Switch the panning model to Equal Power:
  48434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  48435. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  48436. */
  48437. switchPanningModelToEqualPower(): void;
  48438. /**
  48439. * Connect the sound track to an audio analyser allowing some amazing
  48440. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  48441. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  48442. * @param analyser The analyser to connect to the engine
  48443. */
  48444. connectToAnalyser(analyser: Analyser): void;
  48445. }
  48446. }
  48447. declare module BABYLON {
  48448. interface AbstractScene {
  48449. /**
  48450. * The list of sounds used in the scene.
  48451. */
  48452. sounds: Nullable<Array<Sound>>;
  48453. }
  48454. interface Scene {
  48455. /**
  48456. * @hidden
  48457. * Backing field
  48458. */
  48459. _mainSoundTrack: SoundTrack;
  48460. /**
  48461. * The main sound track played by the scene.
  48462. * It cotains your primary collection of sounds.
  48463. */
  48464. mainSoundTrack: SoundTrack;
  48465. /**
  48466. * The list of sound tracks added to the scene
  48467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48468. */
  48469. soundTracks: Nullable<Array<SoundTrack>>;
  48470. /**
  48471. * Gets a sound using a given name
  48472. * @param name defines the name to search for
  48473. * @return the found sound or null if not found at all.
  48474. */
  48475. getSoundByName(name: string): Nullable<Sound>;
  48476. /**
  48477. * Gets or sets if audio support is enabled
  48478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48479. */
  48480. audioEnabled: boolean;
  48481. /**
  48482. * Gets or sets if audio will be output to headphones
  48483. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48484. */
  48485. headphone: boolean;
  48486. /**
  48487. * Gets or sets custom audio listener position provider
  48488. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  48489. */
  48490. audioListenerPositionProvider: Nullable<() => Vector3>;
  48491. /**
  48492. * Gets or sets a refresh rate when using 3D audio positioning
  48493. */
  48494. audioPositioningRefreshRate: number;
  48495. }
  48496. /**
  48497. * Defines the sound scene component responsible to manage any sounds
  48498. * in a given scene.
  48499. */
  48500. export class AudioSceneComponent implements ISceneSerializableComponent {
  48501. private static _CameraDirectionLH;
  48502. private static _CameraDirectionRH;
  48503. /**
  48504. * The component name helpfull to identify the component in the list of scene components.
  48505. */
  48506. readonly name: string;
  48507. /**
  48508. * The scene the component belongs to.
  48509. */
  48510. scene: Scene;
  48511. private _audioEnabled;
  48512. /**
  48513. * Gets whether audio is enabled or not.
  48514. * Please use related enable/disable method to switch state.
  48515. */
  48516. get audioEnabled(): boolean;
  48517. private _headphone;
  48518. /**
  48519. * Gets whether audio is outputing to headphone or not.
  48520. * Please use the according Switch methods to change output.
  48521. */
  48522. get headphone(): boolean;
  48523. /**
  48524. * Gets or sets a refresh rate when using 3D audio positioning
  48525. */
  48526. audioPositioningRefreshRate: number;
  48527. private _audioListenerPositionProvider;
  48528. /**
  48529. * Gets the current audio listener position provider
  48530. */
  48531. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  48532. /**
  48533. * Sets a custom listener position for all sounds in the scene
  48534. * By default, this is the position of the first active camera
  48535. */
  48536. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  48537. /**
  48538. * Creates a new instance of the component for the given scene
  48539. * @param scene Defines the scene to register the component in
  48540. */
  48541. constructor(scene: Scene);
  48542. /**
  48543. * Registers the component in a given scene
  48544. */
  48545. register(): void;
  48546. /**
  48547. * Rebuilds the elements related to this component in case of
  48548. * context lost for instance.
  48549. */
  48550. rebuild(): void;
  48551. /**
  48552. * Serializes the component data to the specified json object
  48553. * @param serializationObject The object to serialize to
  48554. */
  48555. serialize(serializationObject: any): void;
  48556. /**
  48557. * Adds all the elements from the container to the scene
  48558. * @param container the container holding the elements
  48559. */
  48560. addFromContainer(container: AbstractScene): void;
  48561. /**
  48562. * Removes all the elements in the container from the scene
  48563. * @param container contains the elements to remove
  48564. * @param dispose if the removed element should be disposed (default: false)
  48565. */
  48566. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48567. /**
  48568. * Disposes the component and the associated ressources.
  48569. */
  48570. dispose(): void;
  48571. /**
  48572. * Disables audio in the associated scene.
  48573. */
  48574. disableAudio(): void;
  48575. /**
  48576. * Enables audio in the associated scene.
  48577. */
  48578. enableAudio(): void;
  48579. /**
  48580. * Switch audio to headphone output.
  48581. */
  48582. switchAudioModeForHeadphones(): void;
  48583. /**
  48584. * Switch audio to normal speakers.
  48585. */
  48586. switchAudioModeForNormalSpeakers(): void;
  48587. private _cachedCameraDirection;
  48588. private _cachedCameraPosition;
  48589. private _lastCheck;
  48590. private _afterRender;
  48591. }
  48592. }
  48593. declare module BABYLON {
  48594. /**
  48595. * Wraps one or more Sound objects and selects one with random weight for playback.
  48596. */
  48597. export class WeightedSound {
  48598. /** When true a Sound will be selected and played when the current playing Sound completes. */
  48599. loop: boolean;
  48600. private _coneInnerAngle;
  48601. private _coneOuterAngle;
  48602. private _volume;
  48603. /** A Sound is currently playing. */
  48604. isPlaying: boolean;
  48605. /** A Sound is currently paused. */
  48606. isPaused: boolean;
  48607. private _sounds;
  48608. private _weights;
  48609. private _currentIndex?;
  48610. /**
  48611. * Creates a new WeightedSound from the list of sounds given.
  48612. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  48613. * @param sounds Array of Sounds that will be selected from.
  48614. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  48615. */
  48616. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  48617. /**
  48618. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  48619. */
  48620. get directionalConeInnerAngle(): number;
  48621. /**
  48622. * The size of cone in degress for a directional sound in which there will be no attenuation.
  48623. */
  48624. set directionalConeInnerAngle(value: number);
  48625. /**
  48626. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48627. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48628. */
  48629. get directionalConeOuterAngle(): number;
  48630. /**
  48631. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  48632. * Listener angles between innerAngle and outerAngle will falloff linearly.
  48633. */
  48634. set directionalConeOuterAngle(value: number);
  48635. /**
  48636. * Playback volume.
  48637. */
  48638. get volume(): number;
  48639. /**
  48640. * Playback volume.
  48641. */
  48642. set volume(value: number);
  48643. private _onended;
  48644. /**
  48645. * Suspend playback
  48646. */
  48647. pause(): void;
  48648. /**
  48649. * Stop playback
  48650. */
  48651. stop(): void;
  48652. /**
  48653. * Start playback.
  48654. * @param startOffset Position the clip head at a specific time in seconds.
  48655. */
  48656. play(startOffset?: number): void;
  48657. }
  48658. }
  48659. declare module BABYLON {
  48660. /**
  48661. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  48662. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48663. */
  48664. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  48665. /**
  48666. * Gets the name of the behavior.
  48667. */
  48668. get name(): string;
  48669. /**
  48670. * The easing function used by animations
  48671. */
  48672. static EasingFunction: BackEase;
  48673. /**
  48674. * The easing mode used by animations
  48675. */
  48676. static EasingMode: number;
  48677. /**
  48678. * The duration of the animation, in milliseconds
  48679. */
  48680. transitionDuration: number;
  48681. /**
  48682. * Length of the distance animated by the transition when lower radius is reached
  48683. */
  48684. lowerRadiusTransitionRange: number;
  48685. /**
  48686. * Length of the distance animated by the transition when upper radius is reached
  48687. */
  48688. upperRadiusTransitionRange: number;
  48689. private _autoTransitionRange;
  48690. /**
  48691. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48692. */
  48693. get autoTransitionRange(): boolean;
  48694. /**
  48695. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  48696. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  48697. */
  48698. set autoTransitionRange(value: boolean);
  48699. private _attachedCamera;
  48700. private _onAfterCheckInputsObserver;
  48701. private _onMeshTargetChangedObserver;
  48702. /**
  48703. * Initializes the behavior.
  48704. */
  48705. init(): void;
  48706. /**
  48707. * Attaches the behavior to its arc rotate camera.
  48708. * @param camera Defines the camera to attach the behavior to
  48709. */
  48710. attach(camera: ArcRotateCamera): void;
  48711. /**
  48712. * Detaches the behavior from its current arc rotate camera.
  48713. */
  48714. detach(): void;
  48715. private _radiusIsAnimating;
  48716. private _radiusBounceTransition;
  48717. private _animatables;
  48718. private _cachedWheelPrecision;
  48719. /**
  48720. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  48721. * @param radiusLimit The limit to check against.
  48722. * @return Bool to indicate if at limit.
  48723. */
  48724. private _isRadiusAtLimit;
  48725. /**
  48726. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  48727. * @param radiusDelta The delta by which to animate to. Can be negative.
  48728. */
  48729. private _applyBoundRadiusAnimation;
  48730. /**
  48731. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  48732. */
  48733. protected _clearAnimationLocks(): void;
  48734. /**
  48735. * Stops and removes all animations that have been applied to the camera
  48736. */
  48737. stopAllAnimations(): void;
  48738. }
  48739. }
  48740. declare module BABYLON {
  48741. /**
  48742. * 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.
  48743. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48744. */
  48745. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  48746. /**
  48747. * Gets the name of the behavior.
  48748. */
  48749. get name(): string;
  48750. private _mode;
  48751. private _radiusScale;
  48752. private _positionScale;
  48753. private _defaultElevation;
  48754. private _elevationReturnTime;
  48755. private _elevationReturnWaitTime;
  48756. private _zoomStopsAnimation;
  48757. private _framingTime;
  48758. /**
  48759. * The easing function used by animations
  48760. */
  48761. static EasingFunction: ExponentialEase;
  48762. /**
  48763. * The easing mode used by animations
  48764. */
  48765. static EasingMode: number;
  48766. /**
  48767. * Sets the current mode used by the behavior
  48768. */
  48769. set mode(mode: number);
  48770. /**
  48771. * Gets current mode used by the behavior.
  48772. */
  48773. get mode(): number;
  48774. /**
  48775. * Sets the scale applied to the radius (1 by default)
  48776. */
  48777. set radiusScale(radius: number);
  48778. /**
  48779. * Gets the scale applied to the radius
  48780. */
  48781. get radiusScale(): number;
  48782. /**
  48783. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48784. */
  48785. set positionScale(scale: number);
  48786. /**
  48787. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  48788. */
  48789. get positionScale(): number;
  48790. /**
  48791. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48792. * behaviour is triggered, in radians.
  48793. */
  48794. set defaultElevation(elevation: number);
  48795. /**
  48796. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  48797. * behaviour is triggered, in radians.
  48798. */
  48799. get defaultElevation(): number;
  48800. /**
  48801. * Sets the time (in milliseconds) taken to return to the default beta position.
  48802. * Negative value indicates camera should not return to default.
  48803. */
  48804. set elevationReturnTime(speed: number);
  48805. /**
  48806. * Gets the time (in milliseconds) taken to return to the default beta position.
  48807. * Negative value indicates camera should not return to default.
  48808. */
  48809. get elevationReturnTime(): number;
  48810. /**
  48811. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48812. */
  48813. set elevationReturnWaitTime(time: number);
  48814. /**
  48815. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  48816. */
  48817. get elevationReturnWaitTime(): number;
  48818. /**
  48819. * Sets the flag that indicates if user zooming should stop animation.
  48820. */
  48821. set zoomStopsAnimation(flag: boolean);
  48822. /**
  48823. * Gets the flag that indicates if user zooming should stop animation.
  48824. */
  48825. get zoomStopsAnimation(): boolean;
  48826. /**
  48827. * Sets the transition time when framing the mesh, in milliseconds
  48828. */
  48829. set framingTime(time: number);
  48830. /**
  48831. * Gets the transition time when framing the mesh, in milliseconds
  48832. */
  48833. get framingTime(): number;
  48834. /**
  48835. * Define if the behavior should automatically change the configured
  48836. * camera limits and sensibilities.
  48837. */
  48838. autoCorrectCameraLimitsAndSensibility: boolean;
  48839. private _onPrePointerObservableObserver;
  48840. private _onAfterCheckInputsObserver;
  48841. private _onMeshTargetChangedObserver;
  48842. private _attachedCamera;
  48843. private _isPointerDown;
  48844. private _lastInteractionTime;
  48845. /**
  48846. * Initializes the behavior.
  48847. */
  48848. init(): void;
  48849. /**
  48850. * Attaches the behavior to its arc rotate camera.
  48851. * @param camera Defines the camera to attach the behavior to
  48852. */
  48853. attach(camera: ArcRotateCamera): void;
  48854. /**
  48855. * Detaches the behavior from its current arc rotate camera.
  48856. */
  48857. detach(): void;
  48858. private _animatables;
  48859. private _betaIsAnimating;
  48860. private _betaTransition;
  48861. private _radiusTransition;
  48862. private _vectorTransition;
  48863. /**
  48864. * Targets the given mesh and updates zoom level accordingly.
  48865. * @param mesh The mesh to target.
  48866. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48867. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48868. */
  48869. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48870. /**
  48871. * Targets the given mesh with its children and updates zoom level accordingly.
  48872. * @param mesh The mesh to target.
  48873. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48874. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48875. */
  48876. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48877. /**
  48878. * Targets the given meshes with their children and updates zoom level accordingly.
  48879. * @param meshes The mesh to target.
  48880. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48881. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48882. */
  48883. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48884. /**
  48885. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  48886. * @param minimumWorld Determines the smaller position of the bounding box extend
  48887. * @param maximumWorld Determines the bigger position of the bounding box extend
  48888. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  48889. * @param onAnimationEnd Callback triggered at the end of the framing animation
  48890. */
  48891. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  48892. /**
  48893. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  48894. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  48895. * frustum width.
  48896. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  48897. * to fully enclose the mesh in the viewing frustum.
  48898. */
  48899. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  48900. /**
  48901. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  48902. * is automatically returned to its default position (expected to be above ground plane).
  48903. */
  48904. private _maintainCameraAboveGround;
  48905. /**
  48906. * Returns the frustum slope based on the canvas ratio and camera FOV
  48907. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  48908. */
  48909. private _getFrustumSlope;
  48910. /**
  48911. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  48912. */
  48913. private _clearAnimationLocks;
  48914. /**
  48915. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48916. */
  48917. private _applyUserInteraction;
  48918. /**
  48919. * Stops and removes all animations that have been applied to the camera
  48920. */
  48921. stopAllAnimations(): void;
  48922. /**
  48923. * Gets a value indicating if the user is moving the camera
  48924. */
  48925. get isUserIsMoving(): boolean;
  48926. /**
  48927. * The camera can move all the way towards the mesh.
  48928. */
  48929. static IgnoreBoundsSizeMode: number;
  48930. /**
  48931. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  48932. */
  48933. static FitFrustumSidesMode: number;
  48934. }
  48935. }
  48936. declare module BABYLON {
  48937. /**
  48938. * Base class for Camera Pointer Inputs.
  48939. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  48940. * for example usage.
  48941. */
  48942. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  48943. /**
  48944. * Defines the camera the input is attached to.
  48945. */
  48946. abstract camera: Camera;
  48947. /**
  48948. * Whether keyboard modifier keys are pressed at time of last mouse event.
  48949. */
  48950. protected _altKey: boolean;
  48951. protected _ctrlKey: boolean;
  48952. protected _metaKey: boolean;
  48953. protected _shiftKey: boolean;
  48954. /**
  48955. * Which mouse buttons were pressed at time of last mouse event.
  48956. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  48957. */
  48958. protected _buttonsPressed: number;
  48959. /**
  48960. * Defines the buttons associated with the input to handle camera move.
  48961. */
  48962. buttons: number[];
  48963. /**
  48964. * Attach the input controls to a specific dom element to get the input from.
  48965. * @param element Defines the element the controls should be listened from
  48966. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48967. */
  48968. attachControl(noPreventDefault?: boolean): void;
  48969. /**
  48970. * Detach the current controls from the specified dom element.
  48971. */
  48972. detachControl(): void;
  48973. /**
  48974. * Gets the class name of the current input.
  48975. * @returns the class name
  48976. */
  48977. getClassName(): string;
  48978. /**
  48979. * Get the friendly name associated with the input class.
  48980. * @returns the input friendly name
  48981. */
  48982. getSimpleName(): string;
  48983. /**
  48984. * Called on pointer POINTERDOUBLETAP event.
  48985. * Override this method to provide functionality on POINTERDOUBLETAP event.
  48986. */
  48987. protected onDoubleTap(type: string): void;
  48988. /**
  48989. * Called on pointer POINTERMOVE event if only a single touch is active.
  48990. * Override this method to provide functionality.
  48991. */
  48992. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  48993. /**
  48994. * Called on pointer POINTERMOVE event if multiple touches are active.
  48995. * Override this method to provide functionality.
  48996. */
  48997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  48998. /**
  48999. * Called on JS contextmenu event.
  49000. * Override this method to provide functionality.
  49001. */
  49002. protected onContextMenu(evt: PointerEvent): void;
  49003. /**
  49004. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49005. * press.
  49006. * Override this method to provide functionality.
  49007. */
  49008. protected onButtonDown(evt: PointerEvent): void;
  49009. /**
  49010. * Called each time a new POINTERUP event occurs. Ie, for each button
  49011. * release.
  49012. * Override this method to provide functionality.
  49013. */
  49014. protected onButtonUp(evt: PointerEvent): void;
  49015. /**
  49016. * Called when window becomes inactive.
  49017. * Override this method to provide functionality.
  49018. */
  49019. protected onLostFocus(): void;
  49020. private _pointerInput;
  49021. private _observer;
  49022. private _onLostFocus;
  49023. private pointA;
  49024. private pointB;
  49025. }
  49026. }
  49027. declare module BABYLON {
  49028. /**
  49029. * Manage the pointers inputs to control an arc rotate camera.
  49030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49031. */
  49032. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  49033. /**
  49034. * Defines the camera the input is attached to.
  49035. */
  49036. camera: ArcRotateCamera;
  49037. /**
  49038. * Gets the class name of the current input.
  49039. * @returns the class name
  49040. */
  49041. getClassName(): string;
  49042. /**
  49043. * Defines the buttons associated with the input to handle camera move.
  49044. */
  49045. buttons: number[];
  49046. /**
  49047. * Defines the pointer angular sensibility along the X axis or how fast is
  49048. * the camera rotating.
  49049. */
  49050. angularSensibilityX: number;
  49051. /**
  49052. * Defines the pointer angular sensibility along the Y axis or how fast is
  49053. * the camera rotating.
  49054. */
  49055. angularSensibilityY: number;
  49056. /**
  49057. * Defines the pointer pinch precision or how fast is the camera zooming.
  49058. */
  49059. pinchPrecision: number;
  49060. /**
  49061. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49062. * from 0.
  49063. * It defines the percentage of current camera.radius to use as delta when
  49064. * pinch zoom is used.
  49065. */
  49066. pinchDeltaPercentage: number;
  49067. /**
  49068. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49069. * that any object in the plane at the camera's target point will scale
  49070. * perfectly with finger motion.
  49071. * Overrides pinchDeltaPercentage and pinchPrecision.
  49072. */
  49073. useNaturalPinchZoom: boolean;
  49074. /**
  49075. * Defines whether zoom (2 fingers pinch) is enabled through multitouch
  49076. */
  49077. pinchZoom: boolean;
  49078. /**
  49079. * Defines the pointer panning sensibility or how fast is the camera moving.
  49080. */
  49081. panningSensibility: number;
  49082. /**
  49083. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  49084. */
  49085. multiTouchPanning: boolean;
  49086. /**
  49087. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  49088. * zoom (pinch) through multitouch.
  49089. */
  49090. multiTouchPanAndZoom: boolean;
  49091. /**
  49092. * Revers pinch action direction.
  49093. */
  49094. pinchInwards: boolean;
  49095. private _isPanClick;
  49096. private _twoFingerActivityCount;
  49097. private _isPinching;
  49098. /**
  49099. * Move camera from multi touch panning positions.
  49100. */
  49101. private _computeMultiTouchPanning;
  49102. /**
  49103. * Move camera from pinch zoom distances.
  49104. */
  49105. private _computePinchZoom;
  49106. /**
  49107. * Called on pointer POINTERMOVE event if only a single touch is active.
  49108. */
  49109. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49110. /**
  49111. * Called on pointer POINTERDOUBLETAP event.
  49112. */
  49113. protected onDoubleTap(type: string): void;
  49114. /**
  49115. * Called on pointer POINTERMOVE event if multiple touches are active.
  49116. */
  49117. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49118. /**
  49119. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  49120. * press.
  49121. */
  49122. protected onButtonDown(evt: PointerEvent): void;
  49123. /**
  49124. * Called each time a new POINTERUP event occurs. Ie, for each button
  49125. * release.
  49126. */
  49127. protected onButtonUp(evt: PointerEvent): void;
  49128. /**
  49129. * Called when window becomes inactive.
  49130. */
  49131. protected onLostFocus(): void;
  49132. }
  49133. }
  49134. declare module BABYLON {
  49135. /**
  49136. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  49137. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49138. */
  49139. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  49140. /**
  49141. * Defines the camera the input is attached to.
  49142. */
  49143. camera: ArcRotateCamera;
  49144. /**
  49145. * Defines the list of key codes associated with the up action (increase alpha)
  49146. */
  49147. keysUp: number[];
  49148. /**
  49149. * Defines the list of key codes associated with the down action (decrease alpha)
  49150. */
  49151. keysDown: number[];
  49152. /**
  49153. * Defines the list of key codes associated with the left action (increase beta)
  49154. */
  49155. keysLeft: number[];
  49156. /**
  49157. * Defines the list of key codes associated with the right action (decrease beta)
  49158. */
  49159. keysRight: number[];
  49160. /**
  49161. * Defines the list of key codes associated with the reset action.
  49162. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  49163. */
  49164. keysReset: number[];
  49165. /**
  49166. * Defines the panning sensibility of the inputs.
  49167. * (How fast is the camera panning)
  49168. */
  49169. panningSensibility: number;
  49170. /**
  49171. * Defines the zooming sensibility of the inputs.
  49172. * (How fast is the camera zooming)
  49173. */
  49174. zoomingSensibility: number;
  49175. /**
  49176. * Defines whether maintaining the alt key down switch the movement mode from
  49177. * orientation to zoom.
  49178. */
  49179. useAltToZoom: boolean;
  49180. /**
  49181. * Rotation speed of the camera
  49182. */
  49183. angularSpeed: number;
  49184. private _keys;
  49185. private _ctrlPressed;
  49186. private _altPressed;
  49187. private _onCanvasBlurObserver;
  49188. private _onKeyboardObserver;
  49189. private _engine;
  49190. private _scene;
  49191. /**
  49192. * Attach the input controls to a specific dom element to get the input from.
  49193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49194. */
  49195. attachControl(noPreventDefault?: boolean): void;
  49196. /**
  49197. * Detach the current controls from the specified dom element.
  49198. */
  49199. detachControl(): void;
  49200. /**
  49201. * Update the current camera state depending on the inputs that have been used this frame.
  49202. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49203. */
  49204. checkInputs(): void;
  49205. /**
  49206. * Gets the class name of the current intput.
  49207. * @returns the class name
  49208. */
  49209. getClassName(): string;
  49210. /**
  49211. * Get the friendly name associated with the input class.
  49212. * @returns the input friendly name
  49213. */
  49214. getSimpleName(): string;
  49215. }
  49216. }
  49217. declare module BABYLON {
  49218. /**
  49219. * Manage the mouse wheel inputs to control an arc rotate camera.
  49220. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49221. */
  49222. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  49223. /**
  49224. * Defines the camera the input is attached to.
  49225. */
  49226. camera: ArcRotateCamera;
  49227. /**
  49228. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49229. */
  49230. wheelPrecision: number;
  49231. /**
  49232. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49233. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49234. */
  49235. wheelDeltaPercentage: number;
  49236. private _wheel;
  49237. private _observer;
  49238. private computeDeltaFromMouseWheelLegacyEvent;
  49239. /**
  49240. * Attach the input controls to a specific dom element to get the input from.
  49241. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49242. */
  49243. attachControl(noPreventDefault?: boolean): void;
  49244. /**
  49245. * Detach the current controls from the specified dom element.
  49246. */
  49247. detachControl(): void;
  49248. /**
  49249. * Gets the class name of the current intput.
  49250. * @returns the class name
  49251. */
  49252. getClassName(): string;
  49253. /**
  49254. * Get the friendly name associated with the input class.
  49255. * @returns the input friendly name
  49256. */
  49257. getSimpleName(): string;
  49258. }
  49259. }
  49260. declare module BABYLON {
  49261. /**
  49262. * Default Inputs manager for the ArcRotateCamera.
  49263. * It groups all the default supported inputs for ease of use.
  49264. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49265. */
  49266. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  49267. /**
  49268. * Instantiates a new ArcRotateCameraInputsManager.
  49269. * @param camera Defines the camera the inputs belong to
  49270. */
  49271. constructor(camera: ArcRotateCamera);
  49272. /**
  49273. * Add mouse wheel input support to the input manager.
  49274. * @returns the current input manager
  49275. */
  49276. addMouseWheel(): ArcRotateCameraInputsManager;
  49277. /**
  49278. * Add pointers input support to the input manager.
  49279. * @returns the current input manager
  49280. */
  49281. addPointers(): ArcRotateCameraInputsManager;
  49282. /**
  49283. * Add keyboard input support to the input manager.
  49284. * @returns the current input manager
  49285. */
  49286. addKeyboard(): ArcRotateCameraInputsManager;
  49287. }
  49288. }
  49289. declare module BABYLON {
  49290. /**
  49291. * This represents an orbital type of camera.
  49292. *
  49293. * 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.
  49294. * 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.
  49295. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  49296. */
  49297. export class ArcRotateCamera extends TargetCamera {
  49298. /**
  49299. * Defines the rotation angle of the camera along the longitudinal axis.
  49300. */
  49301. alpha: number;
  49302. /**
  49303. * Defines the rotation angle of the camera along the latitudinal axis.
  49304. */
  49305. beta: number;
  49306. /**
  49307. * Defines the radius of the camera from it s target point.
  49308. */
  49309. radius: number;
  49310. protected _target: Vector3;
  49311. protected _targetHost: Nullable<AbstractMesh>;
  49312. /**
  49313. * Defines the target point of the camera.
  49314. * The camera looks towards it form the radius distance.
  49315. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  49316. */
  49317. get target(): Vector3;
  49318. set target(value: Vector3);
  49319. /**
  49320. * Define the current local position of the camera in the scene
  49321. */
  49322. get position(): Vector3;
  49323. set position(newPosition: Vector3);
  49324. protected _upToYMatrix: Matrix;
  49325. protected _YToUpMatrix: Matrix;
  49326. /**
  49327. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  49328. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  49329. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  49330. */
  49331. set upVector(vec: Vector3);
  49332. get upVector(): Vector3;
  49333. /**
  49334. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  49335. */
  49336. setMatUp(): void;
  49337. /**
  49338. * Current inertia value on the longitudinal axis.
  49339. * The bigger this number the longer it will take for the camera to stop.
  49340. */
  49341. inertialAlphaOffset: number;
  49342. /**
  49343. * Current inertia value on the latitudinal axis.
  49344. * The bigger this number the longer it will take for the camera to stop.
  49345. */
  49346. inertialBetaOffset: number;
  49347. /**
  49348. * Current inertia value on the radius axis.
  49349. * The bigger this number the longer it will take for the camera to stop.
  49350. */
  49351. inertialRadiusOffset: number;
  49352. /**
  49353. * Minimum allowed angle on the longitudinal axis.
  49354. * This can help limiting how the Camera is able to move in the scene.
  49355. */
  49356. lowerAlphaLimit: Nullable<number>;
  49357. /**
  49358. * Maximum allowed angle on the longitudinal axis.
  49359. * This can help limiting how the Camera is able to move in the scene.
  49360. */
  49361. upperAlphaLimit: Nullable<number>;
  49362. /**
  49363. * Minimum allowed angle on the latitudinal axis.
  49364. * This can help limiting how the Camera is able to move in the scene.
  49365. */
  49366. lowerBetaLimit: number;
  49367. /**
  49368. * Maximum allowed angle on the latitudinal axis.
  49369. * This can help limiting how the Camera is able to move in the scene.
  49370. */
  49371. upperBetaLimit: number;
  49372. /**
  49373. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  49374. * This can help limiting how the Camera is able to move in the scene.
  49375. */
  49376. lowerRadiusLimit: Nullable<number>;
  49377. /**
  49378. * Maximum allowed distance of the camera to the target (The camera can not get further).
  49379. * This can help limiting how the Camera is able to move in the scene.
  49380. */
  49381. upperRadiusLimit: Nullable<number>;
  49382. /**
  49383. * Defines the current inertia value used during panning of the camera along the X axis.
  49384. */
  49385. inertialPanningX: number;
  49386. /**
  49387. * Defines the current inertia value used during panning of the camera along the Y axis.
  49388. */
  49389. inertialPanningY: number;
  49390. /**
  49391. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  49392. * Basically if your fingers moves away from more than this distance you will be considered
  49393. * in pinch mode.
  49394. */
  49395. pinchToPanMaxDistance: number;
  49396. /**
  49397. * Defines the maximum distance the camera can pan.
  49398. * This could help keeping the cammera always in your scene.
  49399. */
  49400. panningDistanceLimit: Nullable<number>;
  49401. /**
  49402. * Defines the target of the camera before paning.
  49403. */
  49404. panningOriginTarget: Vector3;
  49405. /**
  49406. * Defines the value of the inertia used during panning.
  49407. * 0 would mean stop inertia and one would mean no decelleration at all.
  49408. */
  49409. panningInertia: number;
  49410. /**
  49411. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  49412. */
  49413. get angularSensibilityX(): number;
  49414. set angularSensibilityX(value: number);
  49415. /**
  49416. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  49417. */
  49418. get angularSensibilityY(): number;
  49419. set angularSensibilityY(value: number);
  49420. /**
  49421. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  49422. */
  49423. get pinchPrecision(): number;
  49424. set pinchPrecision(value: number);
  49425. /**
  49426. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  49427. * It will be used instead of pinchDeltaPrecision if different from 0.
  49428. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49429. */
  49430. get pinchDeltaPercentage(): number;
  49431. set pinchDeltaPercentage(value: number);
  49432. /**
  49433. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  49434. * and pinch delta percentage.
  49435. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  49436. * that any object in the plane at the camera's target point will scale
  49437. * perfectly with finger motion.
  49438. */
  49439. get useNaturalPinchZoom(): boolean;
  49440. set useNaturalPinchZoom(value: boolean);
  49441. /**
  49442. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  49443. */
  49444. get panningSensibility(): number;
  49445. set panningSensibility(value: number);
  49446. /**
  49447. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  49448. */
  49449. get keysUp(): number[];
  49450. set keysUp(value: number[]);
  49451. /**
  49452. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  49453. */
  49454. get keysDown(): number[];
  49455. set keysDown(value: number[]);
  49456. /**
  49457. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  49458. */
  49459. get keysLeft(): number[];
  49460. set keysLeft(value: number[]);
  49461. /**
  49462. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  49463. */
  49464. get keysRight(): number[];
  49465. set keysRight(value: number[]);
  49466. /**
  49467. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  49468. */
  49469. get wheelPrecision(): number;
  49470. set wheelPrecision(value: number);
  49471. /**
  49472. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  49473. * It will be used instead of pinchDeltaPrecision if different from 0.
  49474. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  49475. */
  49476. get wheelDeltaPercentage(): number;
  49477. set wheelDeltaPercentage(value: number);
  49478. /**
  49479. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  49480. */
  49481. zoomOnFactor: number;
  49482. /**
  49483. * Defines a screen offset for the camera position.
  49484. */
  49485. targetScreenOffset: Vector2;
  49486. /**
  49487. * Allows the camera to be completely reversed.
  49488. * If false the camera can not arrive upside down.
  49489. */
  49490. allowUpsideDown: boolean;
  49491. /**
  49492. * Define if double tap/click is used to restore the previously saved state of the camera.
  49493. */
  49494. useInputToRestoreState: boolean;
  49495. /** @hidden */
  49496. _viewMatrix: Matrix;
  49497. /** @hidden */
  49498. _useCtrlForPanning: boolean;
  49499. /** @hidden */
  49500. _panningMouseButton: number;
  49501. /**
  49502. * Defines the input associated to the camera.
  49503. */
  49504. inputs: ArcRotateCameraInputsManager;
  49505. /** @hidden */
  49506. _reset: () => void;
  49507. /**
  49508. * Defines the allowed panning axis.
  49509. */
  49510. panningAxis: Vector3;
  49511. protected _transformedDirection: Vector3;
  49512. private _bouncingBehavior;
  49513. /**
  49514. * Gets the bouncing behavior of the camera if it has been enabled.
  49515. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49516. */
  49517. get bouncingBehavior(): Nullable<BouncingBehavior>;
  49518. /**
  49519. * Defines if the bouncing behavior of the camera is enabled on the camera.
  49520. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  49521. */
  49522. get useBouncingBehavior(): boolean;
  49523. set useBouncingBehavior(value: boolean);
  49524. private _framingBehavior;
  49525. /**
  49526. * Gets the framing behavior of the camera if it has been enabled.
  49527. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49528. */
  49529. get framingBehavior(): Nullable<FramingBehavior>;
  49530. /**
  49531. * Defines if the framing behavior of the camera is enabled on the camera.
  49532. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  49533. */
  49534. get useFramingBehavior(): boolean;
  49535. set useFramingBehavior(value: boolean);
  49536. private _autoRotationBehavior;
  49537. /**
  49538. * Gets the auto rotation behavior of the camera if it has been enabled.
  49539. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49540. */
  49541. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  49542. /**
  49543. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  49544. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49545. */
  49546. get useAutoRotationBehavior(): boolean;
  49547. set useAutoRotationBehavior(value: boolean);
  49548. /**
  49549. * Observable triggered when the mesh target has been changed on the camera.
  49550. */
  49551. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  49552. /**
  49553. * Event raised when the camera is colliding with a mesh.
  49554. */
  49555. onCollide: (collidedMesh: AbstractMesh) => void;
  49556. /**
  49557. * Defines whether the camera should check collision with the objects oh the scene.
  49558. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  49559. */
  49560. checkCollisions: boolean;
  49561. /**
  49562. * Defines the collision radius of the camera.
  49563. * This simulates a sphere around the camera.
  49564. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49565. */
  49566. collisionRadius: Vector3;
  49567. protected _collider: Collider;
  49568. protected _previousPosition: Vector3;
  49569. protected _collisionVelocity: Vector3;
  49570. protected _newPosition: Vector3;
  49571. protected _previousAlpha: number;
  49572. protected _previousBeta: number;
  49573. protected _previousRadius: number;
  49574. protected _collisionTriggered: boolean;
  49575. protected _targetBoundingCenter: Nullable<Vector3>;
  49576. private _computationVector;
  49577. /**
  49578. * Instantiates a new ArcRotateCamera in a given scene
  49579. * @param name Defines the name of the camera
  49580. * @param alpha Defines the camera rotation along the logitudinal axis
  49581. * @param beta Defines the camera rotation along the latitudinal axis
  49582. * @param radius Defines the camera distance from its target
  49583. * @param target Defines the camera target
  49584. * @param scene Defines the scene the camera belongs to
  49585. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  49586. */
  49587. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49588. /** @hidden */
  49589. _initCache(): void;
  49590. /** @hidden */
  49591. _updateCache(ignoreParentClass?: boolean): void;
  49592. protected _getTargetPosition(): Vector3;
  49593. private _storedAlpha;
  49594. private _storedBeta;
  49595. private _storedRadius;
  49596. private _storedTarget;
  49597. private _storedTargetScreenOffset;
  49598. /**
  49599. * Stores the current state of the camera (alpha, beta, radius and target)
  49600. * @returns the camera itself
  49601. */
  49602. storeState(): Camera;
  49603. /**
  49604. * @hidden
  49605. * Restored camera state. You must call storeState() first
  49606. */
  49607. _restoreStateValues(): boolean;
  49608. /** @hidden */
  49609. _isSynchronizedViewMatrix(): boolean;
  49610. /**
  49611. * Attach the input controls to a specific dom element to get the input from.
  49612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49613. */
  49614. attachControl(noPreventDefault?: boolean): void;
  49615. /**
  49616. * Attach the input controls to a specific dom element to get the input from.
  49617. * @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
  49618. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49619. */
  49620. attachControl(ignored: any, noPreventDefault?: boolean): void;
  49621. /**
  49622. * Attached controls to the current camera.
  49623. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49624. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49625. */
  49626. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49627. /**
  49628. * Attached controls to the current camera.
  49629. * @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
  49630. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49631. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49632. */
  49633. attachControl(ignored: any, noPreventDefault: boolean, useCtrlForPanning: boolean): void;
  49634. /**
  49635. * Attached controls to the current camera.
  49636. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49637. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  49638. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  49639. */
  49640. attachControl(noPreventDefault: boolean, useCtrlForPanning: boolean, panningMouseButton: number): void;
  49641. /**
  49642. * Detach the current controls from the specified dom element.
  49643. */
  49644. detachControl(): void;
  49645. /**
  49646. * Detach the current controls from the specified dom element.
  49647. * @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
  49648. */
  49649. detachControl(ignored: any): void;
  49650. /** @hidden */
  49651. _checkInputs(): void;
  49652. protected _checkLimits(): void;
  49653. /**
  49654. * Rebuilds angles (alpha, beta) and radius from the give position and target
  49655. */
  49656. rebuildAnglesAndRadius(): void;
  49657. /**
  49658. * Use a position to define the current camera related information like alpha, beta and radius
  49659. * @param position Defines the position to set the camera at
  49660. */
  49661. setPosition(position: Vector3): void;
  49662. /**
  49663. * Defines the target the camera should look at.
  49664. * This will automatically adapt alpha beta and radius to fit within the new target.
  49665. * @param target Defines the new target as a Vector or a mesh
  49666. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  49667. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  49668. */
  49669. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  49670. /** @hidden */
  49671. _getViewMatrix(): Matrix;
  49672. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  49673. /**
  49674. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  49675. * @param meshes Defines the mesh to zoom on
  49676. * @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)
  49677. */
  49678. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  49679. /**
  49680. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  49681. * The target will be changed but the radius
  49682. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  49683. * @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)
  49684. */
  49685. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  49686. min: Vector3;
  49687. max: Vector3;
  49688. distance: number;
  49689. }, doNotUpdateMaxZ?: boolean): void;
  49690. /**
  49691. * @override
  49692. * Override Camera.createRigCamera
  49693. */
  49694. createRigCamera(name: string, cameraIndex: number): Camera;
  49695. /**
  49696. * @hidden
  49697. * @override
  49698. * Override Camera._updateRigCameras
  49699. */
  49700. _updateRigCameras(): void;
  49701. /**
  49702. * Destroy the camera and release the current resources hold by it.
  49703. */
  49704. dispose(): void;
  49705. /**
  49706. * Gets the current object class name.
  49707. * @return the class name
  49708. */
  49709. getClassName(): string;
  49710. }
  49711. }
  49712. declare module BABYLON {
  49713. /**
  49714. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  49715. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  49716. */
  49717. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  49718. /**
  49719. * Gets the name of the behavior.
  49720. */
  49721. get name(): string;
  49722. private _zoomStopsAnimation;
  49723. private _idleRotationSpeed;
  49724. private _idleRotationWaitTime;
  49725. private _idleRotationSpinupTime;
  49726. /**
  49727. * Sets the flag that indicates if user zooming should stop animation.
  49728. */
  49729. set zoomStopsAnimation(flag: boolean);
  49730. /**
  49731. * Gets the flag that indicates if user zooming should stop animation.
  49732. */
  49733. get zoomStopsAnimation(): boolean;
  49734. /**
  49735. * Sets the default speed at which the camera rotates around the model.
  49736. */
  49737. set idleRotationSpeed(speed: number);
  49738. /**
  49739. * Gets the default speed at which the camera rotates around the model.
  49740. */
  49741. get idleRotationSpeed(): number;
  49742. /**
  49743. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  49744. */
  49745. set idleRotationWaitTime(time: number);
  49746. /**
  49747. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  49748. */
  49749. get idleRotationWaitTime(): number;
  49750. /**
  49751. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49752. */
  49753. set idleRotationSpinupTime(time: number);
  49754. /**
  49755. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  49756. */
  49757. get idleRotationSpinupTime(): number;
  49758. /**
  49759. * Gets a value indicating if the camera is currently rotating because of this behavior
  49760. */
  49761. get rotationInProgress(): boolean;
  49762. private _onPrePointerObservableObserver;
  49763. private _onAfterCheckInputsObserver;
  49764. private _attachedCamera;
  49765. private _isPointerDown;
  49766. private _lastFrameTime;
  49767. private _lastInteractionTime;
  49768. private _cameraRotationSpeed;
  49769. /**
  49770. * Initializes the behavior.
  49771. */
  49772. init(): void;
  49773. /**
  49774. * Attaches the behavior to its arc rotate camera.
  49775. * @param camera Defines the camera to attach the behavior to
  49776. */
  49777. attach(camera: ArcRotateCamera): void;
  49778. /**
  49779. * Detaches the behavior from its current arc rotate camera.
  49780. */
  49781. detach(): void;
  49782. /**
  49783. * Returns true if user is scrolling.
  49784. * @return true if user is scrolling.
  49785. */
  49786. private _userIsZooming;
  49787. private _lastFrameRadius;
  49788. private _shouldAnimationStopForInteraction;
  49789. /**
  49790. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  49791. */
  49792. private _applyUserInteraction;
  49793. private _userIsMoving;
  49794. }
  49795. }
  49796. declare module BABYLON {
  49797. /**
  49798. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  49799. */
  49800. export class AttachToBoxBehavior implements Behavior<Mesh> {
  49801. private ui;
  49802. /**
  49803. * The name of the behavior
  49804. */
  49805. name: string;
  49806. /**
  49807. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  49808. */
  49809. distanceAwayFromFace: number;
  49810. /**
  49811. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  49812. */
  49813. distanceAwayFromBottomOfFace: number;
  49814. private _faceVectors;
  49815. private _target;
  49816. private _scene;
  49817. private _onRenderObserver;
  49818. private _tmpMatrix;
  49819. private _tmpVector;
  49820. /**
  49821. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  49822. * @param ui The transform node that should be attched to the mesh
  49823. */
  49824. constructor(ui: TransformNode);
  49825. /**
  49826. * Initializes the behavior
  49827. */
  49828. init(): void;
  49829. private _closestFace;
  49830. private _zeroVector;
  49831. private _lookAtTmpMatrix;
  49832. private _lookAtToRef;
  49833. /**
  49834. * Attaches the AttachToBoxBehavior to the passed in mesh
  49835. * @param target The mesh that the specified node will be attached to
  49836. */
  49837. attach(target: Mesh): void;
  49838. /**
  49839. * Detaches the behavior from the mesh
  49840. */
  49841. detach(): void;
  49842. }
  49843. }
  49844. declare module BABYLON {
  49845. /**
  49846. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  49847. */
  49848. export class FadeInOutBehavior implements Behavior<Mesh> {
  49849. /**
  49850. * Time in milliseconds to delay before fading in (Default: 0)
  49851. */
  49852. delay: number;
  49853. /**
  49854. * Time in milliseconds for the mesh to fade in (Default: 300)
  49855. */
  49856. fadeInTime: number;
  49857. private _millisecondsPerFrame;
  49858. private _hovered;
  49859. private _hoverValue;
  49860. private _ownerNode;
  49861. /**
  49862. * Instatiates the FadeInOutBehavior
  49863. */
  49864. constructor();
  49865. /**
  49866. * The name of the behavior
  49867. */
  49868. get name(): string;
  49869. /**
  49870. * Initializes the behavior
  49871. */
  49872. init(): void;
  49873. /**
  49874. * Attaches the fade behavior on the passed in mesh
  49875. * @param ownerNode The mesh that will be faded in/out once attached
  49876. */
  49877. attach(ownerNode: Mesh): void;
  49878. /**
  49879. * Detaches the behavior from the mesh
  49880. */
  49881. detach(): void;
  49882. /**
  49883. * Triggers the mesh to begin fading in or out
  49884. * @param value if the object should fade in or out (true to fade in)
  49885. */
  49886. fadeIn(value: boolean): void;
  49887. private _update;
  49888. private _setAllVisibility;
  49889. }
  49890. }
  49891. declare module BABYLON {
  49892. /**
  49893. * Class containing a set of static utilities functions for managing Pivots
  49894. * @hidden
  49895. */
  49896. export class PivotTools {
  49897. private static _PivotCached;
  49898. private static _OldPivotPoint;
  49899. private static _PivotTranslation;
  49900. private static _PivotTmpVector;
  49901. private static _PivotPostMultiplyPivotMatrix;
  49902. /** @hidden */
  49903. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  49904. /** @hidden */
  49905. static _RestorePivotPoint(mesh: AbstractMesh): void;
  49906. }
  49907. }
  49908. declare module BABYLON {
  49909. /**
  49910. * Class containing static functions to help procedurally build meshes
  49911. */
  49912. export class PlaneBuilder {
  49913. /**
  49914. * Creates a plane mesh
  49915. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  49916. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  49917. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  49918. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49919. * * 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
  49920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49921. * @param name defines the name of the mesh
  49922. * @param options defines the options used to create the mesh
  49923. * @param scene defines the hosting scene
  49924. * @returns the plane mesh
  49925. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  49926. */
  49927. static CreatePlane(name: string, options: {
  49928. size?: number;
  49929. width?: number;
  49930. height?: number;
  49931. sideOrientation?: number;
  49932. frontUVs?: Vector4;
  49933. backUVs?: Vector4;
  49934. updatable?: boolean;
  49935. sourcePlane?: Plane;
  49936. }, scene?: Nullable<Scene>): Mesh;
  49937. }
  49938. }
  49939. declare module BABYLON {
  49940. /**
  49941. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  49942. */
  49943. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  49944. private static _AnyMouseID;
  49945. /**
  49946. * Abstract mesh the behavior is set on
  49947. */
  49948. attachedNode: AbstractMesh;
  49949. private _dragPlane;
  49950. private _scene;
  49951. private _pointerObserver;
  49952. private _beforeRenderObserver;
  49953. private static _planeScene;
  49954. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  49955. /**
  49956. * 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)
  49957. */
  49958. maxDragAngle: number;
  49959. /**
  49960. * @hidden
  49961. */
  49962. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  49963. /**
  49964. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  49965. */
  49966. currentDraggingPointerID: number;
  49967. /**
  49968. * The last position where the pointer hit the drag plane in world space
  49969. */
  49970. lastDragPosition: Vector3;
  49971. /**
  49972. * If the behavior is currently in a dragging state
  49973. */
  49974. dragging: boolean;
  49975. /**
  49976. * 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)
  49977. */
  49978. dragDeltaRatio: number;
  49979. /**
  49980. * If the drag plane orientation should be updated during the dragging (Default: true)
  49981. */
  49982. updateDragPlane: boolean;
  49983. private _debugMode;
  49984. private _moving;
  49985. /**
  49986. * Fires each time the attached mesh is dragged with the pointer
  49987. * * delta between last drag position and current drag position in world space
  49988. * * dragDistance along the drag axis
  49989. * * dragPlaneNormal normal of the current drag plane used during the drag
  49990. * * dragPlanePoint in world space where the drag intersects the drag plane
  49991. */
  49992. onDragObservable: Observable<{
  49993. delta: Vector3;
  49994. dragPlanePoint: Vector3;
  49995. dragPlaneNormal: Vector3;
  49996. dragDistance: number;
  49997. pointerId: number;
  49998. }>;
  49999. /**
  50000. * Fires each time a drag begins (eg. mouse down on mesh)
  50001. */
  50002. onDragStartObservable: Observable<{
  50003. dragPlanePoint: Vector3;
  50004. pointerId: number;
  50005. }>;
  50006. /**
  50007. * Fires each time a drag ends (eg. mouse release after drag)
  50008. */
  50009. onDragEndObservable: Observable<{
  50010. dragPlanePoint: Vector3;
  50011. pointerId: number;
  50012. }>;
  50013. /**
  50014. * If the attached mesh should be moved when dragged
  50015. */
  50016. moveAttached: boolean;
  50017. /**
  50018. * If the drag behavior will react to drag events (Default: true)
  50019. */
  50020. enabled: boolean;
  50021. /**
  50022. * If pointer events should start and release the drag (Default: true)
  50023. */
  50024. startAndReleaseDragOnPointerEvents: boolean;
  50025. /**
  50026. * If camera controls should be detached during the drag
  50027. */
  50028. detachCameraControls: boolean;
  50029. /**
  50030. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  50031. */
  50032. useObjectOrientationForDragging: boolean;
  50033. private _options;
  50034. /**
  50035. * Gets the options used by the behavior
  50036. */
  50037. get options(): {
  50038. dragAxis?: Vector3;
  50039. dragPlaneNormal?: Vector3;
  50040. };
  50041. /**
  50042. * Sets the options used by the behavior
  50043. */
  50044. set options(options: {
  50045. dragAxis?: Vector3;
  50046. dragPlaneNormal?: Vector3;
  50047. });
  50048. /**
  50049. * Creates a pointer drag behavior that can be attached to a mesh
  50050. * @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)
  50051. */
  50052. constructor(options?: {
  50053. dragAxis?: Vector3;
  50054. dragPlaneNormal?: Vector3;
  50055. });
  50056. /**
  50057. * Predicate to determine if it is valid to move the object to a new position when it is moved
  50058. */
  50059. validateDrag: (targetPosition: Vector3) => boolean;
  50060. /**
  50061. * The name of the behavior
  50062. */
  50063. get name(): string;
  50064. /**
  50065. * Initializes the behavior
  50066. */
  50067. init(): void;
  50068. private _tmpVector;
  50069. private _alternatePickedPoint;
  50070. private _worldDragAxis;
  50071. private _targetPosition;
  50072. private _attachedToElement;
  50073. /**
  50074. * Attaches the drag behavior the passed in mesh
  50075. * @param ownerNode The mesh that will be dragged around once attached
  50076. * @param predicate Predicate to use for pick filtering
  50077. */
  50078. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  50079. /**
  50080. * Force relase the drag action by code.
  50081. */
  50082. releaseDrag(): void;
  50083. private _startDragRay;
  50084. private _lastPointerRay;
  50085. /**
  50086. * Simulates the start of a pointer drag event on the behavior
  50087. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  50088. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  50089. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  50090. */
  50091. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50092. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  50093. private _dragDelta;
  50094. protected _moveDrag(ray: Ray): void;
  50095. private _pickWithRayOnDragPlane;
  50096. private _pointA;
  50097. private _pointC;
  50098. private _localAxis;
  50099. private _lookAt;
  50100. private _updateDragPlanePosition;
  50101. /**
  50102. * Detaches the behavior from the mesh
  50103. */
  50104. detach(): void;
  50105. }
  50106. }
  50107. declare module BABYLON {
  50108. /**
  50109. * A behavior that when attached to a mesh will allow the mesh to be scaled
  50110. */
  50111. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  50112. private _dragBehaviorA;
  50113. private _dragBehaviorB;
  50114. private _startDistance;
  50115. private _initialScale;
  50116. private _targetScale;
  50117. private _ownerNode;
  50118. private _sceneRenderObserver;
  50119. /**
  50120. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  50121. */
  50122. constructor();
  50123. /**
  50124. * The name of the behavior
  50125. */
  50126. get name(): string;
  50127. /**
  50128. * Initializes the behavior
  50129. */
  50130. init(): void;
  50131. private _getCurrentDistance;
  50132. /**
  50133. * Attaches the scale behavior the passed in mesh
  50134. * @param ownerNode The mesh that will be scaled around once attached
  50135. */
  50136. attach(ownerNode: Mesh): void;
  50137. /**
  50138. * Detaches the behavior from the mesh
  50139. */
  50140. detach(): void;
  50141. }
  50142. }
  50143. declare module BABYLON {
  50144. /**
  50145. * 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
  50146. */
  50147. export class SixDofDragBehavior implements Behavior<Mesh> {
  50148. private static _virtualScene;
  50149. private _ownerNode;
  50150. private _sceneRenderObserver;
  50151. private _scene;
  50152. private _targetPosition;
  50153. private _virtualOriginMesh;
  50154. private _virtualDragMesh;
  50155. private _pointerObserver;
  50156. private _moving;
  50157. private _startingOrientation;
  50158. private _attachedToElement;
  50159. /**
  50160. * 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)
  50161. */
  50162. private zDragFactor;
  50163. /**
  50164. * If the object should rotate to face the drag origin
  50165. */
  50166. rotateDraggedObject: boolean;
  50167. /**
  50168. * If the behavior is currently in a dragging state
  50169. */
  50170. dragging: boolean;
  50171. /**
  50172. * 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)
  50173. */
  50174. dragDeltaRatio: number;
  50175. /**
  50176. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  50177. */
  50178. currentDraggingPointerID: number;
  50179. /**
  50180. * If camera controls should be detached during the drag
  50181. */
  50182. detachCameraControls: boolean;
  50183. /**
  50184. * Fires each time a drag starts
  50185. */
  50186. onDragStartObservable: Observable<{}>;
  50187. /**
  50188. * Fires each time a drag happens
  50189. */
  50190. onDragObservable: Observable<void>;
  50191. /**
  50192. * Fires each time a drag ends (eg. mouse release after drag)
  50193. */
  50194. onDragEndObservable: Observable<{}>;
  50195. /**
  50196. * 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
  50197. */
  50198. constructor();
  50199. /**
  50200. * The name of the behavior
  50201. */
  50202. get name(): string;
  50203. /**
  50204. * Initializes the behavior
  50205. */
  50206. init(): void;
  50207. /**
  50208. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  50209. */
  50210. private get _pointerCamera();
  50211. /**
  50212. * Attaches the scale behavior the passed in mesh
  50213. * @param ownerNode The mesh that will be scaled around once attached
  50214. */
  50215. attach(ownerNode: Mesh): void;
  50216. /**
  50217. * Detaches the behavior from the mesh
  50218. */
  50219. detach(): void;
  50220. }
  50221. }
  50222. declare module BABYLON {
  50223. /**
  50224. * Class used to apply inverse kinematics to bones
  50225. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  50226. */
  50227. export class BoneIKController {
  50228. private static _tmpVecs;
  50229. private static _tmpQuat;
  50230. private static _tmpMats;
  50231. /**
  50232. * Gets or sets the target mesh
  50233. */
  50234. targetMesh: AbstractMesh;
  50235. /** Gets or sets the mesh used as pole */
  50236. poleTargetMesh: AbstractMesh;
  50237. /**
  50238. * Gets or sets the bone used as pole
  50239. */
  50240. poleTargetBone: Nullable<Bone>;
  50241. /**
  50242. * Gets or sets the target position
  50243. */
  50244. targetPosition: Vector3;
  50245. /**
  50246. * Gets or sets the pole target position
  50247. */
  50248. poleTargetPosition: Vector3;
  50249. /**
  50250. * Gets or sets the pole target local offset
  50251. */
  50252. poleTargetLocalOffset: Vector3;
  50253. /**
  50254. * Gets or sets the pole angle
  50255. */
  50256. poleAngle: number;
  50257. /**
  50258. * Gets or sets the mesh associated with the controller
  50259. */
  50260. mesh: AbstractMesh;
  50261. /**
  50262. * 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)
  50263. */
  50264. slerpAmount: number;
  50265. private _bone1Quat;
  50266. private _bone1Mat;
  50267. private _bone2Ang;
  50268. private _bone1;
  50269. private _bone2;
  50270. private _bone1Length;
  50271. private _bone2Length;
  50272. private _maxAngle;
  50273. private _maxReach;
  50274. private _rightHandedSystem;
  50275. private _bendAxis;
  50276. private _slerping;
  50277. private _adjustRoll;
  50278. /**
  50279. * Gets or sets maximum allowed angle
  50280. */
  50281. get maxAngle(): number;
  50282. set maxAngle(value: number);
  50283. /**
  50284. * Creates a new BoneIKController
  50285. * @param mesh defines the mesh to control
  50286. * @param bone defines the bone to control
  50287. * @param options defines options to set up the controller
  50288. */
  50289. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  50290. targetMesh?: AbstractMesh;
  50291. poleTargetMesh?: AbstractMesh;
  50292. poleTargetBone?: Bone;
  50293. poleTargetLocalOffset?: Vector3;
  50294. poleAngle?: number;
  50295. bendAxis?: Vector3;
  50296. maxAngle?: number;
  50297. slerpAmount?: number;
  50298. });
  50299. private _setMaxAngle;
  50300. /**
  50301. * Force the controller to update the bones
  50302. */
  50303. update(): void;
  50304. }
  50305. }
  50306. declare module BABYLON {
  50307. /**
  50308. * Class used to make a bone look toward a point in space
  50309. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  50310. */
  50311. export class BoneLookController {
  50312. private static _tmpVecs;
  50313. private static _tmpQuat;
  50314. private static _tmpMats;
  50315. /**
  50316. * The target Vector3 that the bone will look at
  50317. */
  50318. target: Vector3;
  50319. /**
  50320. * The mesh that the bone is attached to
  50321. */
  50322. mesh: AbstractMesh;
  50323. /**
  50324. * The bone that will be looking to the target
  50325. */
  50326. bone: Bone;
  50327. /**
  50328. * The up axis of the coordinate system that is used when the bone is rotated
  50329. */
  50330. upAxis: Vector3;
  50331. /**
  50332. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  50333. */
  50334. upAxisSpace: Space;
  50335. /**
  50336. * Used to make an adjustment to the yaw of the bone
  50337. */
  50338. adjustYaw: number;
  50339. /**
  50340. * Used to make an adjustment to the pitch of the bone
  50341. */
  50342. adjustPitch: number;
  50343. /**
  50344. * Used to make an adjustment to the roll of the bone
  50345. */
  50346. adjustRoll: number;
  50347. /**
  50348. * 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)
  50349. */
  50350. slerpAmount: number;
  50351. private _minYaw;
  50352. private _maxYaw;
  50353. private _minPitch;
  50354. private _maxPitch;
  50355. private _minYawSin;
  50356. private _minYawCos;
  50357. private _maxYawSin;
  50358. private _maxYawCos;
  50359. private _midYawConstraint;
  50360. private _minPitchTan;
  50361. private _maxPitchTan;
  50362. private _boneQuat;
  50363. private _slerping;
  50364. private _transformYawPitch;
  50365. private _transformYawPitchInv;
  50366. private _firstFrameSkipped;
  50367. private _yawRange;
  50368. private _fowardAxis;
  50369. /**
  50370. * Gets or sets the minimum yaw angle that the bone can look to
  50371. */
  50372. get minYaw(): number;
  50373. set minYaw(value: number);
  50374. /**
  50375. * Gets or sets the maximum yaw angle that the bone can look to
  50376. */
  50377. get maxYaw(): number;
  50378. set maxYaw(value: number);
  50379. /**
  50380. * Gets or sets the minimum pitch angle that the bone can look to
  50381. */
  50382. get minPitch(): number;
  50383. set minPitch(value: number);
  50384. /**
  50385. * Gets or sets the maximum pitch angle that the bone can look to
  50386. */
  50387. get maxPitch(): number;
  50388. set maxPitch(value: number);
  50389. /**
  50390. * Create a BoneLookController
  50391. * @param mesh the mesh that the bone belongs to
  50392. * @param bone the bone that will be looking to the target
  50393. * @param target the target Vector3 to look at
  50394. * @param options optional settings:
  50395. * * maxYaw: the maximum angle the bone will yaw to
  50396. * * minYaw: the minimum angle the bone will yaw to
  50397. * * maxPitch: the maximum angle the bone will pitch to
  50398. * * minPitch: the minimum angle the bone will yaw to
  50399. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  50400. * * upAxis: the up axis of the coordinate system
  50401. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  50402. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  50403. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  50404. * * adjustYaw: used to make an adjustment to the yaw of the bone
  50405. * * adjustPitch: used to make an adjustment to the pitch of the bone
  50406. * * adjustRoll: used to make an adjustment to the roll of the bone
  50407. **/
  50408. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  50409. maxYaw?: number;
  50410. minYaw?: number;
  50411. maxPitch?: number;
  50412. minPitch?: number;
  50413. slerpAmount?: number;
  50414. upAxis?: Vector3;
  50415. upAxisSpace?: Space;
  50416. yawAxis?: Vector3;
  50417. pitchAxis?: Vector3;
  50418. adjustYaw?: number;
  50419. adjustPitch?: number;
  50420. adjustRoll?: number;
  50421. });
  50422. /**
  50423. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  50424. */
  50425. update(): void;
  50426. private _getAngleDiff;
  50427. private _getAngleBetween;
  50428. private _isAngleBetween;
  50429. }
  50430. }
  50431. declare module BABYLON {
  50432. /**
  50433. * Manage the gamepad inputs to control an arc rotate camera.
  50434. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50435. */
  50436. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  50437. /**
  50438. * Defines the camera the input is attached to.
  50439. */
  50440. camera: ArcRotateCamera;
  50441. /**
  50442. * Defines the gamepad the input is gathering event from.
  50443. */
  50444. gamepad: Nullable<Gamepad>;
  50445. /**
  50446. * Defines the gamepad rotation sensiblity.
  50447. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50448. */
  50449. gamepadRotationSensibility: number;
  50450. /**
  50451. * Defines the gamepad move sensiblity.
  50452. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50453. */
  50454. gamepadMoveSensibility: number;
  50455. private _yAxisScale;
  50456. /**
  50457. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50458. */
  50459. get invertYAxis(): boolean;
  50460. set invertYAxis(value: boolean);
  50461. private _onGamepadConnectedObserver;
  50462. private _onGamepadDisconnectedObserver;
  50463. /**
  50464. * Attach the input controls to a specific dom element to get the input from.
  50465. */
  50466. attachControl(): void;
  50467. /**
  50468. * Detach the current controls from the specified dom element.
  50469. */
  50470. detachControl(): void;
  50471. /**
  50472. * Update the current camera state depending on the inputs that have been used this frame.
  50473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50474. */
  50475. checkInputs(): void;
  50476. /**
  50477. * Gets the class name of the current intput.
  50478. * @returns the class name
  50479. */
  50480. getClassName(): string;
  50481. /**
  50482. * Get the friendly name associated with the input class.
  50483. * @returns the input friendly name
  50484. */
  50485. getSimpleName(): string;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. interface ArcRotateCameraInputsManager {
  50490. /**
  50491. * Add orientation input support to the input manager.
  50492. * @returns the current input manager
  50493. */
  50494. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  50495. }
  50496. /**
  50497. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  50498. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50499. */
  50500. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  50501. /**
  50502. * Defines the camera the input is attached to.
  50503. */
  50504. camera: ArcRotateCamera;
  50505. /**
  50506. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  50507. */
  50508. alphaCorrection: number;
  50509. /**
  50510. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  50511. */
  50512. gammaCorrection: number;
  50513. private _alpha;
  50514. private _gamma;
  50515. private _dirty;
  50516. private _deviceOrientationHandler;
  50517. /**
  50518. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  50519. */
  50520. constructor();
  50521. /**
  50522. * Attach the input controls to a specific dom element to get the input from.
  50523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50524. */
  50525. attachControl(noPreventDefault?: boolean): void;
  50526. /** @hidden */
  50527. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  50528. /**
  50529. * Update the current camera state depending on the inputs that have been used this frame.
  50530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50531. */
  50532. checkInputs(): void;
  50533. /**
  50534. * Detach the current controls from the specified dom element.
  50535. */
  50536. detachControl(): void;
  50537. /**
  50538. * Gets the class name of the current intput.
  50539. * @returns the class name
  50540. */
  50541. getClassName(): string;
  50542. /**
  50543. * Get the friendly name associated with the input class.
  50544. * @returns the input friendly name
  50545. */
  50546. getSimpleName(): string;
  50547. }
  50548. }
  50549. declare module BABYLON {
  50550. /**
  50551. * Listen to mouse events to control the camera.
  50552. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50553. */
  50554. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  50555. /**
  50556. * Defines the camera the input is attached to.
  50557. */
  50558. camera: FlyCamera;
  50559. /**
  50560. * Defines if touch is enabled. (Default is true.)
  50561. */
  50562. touchEnabled: boolean;
  50563. /**
  50564. * Defines the buttons associated with the input to handle camera rotation.
  50565. */
  50566. buttons: number[];
  50567. /**
  50568. * Assign buttons for Yaw control.
  50569. */
  50570. buttonsYaw: number[];
  50571. /**
  50572. * Assign buttons for Pitch control.
  50573. */
  50574. buttonsPitch: number[];
  50575. /**
  50576. * Assign buttons for Roll control.
  50577. */
  50578. buttonsRoll: number[];
  50579. /**
  50580. * Detect if any button is being pressed while mouse is moved.
  50581. * -1 = Mouse locked.
  50582. * 0 = Left button.
  50583. * 1 = Middle Button.
  50584. * 2 = Right Button.
  50585. */
  50586. activeButton: number;
  50587. /**
  50588. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  50589. * Higher values reduce its sensitivity.
  50590. */
  50591. angularSensibility: number;
  50592. private _observer;
  50593. private _rollObserver;
  50594. private previousPosition;
  50595. private noPreventDefault;
  50596. private element;
  50597. /**
  50598. * Listen to mouse events to control the camera.
  50599. * @param touchEnabled Define if touch is enabled. (Default is true.)
  50600. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50601. */
  50602. constructor(touchEnabled?: boolean);
  50603. /**
  50604. * Attach the mouse control to the HTML DOM element.
  50605. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  50606. */
  50607. attachControl(noPreventDefault?: boolean): void;
  50608. /**
  50609. * Detach the current controls from the specified dom element.
  50610. */
  50611. detachControl(): void;
  50612. /**
  50613. * Gets the class name of the current input.
  50614. * @returns the class name.
  50615. */
  50616. getClassName(): string;
  50617. /**
  50618. * Get the friendly name associated with the input class.
  50619. * @returns the input's friendly name.
  50620. */
  50621. getSimpleName(): string;
  50622. private _pointerInput;
  50623. private _onMouseMove;
  50624. /**
  50625. * Rotate camera by mouse offset.
  50626. */
  50627. private rotateCamera;
  50628. }
  50629. }
  50630. declare module BABYLON {
  50631. /**
  50632. * Default Inputs manager for the FlyCamera.
  50633. * It groups all the default supported inputs for ease of use.
  50634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50635. */
  50636. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  50637. /**
  50638. * Instantiates a new FlyCameraInputsManager.
  50639. * @param camera Defines the camera the inputs belong to.
  50640. */
  50641. constructor(camera: FlyCamera);
  50642. /**
  50643. * Add keyboard input support to the input manager.
  50644. * @returns the new FlyCameraKeyboardMoveInput().
  50645. */
  50646. addKeyboard(): FlyCameraInputsManager;
  50647. /**
  50648. * Add mouse input support to the input manager.
  50649. * @param touchEnabled Enable touch screen support.
  50650. * @returns the new FlyCameraMouseInput().
  50651. */
  50652. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  50653. }
  50654. }
  50655. declare module BABYLON {
  50656. /**
  50657. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50658. * such as in a 3D Space Shooter or a Flight Simulator.
  50659. */
  50660. export class FlyCamera extends TargetCamera {
  50661. /**
  50662. * Define the collision ellipsoid of the camera.
  50663. * This is helpful for simulating a camera body, like a player's body.
  50664. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  50665. */
  50666. ellipsoid: Vector3;
  50667. /**
  50668. * Define an offset for the position of the ellipsoid around the camera.
  50669. * This can be helpful if the camera is attached away from the player's body center,
  50670. * such as at its head.
  50671. */
  50672. ellipsoidOffset: Vector3;
  50673. /**
  50674. * Enable or disable collisions of the camera with the rest of the scene objects.
  50675. */
  50676. checkCollisions: boolean;
  50677. /**
  50678. * Enable or disable gravity on the camera.
  50679. */
  50680. applyGravity: boolean;
  50681. /**
  50682. * Define the current direction the camera is moving to.
  50683. */
  50684. cameraDirection: Vector3;
  50685. /**
  50686. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  50687. * This overrides and empties cameraRotation.
  50688. */
  50689. rotationQuaternion: Quaternion;
  50690. /**
  50691. * Track Roll to maintain the wanted Rolling when looking around.
  50692. */
  50693. _trackRoll: number;
  50694. /**
  50695. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  50696. */
  50697. rollCorrect: number;
  50698. /**
  50699. * Mimic a banked turn, Rolling the camera when Yawing.
  50700. * It's recommended to use rollCorrect = 10 for faster banking correction.
  50701. */
  50702. bankedTurn: boolean;
  50703. /**
  50704. * Limit in radians for how much Roll banking will add. (Default: 90°)
  50705. */
  50706. bankedTurnLimit: number;
  50707. /**
  50708. * Value of 0 disables the banked Roll.
  50709. * Value of 1 is equal to the Yaw angle in radians.
  50710. */
  50711. bankedTurnMultiplier: number;
  50712. /**
  50713. * The inputs manager loads all the input sources, such as keyboard and mouse.
  50714. */
  50715. inputs: FlyCameraInputsManager;
  50716. /**
  50717. * Gets the input sensibility for mouse input.
  50718. * Higher values reduce sensitivity.
  50719. */
  50720. get angularSensibility(): number;
  50721. /**
  50722. * Sets the input sensibility for a mouse input.
  50723. * Higher values reduce sensitivity.
  50724. */
  50725. set angularSensibility(value: number);
  50726. /**
  50727. * Get the keys for camera movement forward.
  50728. */
  50729. get keysForward(): number[];
  50730. /**
  50731. * Set the keys for camera movement forward.
  50732. */
  50733. set keysForward(value: number[]);
  50734. /**
  50735. * Get the keys for camera movement backward.
  50736. */
  50737. get keysBackward(): number[];
  50738. set keysBackward(value: number[]);
  50739. /**
  50740. * Get the keys for camera movement up.
  50741. */
  50742. get keysUp(): number[];
  50743. /**
  50744. * Set the keys for camera movement up.
  50745. */
  50746. set keysUp(value: number[]);
  50747. /**
  50748. * Get the keys for camera movement down.
  50749. */
  50750. get keysDown(): number[];
  50751. /**
  50752. * Set the keys for camera movement down.
  50753. */
  50754. set keysDown(value: number[]);
  50755. /**
  50756. * Get the keys for camera movement left.
  50757. */
  50758. get keysLeft(): number[];
  50759. /**
  50760. * Set the keys for camera movement left.
  50761. */
  50762. set keysLeft(value: number[]);
  50763. /**
  50764. * Set the keys for camera movement right.
  50765. */
  50766. get keysRight(): number[];
  50767. /**
  50768. * Set the keys for camera movement right.
  50769. */
  50770. set keysRight(value: number[]);
  50771. /**
  50772. * Event raised when the camera collides with a mesh in the scene.
  50773. */
  50774. onCollide: (collidedMesh: AbstractMesh) => void;
  50775. private _collider;
  50776. private _needMoveForGravity;
  50777. private _oldPosition;
  50778. private _diffPosition;
  50779. private _newPosition;
  50780. /** @hidden */
  50781. _localDirection: Vector3;
  50782. /** @hidden */
  50783. _transformedDirection: Vector3;
  50784. /**
  50785. * Instantiates a FlyCamera.
  50786. * This is a flying camera, designed for 3D movement and rotation in all directions,
  50787. * such as in a 3D Space Shooter or a Flight Simulator.
  50788. * @param name Define the name of the camera in the scene.
  50789. * @param position Define the starting position of the camera in the scene.
  50790. * @param scene Define the scene the camera belongs to.
  50791. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  50792. */
  50793. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  50794. /**
  50795. * Attach the input controls to a specific dom element to get the input from.
  50796. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50797. */
  50798. attachControl(noPreventDefault?: boolean): void;
  50799. /**
  50800. * Detach a control from the HTML DOM element.
  50801. * The camera will stop reacting to that input.
  50802. */
  50803. detachControl(): void;
  50804. private _collisionMask;
  50805. /**
  50806. * Get the mask that the camera ignores in collision events.
  50807. */
  50808. get collisionMask(): number;
  50809. /**
  50810. * Set the mask that the camera ignores in collision events.
  50811. */
  50812. set collisionMask(mask: number);
  50813. /** @hidden */
  50814. _collideWithWorld(displacement: Vector3): void;
  50815. /** @hidden */
  50816. private _onCollisionPositionChange;
  50817. /** @hidden */
  50818. _checkInputs(): void;
  50819. /** @hidden */
  50820. _decideIfNeedsToMove(): boolean;
  50821. /** @hidden */
  50822. _updatePosition(): void;
  50823. /**
  50824. * Restore the Roll to its target value at the rate specified.
  50825. * @param rate - Higher means slower restoring.
  50826. * @hidden
  50827. */
  50828. restoreRoll(rate: number): void;
  50829. /**
  50830. * Destroy the camera and release the current resources held by it.
  50831. */
  50832. dispose(): void;
  50833. /**
  50834. * Get the current object class name.
  50835. * @returns the class name.
  50836. */
  50837. getClassName(): string;
  50838. }
  50839. }
  50840. declare module BABYLON {
  50841. /**
  50842. * Listen to keyboard events to control the camera.
  50843. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50844. */
  50845. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  50846. /**
  50847. * Defines the camera the input is attached to.
  50848. */
  50849. camera: FlyCamera;
  50850. /**
  50851. * The list of keyboard keys used to control the forward move of the camera.
  50852. */
  50853. keysForward: number[];
  50854. /**
  50855. * The list of keyboard keys used to control the backward move of the camera.
  50856. */
  50857. keysBackward: number[];
  50858. /**
  50859. * The list of keyboard keys used to control the forward move of the camera.
  50860. */
  50861. keysUp: number[];
  50862. /**
  50863. * The list of keyboard keys used to control the backward move of the camera.
  50864. */
  50865. keysDown: number[];
  50866. /**
  50867. * The list of keyboard keys used to control the right strafe move of the camera.
  50868. */
  50869. keysRight: number[];
  50870. /**
  50871. * The list of keyboard keys used to control the left strafe move of the camera.
  50872. */
  50873. keysLeft: number[];
  50874. private _keys;
  50875. private _onCanvasBlurObserver;
  50876. private _onKeyboardObserver;
  50877. private _engine;
  50878. private _scene;
  50879. /**
  50880. * Attach the input controls to a specific dom element to get the input from.
  50881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50882. */
  50883. attachControl(noPreventDefault?: boolean): void;
  50884. /**
  50885. * Detach the current controls from the specified dom element.
  50886. */
  50887. detachControl(): void;
  50888. /**
  50889. * Gets the class name of the current intput.
  50890. * @returns the class name
  50891. */
  50892. getClassName(): string;
  50893. /** @hidden */
  50894. _onLostFocus(e: FocusEvent): void;
  50895. /**
  50896. * Get the friendly name associated with the input class.
  50897. * @returns the input friendly name
  50898. */
  50899. getSimpleName(): string;
  50900. /**
  50901. * Update the current camera state depending on the inputs that have been used this frame.
  50902. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50903. */
  50904. checkInputs(): void;
  50905. }
  50906. }
  50907. declare module BABYLON {
  50908. /**
  50909. * Manage the mouse wheel inputs to control a follow camera.
  50910. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50911. */
  50912. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  50913. /**
  50914. * Defines the camera the input is attached to.
  50915. */
  50916. camera: FollowCamera;
  50917. /**
  50918. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  50919. */
  50920. axisControlRadius: boolean;
  50921. /**
  50922. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  50923. */
  50924. axisControlHeight: boolean;
  50925. /**
  50926. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  50927. */
  50928. axisControlRotation: boolean;
  50929. /**
  50930. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  50931. * relation to mouseWheel events.
  50932. */
  50933. wheelPrecision: number;
  50934. /**
  50935. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  50936. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  50937. */
  50938. wheelDeltaPercentage: number;
  50939. private _wheel;
  50940. private _observer;
  50941. /**
  50942. * Attach the input controls to a specific dom element to get the input from.
  50943. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50944. */
  50945. attachControl(noPreventDefault?: boolean): void;
  50946. /**
  50947. * Detach the current controls from the specified dom element.
  50948. */
  50949. detachControl(): void;
  50950. /**
  50951. * Gets the class name of the current intput.
  50952. * @returns the class name
  50953. */
  50954. getClassName(): string;
  50955. /**
  50956. * Get the friendly name associated with the input class.
  50957. * @returns the input friendly name
  50958. */
  50959. getSimpleName(): string;
  50960. }
  50961. }
  50962. declare module BABYLON {
  50963. /**
  50964. * Manage the pointers inputs to control an follow camera.
  50965. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50966. */
  50967. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  50968. /**
  50969. * Defines the camera the input is attached to.
  50970. */
  50971. camera: FollowCamera;
  50972. /**
  50973. * Gets the class name of the current input.
  50974. * @returns the class name
  50975. */
  50976. getClassName(): string;
  50977. /**
  50978. * Defines the pointer angular sensibility along the X axis or how fast is
  50979. * the camera rotating.
  50980. * A negative number will reverse the axis direction.
  50981. */
  50982. angularSensibilityX: number;
  50983. /**
  50984. * Defines the pointer angular sensibility along the Y axis or how fast is
  50985. * the camera rotating.
  50986. * A negative number will reverse the axis direction.
  50987. */
  50988. angularSensibilityY: number;
  50989. /**
  50990. * Defines the pointer pinch precision or how fast is the camera zooming.
  50991. * A negative number will reverse the axis direction.
  50992. */
  50993. pinchPrecision: number;
  50994. /**
  50995. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  50996. * from 0.
  50997. * It defines the percentage of current camera.radius to use as delta when
  50998. * pinch zoom is used.
  50999. */
  51000. pinchDeltaPercentage: number;
  51001. /**
  51002. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  51003. */
  51004. axisXControlRadius: boolean;
  51005. /**
  51006. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  51007. */
  51008. axisXControlHeight: boolean;
  51009. /**
  51010. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  51011. */
  51012. axisXControlRotation: boolean;
  51013. /**
  51014. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  51015. */
  51016. axisYControlRadius: boolean;
  51017. /**
  51018. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  51019. */
  51020. axisYControlHeight: boolean;
  51021. /**
  51022. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  51023. */
  51024. axisYControlRotation: boolean;
  51025. /**
  51026. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  51027. */
  51028. axisPinchControlRadius: boolean;
  51029. /**
  51030. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  51031. */
  51032. axisPinchControlHeight: boolean;
  51033. /**
  51034. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  51035. */
  51036. axisPinchControlRotation: boolean;
  51037. /**
  51038. * Log error messages if basic misconfiguration has occurred.
  51039. */
  51040. warningEnable: boolean;
  51041. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  51042. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  51043. private _warningCounter;
  51044. private _warning;
  51045. }
  51046. }
  51047. declare module BABYLON {
  51048. /**
  51049. * Default Inputs manager for the FollowCamera.
  51050. * It groups all the default supported inputs for ease of use.
  51051. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51052. */
  51053. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  51054. /**
  51055. * Instantiates a new FollowCameraInputsManager.
  51056. * @param camera Defines the camera the inputs belong to
  51057. */
  51058. constructor(camera: FollowCamera);
  51059. /**
  51060. * Add keyboard input support to the input manager.
  51061. * @returns the current input manager
  51062. */
  51063. addKeyboard(): FollowCameraInputsManager;
  51064. /**
  51065. * Add mouse wheel input support to the input manager.
  51066. * @returns the current input manager
  51067. */
  51068. addMouseWheel(): FollowCameraInputsManager;
  51069. /**
  51070. * Add pointers input support to the input manager.
  51071. * @returns the current input manager
  51072. */
  51073. addPointers(): FollowCameraInputsManager;
  51074. /**
  51075. * Add orientation input support to the input manager.
  51076. * @returns the current input manager
  51077. */
  51078. addVRDeviceOrientation(): FollowCameraInputsManager;
  51079. }
  51080. }
  51081. declare module BABYLON {
  51082. /**
  51083. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  51084. * an arc rotate version arcFollowCamera are available.
  51085. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51086. */
  51087. export class FollowCamera extends TargetCamera {
  51088. /**
  51089. * Distance the follow camera should follow an object at
  51090. */
  51091. radius: number;
  51092. /**
  51093. * Minimum allowed distance of the camera to the axis of rotation
  51094. * (The camera can not get closer).
  51095. * This can help limiting how the Camera is able to move in the scene.
  51096. */
  51097. lowerRadiusLimit: Nullable<number>;
  51098. /**
  51099. * Maximum allowed distance of the camera to the axis of rotation
  51100. * (The camera can not get further).
  51101. * This can help limiting how the Camera is able to move in the scene.
  51102. */
  51103. upperRadiusLimit: Nullable<number>;
  51104. /**
  51105. * Define a rotation offset between the camera and the object it follows
  51106. */
  51107. rotationOffset: number;
  51108. /**
  51109. * Minimum allowed angle to camera position relative to target object.
  51110. * This can help limiting how the Camera is able to move in the scene.
  51111. */
  51112. lowerRotationOffsetLimit: Nullable<number>;
  51113. /**
  51114. * Maximum allowed angle to camera position relative to target object.
  51115. * This can help limiting how the Camera is able to move in the scene.
  51116. */
  51117. upperRotationOffsetLimit: Nullable<number>;
  51118. /**
  51119. * Define a height offset between the camera and the object it follows.
  51120. * It can help following an object from the top (like a car chaing a plane)
  51121. */
  51122. heightOffset: number;
  51123. /**
  51124. * Minimum allowed height of camera position relative to target object.
  51125. * This can help limiting how the Camera is able to move in the scene.
  51126. */
  51127. lowerHeightOffsetLimit: Nullable<number>;
  51128. /**
  51129. * Maximum allowed height of camera position relative to target object.
  51130. * This can help limiting how the Camera is able to move in the scene.
  51131. */
  51132. upperHeightOffsetLimit: Nullable<number>;
  51133. /**
  51134. * Define how fast the camera can accelerate to follow it s target.
  51135. */
  51136. cameraAcceleration: number;
  51137. /**
  51138. * Define the speed limit of the camera following an object.
  51139. */
  51140. maxCameraSpeed: number;
  51141. /**
  51142. * Define the target of the camera.
  51143. */
  51144. lockedTarget: Nullable<AbstractMesh>;
  51145. /**
  51146. * Defines the input associated with the camera.
  51147. */
  51148. inputs: FollowCameraInputsManager;
  51149. /**
  51150. * Instantiates the follow camera.
  51151. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51152. * @param name Define the name of the camera in the scene
  51153. * @param position Define the position of the camera
  51154. * @param scene Define the scene the camera belong to
  51155. * @param lockedTarget Define the target of the camera
  51156. */
  51157. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  51158. private _follow;
  51159. /**
  51160. * Attach the input controls to a specific dom element to get the input from.
  51161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51162. */
  51163. attachControl(noPreventDefault?: boolean): void;
  51164. /**
  51165. * Detach the current controls from the specified dom element.
  51166. */
  51167. detachControl(): void;
  51168. /** @hidden */
  51169. _checkInputs(): void;
  51170. private _checkLimits;
  51171. /**
  51172. * Gets the camera class name.
  51173. * @returns the class name
  51174. */
  51175. getClassName(): string;
  51176. }
  51177. /**
  51178. * Arc Rotate version of the follow camera.
  51179. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  51180. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51181. */
  51182. export class ArcFollowCamera extends TargetCamera {
  51183. /** The longitudinal angle of the camera */
  51184. alpha: number;
  51185. /** The latitudinal angle of the camera */
  51186. beta: number;
  51187. /** The radius of the camera from its target */
  51188. radius: number;
  51189. private _cartesianCoordinates;
  51190. /** Define the camera target (the mesh it should follow) */
  51191. private _meshTarget;
  51192. /**
  51193. * Instantiates a new ArcFollowCamera
  51194. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  51195. * @param name Define the name of the camera
  51196. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  51197. * @param beta Define the rotation angle of the camera around the elevation axis
  51198. * @param radius Define the radius of the camera from its target point
  51199. * @param target Define the target of the camera
  51200. * @param scene Define the scene the camera belongs to
  51201. */
  51202. constructor(name: string,
  51203. /** The longitudinal angle of the camera */
  51204. alpha: number,
  51205. /** The latitudinal angle of the camera */
  51206. beta: number,
  51207. /** The radius of the camera from its target */
  51208. radius: number,
  51209. /** Define the camera target (the mesh it should follow) */
  51210. target: Nullable<AbstractMesh>, scene: Scene);
  51211. private _follow;
  51212. /** @hidden */
  51213. _checkInputs(): void;
  51214. /**
  51215. * Returns the class name of the object.
  51216. * It is mostly used internally for serialization purposes.
  51217. */
  51218. getClassName(): string;
  51219. }
  51220. }
  51221. declare module BABYLON {
  51222. /**
  51223. * Manage the keyboard inputs to control the movement of a follow camera.
  51224. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51225. */
  51226. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  51227. /**
  51228. * Defines the camera the input is attached to.
  51229. */
  51230. camera: FollowCamera;
  51231. /**
  51232. * Defines the list of key codes associated with the up action (increase heightOffset)
  51233. */
  51234. keysHeightOffsetIncr: number[];
  51235. /**
  51236. * Defines the list of key codes associated with the down action (decrease heightOffset)
  51237. */
  51238. keysHeightOffsetDecr: number[];
  51239. /**
  51240. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  51241. */
  51242. keysHeightOffsetModifierAlt: boolean;
  51243. /**
  51244. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  51245. */
  51246. keysHeightOffsetModifierCtrl: boolean;
  51247. /**
  51248. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  51249. */
  51250. keysHeightOffsetModifierShift: boolean;
  51251. /**
  51252. * Defines the list of key codes associated with the left action (increase rotationOffset)
  51253. */
  51254. keysRotationOffsetIncr: number[];
  51255. /**
  51256. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  51257. */
  51258. keysRotationOffsetDecr: number[];
  51259. /**
  51260. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  51261. */
  51262. keysRotationOffsetModifierAlt: boolean;
  51263. /**
  51264. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  51265. */
  51266. keysRotationOffsetModifierCtrl: boolean;
  51267. /**
  51268. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  51269. */
  51270. keysRotationOffsetModifierShift: boolean;
  51271. /**
  51272. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  51273. */
  51274. keysRadiusIncr: number[];
  51275. /**
  51276. * Defines the list of key codes associated with the zoom-out action (increase radius)
  51277. */
  51278. keysRadiusDecr: number[];
  51279. /**
  51280. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  51281. */
  51282. keysRadiusModifierAlt: boolean;
  51283. /**
  51284. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  51285. */
  51286. keysRadiusModifierCtrl: boolean;
  51287. /**
  51288. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  51289. */
  51290. keysRadiusModifierShift: boolean;
  51291. /**
  51292. * Defines the rate of change of heightOffset.
  51293. */
  51294. heightSensibility: number;
  51295. /**
  51296. * Defines the rate of change of rotationOffset.
  51297. */
  51298. rotationSensibility: number;
  51299. /**
  51300. * Defines the rate of change of radius.
  51301. */
  51302. radiusSensibility: number;
  51303. private _keys;
  51304. private _ctrlPressed;
  51305. private _altPressed;
  51306. private _shiftPressed;
  51307. private _onCanvasBlurObserver;
  51308. private _onKeyboardObserver;
  51309. private _engine;
  51310. private _scene;
  51311. /**
  51312. * Attach the input controls to a specific dom element to get the input from.
  51313. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  51314. */
  51315. attachControl(noPreventDefault?: boolean): void;
  51316. /**
  51317. * Detach the current controls from the specified dom element.
  51318. */
  51319. detachControl(): void;
  51320. /**
  51321. * Update the current camera state depending on the inputs that have been used this frame.
  51322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51323. */
  51324. checkInputs(): void;
  51325. /**
  51326. * Gets the class name of the current input.
  51327. * @returns the class name
  51328. */
  51329. getClassName(): string;
  51330. /**
  51331. * Get the friendly name associated with the input class.
  51332. * @returns the input friendly name
  51333. */
  51334. getSimpleName(): string;
  51335. /**
  51336. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51337. * allow modification of the heightOffset value.
  51338. */
  51339. private _modifierHeightOffset;
  51340. /**
  51341. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51342. * allow modification of the rotationOffset value.
  51343. */
  51344. private _modifierRotationOffset;
  51345. /**
  51346. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  51347. * allow modification of the radius value.
  51348. */
  51349. private _modifierRadius;
  51350. }
  51351. }
  51352. declare module BABYLON {
  51353. interface FreeCameraInputsManager {
  51354. /**
  51355. * @hidden
  51356. */
  51357. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  51358. /**
  51359. * Add orientation input support to the input manager.
  51360. * @returns the current input manager
  51361. */
  51362. addDeviceOrientation(): FreeCameraInputsManager;
  51363. }
  51364. /**
  51365. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  51366. * Screen rotation is taken into account.
  51367. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51368. */
  51369. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  51370. private _camera;
  51371. private _screenOrientationAngle;
  51372. private _constantTranform;
  51373. private _screenQuaternion;
  51374. private _alpha;
  51375. private _beta;
  51376. private _gamma;
  51377. /**
  51378. * Can be used to detect if a device orientation sensor is available on a device
  51379. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  51380. * @returns a promise that will resolve on orientation change
  51381. */
  51382. static WaitForOrientationChangeAsync(timeout?: number): Promise<void>;
  51383. /**
  51384. * @hidden
  51385. */
  51386. _onDeviceOrientationChangedObservable: Observable<void>;
  51387. /**
  51388. * Instantiates a new input
  51389. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51390. */
  51391. constructor();
  51392. /**
  51393. * Define the camera controlled by the input.
  51394. */
  51395. get camera(): FreeCamera;
  51396. set camera(camera: FreeCamera);
  51397. /**
  51398. * Attach the input controls to a specific dom element to get the input from.
  51399. */
  51400. attachControl(): void;
  51401. private _orientationChanged;
  51402. private _deviceOrientation;
  51403. /**
  51404. * Detach the current controls from the specified dom element.
  51405. */
  51406. detachControl(): void;
  51407. /**
  51408. * Update the current camera state depending on the inputs that have been used this frame.
  51409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51410. */
  51411. checkInputs(): void;
  51412. /**
  51413. * Gets the class name of the current intput.
  51414. * @returns the class name
  51415. */
  51416. getClassName(): string;
  51417. /**
  51418. * Get the friendly name associated with the input class.
  51419. * @returns the input friendly name
  51420. */
  51421. getSimpleName(): string;
  51422. }
  51423. }
  51424. declare module BABYLON {
  51425. /**
  51426. * Manage the gamepad inputs to control a free camera.
  51427. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51428. */
  51429. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  51430. /**
  51431. * Define the camera the input is attached to.
  51432. */
  51433. camera: FreeCamera;
  51434. /**
  51435. * Define the Gamepad controlling the input
  51436. */
  51437. gamepad: Nullable<Gamepad>;
  51438. /**
  51439. * Defines the gamepad rotation sensiblity.
  51440. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51441. */
  51442. gamepadAngularSensibility: number;
  51443. /**
  51444. * Defines the gamepad move sensiblity.
  51445. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51446. */
  51447. gamepadMoveSensibility: number;
  51448. private _yAxisScale;
  51449. /**
  51450. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  51451. */
  51452. get invertYAxis(): boolean;
  51453. set invertYAxis(value: boolean);
  51454. private _onGamepadConnectedObserver;
  51455. private _onGamepadDisconnectedObserver;
  51456. private _cameraTransform;
  51457. private _deltaTransform;
  51458. private _vector3;
  51459. private _vector2;
  51460. /**
  51461. * Attach the input controls to a specific dom element to get the input from.
  51462. */
  51463. attachControl(): void;
  51464. /**
  51465. * Detach the current controls from the specified dom element.
  51466. */
  51467. detachControl(): void;
  51468. /**
  51469. * Update the current camera state depending on the inputs that have been used this frame.
  51470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51471. */
  51472. checkInputs(): void;
  51473. /**
  51474. * Gets the class name of the current intput.
  51475. * @returns the class name
  51476. */
  51477. getClassName(): string;
  51478. /**
  51479. * Get the friendly name associated with the input class.
  51480. * @returns the input friendly name
  51481. */
  51482. getSimpleName(): string;
  51483. }
  51484. }
  51485. declare module BABYLON {
  51486. /**
  51487. * Defines the potential axis of a Joystick
  51488. */
  51489. export enum JoystickAxis {
  51490. /** X axis */
  51491. X = 0,
  51492. /** Y axis */
  51493. Y = 1,
  51494. /** Z axis */
  51495. Z = 2
  51496. }
  51497. /**
  51498. * Represents the different customization options available
  51499. * for VirtualJoystick
  51500. */
  51501. interface VirtualJoystickCustomizations {
  51502. /**
  51503. * Size of the joystick's puck
  51504. */
  51505. puckSize: number;
  51506. /**
  51507. * Size of the joystick's container
  51508. */
  51509. containerSize: number;
  51510. /**
  51511. * Color of the joystick && puck
  51512. */
  51513. color: string;
  51514. /**
  51515. * Image URL for the joystick's puck
  51516. */
  51517. puckImage?: string;
  51518. /**
  51519. * Image URL for the joystick's container
  51520. */
  51521. containerImage?: string;
  51522. /**
  51523. * Defines the unmoving position of the joystick container
  51524. */
  51525. position?: {
  51526. x: number;
  51527. y: number;
  51528. };
  51529. /**
  51530. * Defines whether or not the joystick container is always visible
  51531. */
  51532. alwaysVisible: boolean;
  51533. /**
  51534. * Defines whether or not to limit the movement of the puck to the joystick's container
  51535. */
  51536. limitToContainer: boolean;
  51537. }
  51538. /**
  51539. * Class used to define virtual joystick (used in touch mode)
  51540. */
  51541. export class VirtualJoystick {
  51542. /**
  51543. * Gets or sets a boolean indicating that left and right values must be inverted
  51544. */
  51545. reverseLeftRight: boolean;
  51546. /**
  51547. * Gets or sets a boolean indicating that up and down values must be inverted
  51548. */
  51549. reverseUpDown: boolean;
  51550. /**
  51551. * Gets the offset value for the position (ie. the change of the position value)
  51552. */
  51553. deltaPosition: Vector3;
  51554. /**
  51555. * Gets a boolean indicating if the virtual joystick was pressed
  51556. */
  51557. pressed: boolean;
  51558. /**
  51559. * Canvas the virtual joystick will render onto, default z-index of this is 5
  51560. */
  51561. static Canvas: Nullable<HTMLCanvasElement>;
  51562. /**
  51563. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  51564. */
  51565. limitToContainer: boolean;
  51566. private static _globalJoystickIndex;
  51567. private static _alwaysVisibleSticks;
  51568. private static vjCanvasContext;
  51569. private static vjCanvasWidth;
  51570. private static vjCanvasHeight;
  51571. private static halfWidth;
  51572. private static _GetDefaultOptions;
  51573. private _action;
  51574. private _axisTargetedByLeftAndRight;
  51575. private _axisTargetedByUpAndDown;
  51576. private _joystickSensibility;
  51577. private _inversedSensibility;
  51578. private _joystickPointerID;
  51579. private _joystickColor;
  51580. private _joystickPointerPos;
  51581. private _joystickPreviousPointerPos;
  51582. private _joystickPointerStartPos;
  51583. private _deltaJoystickVector;
  51584. private _leftJoystick;
  51585. private _touches;
  51586. private _joystickPosition;
  51587. private _alwaysVisible;
  51588. private _puckImage;
  51589. private _containerImage;
  51590. private _joystickPuckSize;
  51591. private _joystickContainerSize;
  51592. private _clearPuckSize;
  51593. private _clearContainerSize;
  51594. private _clearPuckSizeOffset;
  51595. private _clearContainerSizeOffset;
  51596. private _onPointerDownHandlerRef;
  51597. private _onPointerMoveHandlerRef;
  51598. private _onPointerUpHandlerRef;
  51599. private _onResize;
  51600. /**
  51601. * Creates a new virtual joystick
  51602. * @param leftJoystick defines that the joystick is for left hand (false by default)
  51603. * @param customizations Defines the options we want to customize the VirtualJoystick
  51604. */
  51605. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  51606. /**
  51607. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  51608. * @param newJoystickSensibility defines the new sensibility
  51609. */
  51610. setJoystickSensibility(newJoystickSensibility: number): void;
  51611. private _onPointerDown;
  51612. private _onPointerMove;
  51613. private _onPointerUp;
  51614. /**
  51615. * Change the color of the virtual joystick
  51616. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  51617. */
  51618. setJoystickColor(newColor: string): void;
  51619. /**
  51620. * Size of the joystick's container
  51621. */
  51622. set containerSize(newSize: number);
  51623. get containerSize(): number;
  51624. /**
  51625. * Size of the joystick's puck
  51626. */
  51627. set puckSize(newSize: number);
  51628. get puckSize(): number;
  51629. /**
  51630. * Clears the set position of the joystick
  51631. */
  51632. clearPosition(): void;
  51633. /**
  51634. * Defines whether or not the joystick container is always visible
  51635. */
  51636. set alwaysVisible(value: boolean);
  51637. get alwaysVisible(): boolean;
  51638. /**
  51639. * Sets the constant position of the Joystick container
  51640. * @param x X axis coordinate
  51641. * @param y Y axis coordinate
  51642. */
  51643. setPosition(x: number, y: number): void;
  51644. /**
  51645. * Defines a callback to call when the joystick is touched
  51646. * @param action defines the callback
  51647. */
  51648. setActionOnTouch(action: () => any): void;
  51649. /**
  51650. * Defines which axis you'd like to control for left & right
  51651. * @param axis defines the axis to use
  51652. */
  51653. setAxisForLeftRight(axis: JoystickAxis): void;
  51654. /**
  51655. * Defines which axis you'd like to control for up & down
  51656. * @param axis defines the axis to use
  51657. */
  51658. setAxisForUpDown(axis: JoystickAxis): void;
  51659. /**
  51660. * Clears the canvas from the previous puck / container draw
  51661. */
  51662. private _clearPreviousDraw;
  51663. /**
  51664. * Loads `urlPath` to be used for the container's image
  51665. * @param urlPath defines the urlPath of an image to use
  51666. */
  51667. setContainerImage(urlPath: string): void;
  51668. /**
  51669. * Loads `urlPath` to be used for the puck's image
  51670. * @param urlPath defines the urlPath of an image to use
  51671. */
  51672. setPuckImage(urlPath: string): void;
  51673. /**
  51674. * Draws the Virtual Joystick's container
  51675. */
  51676. private _drawContainer;
  51677. /**
  51678. * Draws the Virtual Joystick's puck
  51679. */
  51680. private _drawPuck;
  51681. private _drawVirtualJoystick;
  51682. /**
  51683. * Release internal HTML canvas
  51684. */
  51685. releaseCanvas(): void;
  51686. }
  51687. }
  51688. declare module BABYLON {
  51689. interface FreeCameraInputsManager {
  51690. /**
  51691. * Add virtual joystick input support to the input manager.
  51692. * @returns the current input manager
  51693. */
  51694. addVirtualJoystick(): FreeCameraInputsManager;
  51695. }
  51696. /**
  51697. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  51698. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  51699. */
  51700. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  51701. /**
  51702. * Defines the camera the input is attached to.
  51703. */
  51704. camera: FreeCamera;
  51705. private _leftjoystick;
  51706. private _rightjoystick;
  51707. /**
  51708. * Gets the left stick of the virtual joystick.
  51709. * @returns The virtual Joystick
  51710. */
  51711. getLeftJoystick(): VirtualJoystick;
  51712. /**
  51713. * Gets the right stick of the virtual joystick.
  51714. * @returns The virtual Joystick
  51715. */
  51716. getRightJoystick(): VirtualJoystick;
  51717. /**
  51718. * Update the current camera state depending on the inputs that have been used this frame.
  51719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  51720. */
  51721. checkInputs(): void;
  51722. /**
  51723. * Attach the input controls to a specific dom element to get the input from.
  51724. */
  51725. attachControl(): void;
  51726. /**
  51727. * Detach the current controls from the specified dom element.
  51728. */
  51729. detachControl(): void;
  51730. /**
  51731. * Gets the class name of the current intput.
  51732. * @returns the class name
  51733. */
  51734. getClassName(): string;
  51735. /**
  51736. * Get the friendly name associated with the input class.
  51737. * @returns the input friendly name
  51738. */
  51739. getSimpleName(): string;
  51740. }
  51741. }
  51742. declare module BABYLON {
  51743. /**
  51744. * This represents a FPS type of camera controlled by touch.
  51745. * This is like a universal camera minus the Gamepad controls.
  51746. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51747. */
  51748. export class TouchCamera extends FreeCamera {
  51749. /**
  51750. * Defines the touch sensibility for rotation.
  51751. * The higher the faster.
  51752. */
  51753. get touchAngularSensibility(): number;
  51754. set touchAngularSensibility(value: number);
  51755. /**
  51756. * Defines the touch sensibility for move.
  51757. * The higher the faster.
  51758. */
  51759. get touchMoveSensibility(): number;
  51760. set touchMoveSensibility(value: number);
  51761. /**
  51762. * Instantiates a new touch camera.
  51763. * This represents a FPS type of camera controlled by touch.
  51764. * This is like a universal camera minus the Gamepad controls.
  51765. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51766. * @param name Define the name of the camera in the scene
  51767. * @param position Define the start position of the camera in the scene
  51768. * @param scene Define the scene the camera belongs to
  51769. */
  51770. constructor(name: string, position: Vector3, scene: Scene);
  51771. /**
  51772. * Gets the current object class name.
  51773. * @return the class name
  51774. */
  51775. getClassName(): string;
  51776. /** @hidden */
  51777. _setupInputs(): void;
  51778. }
  51779. }
  51780. declare module BABYLON {
  51781. /**
  51782. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  51783. * being tilted forward or back and left or right.
  51784. */
  51785. export class DeviceOrientationCamera extends FreeCamera {
  51786. private _initialQuaternion;
  51787. private _quaternionCache;
  51788. private _tmpDragQuaternion;
  51789. private _disablePointerInputWhenUsingDeviceOrientation;
  51790. /**
  51791. * Creates a new device orientation camera
  51792. * @param name The name of the camera
  51793. * @param position The start position camera
  51794. * @param scene The scene the camera belongs to
  51795. */
  51796. constructor(name: string, position: Vector3, scene: Scene);
  51797. /**
  51798. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  51799. */
  51800. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  51801. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  51802. private _dragFactor;
  51803. /**
  51804. * Enabled turning on the y axis when the orientation sensor is active
  51805. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  51806. */
  51807. enableHorizontalDragging(dragFactor?: number): void;
  51808. /**
  51809. * Gets the current instance class name ("DeviceOrientationCamera").
  51810. * This helps avoiding instanceof at run time.
  51811. * @returns the class name
  51812. */
  51813. getClassName(): string;
  51814. /**
  51815. * @hidden
  51816. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  51817. */
  51818. _checkInputs(): void;
  51819. /**
  51820. * Reset the camera to its default orientation on the specified axis only.
  51821. * @param axis The axis to reset
  51822. */
  51823. resetToCurrentRotation(axis?: Axis): void;
  51824. }
  51825. }
  51826. declare module BABYLON {
  51827. /**
  51828. * Defines supported buttons for XBox360 compatible gamepads
  51829. */
  51830. export enum Xbox360Button {
  51831. /** A */
  51832. A = 0,
  51833. /** B */
  51834. B = 1,
  51835. /** X */
  51836. X = 2,
  51837. /** Y */
  51838. Y = 3,
  51839. /** Left button */
  51840. LB = 4,
  51841. /** Right button */
  51842. RB = 5,
  51843. /** Back */
  51844. Back = 8,
  51845. /** Start */
  51846. Start = 9,
  51847. /** Left stick */
  51848. LeftStick = 10,
  51849. /** Right stick */
  51850. RightStick = 11
  51851. }
  51852. /** Defines values for XBox360 DPad */
  51853. export enum Xbox360Dpad {
  51854. /** Up */
  51855. Up = 12,
  51856. /** Down */
  51857. Down = 13,
  51858. /** Left */
  51859. Left = 14,
  51860. /** Right */
  51861. Right = 15
  51862. }
  51863. /**
  51864. * Defines a XBox360 gamepad
  51865. */
  51866. export class Xbox360Pad extends Gamepad {
  51867. private _leftTrigger;
  51868. private _rightTrigger;
  51869. private _onlefttriggerchanged;
  51870. private _onrighttriggerchanged;
  51871. private _onbuttondown;
  51872. private _onbuttonup;
  51873. private _ondpaddown;
  51874. private _ondpadup;
  51875. /** Observable raised when a button is pressed */
  51876. onButtonDownObservable: Observable<Xbox360Button>;
  51877. /** Observable raised when a button is released */
  51878. onButtonUpObservable: Observable<Xbox360Button>;
  51879. /** Observable raised when a pad is pressed */
  51880. onPadDownObservable: Observable<Xbox360Dpad>;
  51881. /** Observable raised when a pad is released */
  51882. onPadUpObservable: Observable<Xbox360Dpad>;
  51883. private _buttonA;
  51884. private _buttonB;
  51885. private _buttonX;
  51886. private _buttonY;
  51887. private _buttonBack;
  51888. private _buttonStart;
  51889. private _buttonLB;
  51890. private _buttonRB;
  51891. private _buttonLeftStick;
  51892. private _buttonRightStick;
  51893. private _dPadUp;
  51894. private _dPadDown;
  51895. private _dPadLeft;
  51896. private _dPadRight;
  51897. private _isXboxOnePad;
  51898. /**
  51899. * Creates a new XBox360 gamepad object
  51900. * @param id defines the id of this gamepad
  51901. * @param index defines its index
  51902. * @param gamepad defines the internal HTML gamepad object
  51903. * @param xboxOne defines if it is a XBox One gamepad
  51904. */
  51905. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  51906. /**
  51907. * Defines the callback to call when left trigger is pressed
  51908. * @param callback defines the callback to use
  51909. */
  51910. onlefttriggerchanged(callback: (value: number) => void): void;
  51911. /**
  51912. * Defines the callback to call when right trigger is pressed
  51913. * @param callback defines the callback to use
  51914. */
  51915. onrighttriggerchanged(callback: (value: number) => void): void;
  51916. /**
  51917. * Gets the left trigger value
  51918. */
  51919. get leftTrigger(): number;
  51920. /**
  51921. * Sets the left trigger value
  51922. */
  51923. set leftTrigger(newValue: number);
  51924. /**
  51925. * Gets the right trigger value
  51926. */
  51927. get rightTrigger(): number;
  51928. /**
  51929. * Sets the right trigger value
  51930. */
  51931. set rightTrigger(newValue: number);
  51932. /**
  51933. * Defines the callback to call when a button is pressed
  51934. * @param callback defines the callback to use
  51935. */
  51936. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  51937. /**
  51938. * Defines the callback to call when a button is released
  51939. * @param callback defines the callback to use
  51940. */
  51941. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  51942. /**
  51943. * Defines the callback to call when a pad is pressed
  51944. * @param callback defines the callback to use
  51945. */
  51946. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  51947. /**
  51948. * Defines the callback to call when a pad is released
  51949. * @param callback defines the callback to use
  51950. */
  51951. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  51952. private _setButtonValue;
  51953. private _setDPadValue;
  51954. /**
  51955. * Gets the value of the `A` button
  51956. */
  51957. get buttonA(): number;
  51958. /**
  51959. * Sets the value of the `A` button
  51960. */
  51961. set buttonA(value: number);
  51962. /**
  51963. * Gets the value of the `B` button
  51964. */
  51965. get buttonB(): number;
  51966. /**
  51967. * Sets the value of the `B` button
  51968. */
  51969. set buttonB(value: number);
  51970. /**
  51971. * Gets the value of the `X` button
  51972. */
  51973. get buttonX(): number;
  51974. /**
  51975. * Sets the value of the `X` button
  51976. */
  51977. set buttonX(value: number);
  51978. /**
  51979. * Gets the value of the `Y` button
  51980. */
  51981. get buttonY(): number;
  51982. /**
  51983. * Sets the value of the `Y` button
  51984. */
  51985. set buttonY(value: number);
  51986. /**
  51987. * Gets the value of the `Start` button
  51988. */
  51989. get buttonStart(): number;
  51990. /**
  51991. * Sets the value of the `Start` button
  51992. */
  51993. set buttonStart(value: number);
  51994. /**
  51995. * Gets the value of the `Back` button
  51996. */
  51997. get buttonBack(): number;
  51998. /**
  51999. * Sets the value of the `Back` button
  52000. */
  52001. set buttonBack(value: number);
  52002. /**
  52003. * Gets the value of the `Left` button
  52004. */
  52005. get buttonLB(): number;
  52006. /**
  52007. * Sets the value of the `Left` button
  52008. */
  52009. set buttonLB(value: number);
  52010. /**
  52011. * Gets the value of the `Right` button
  52012. */
  52013. get buttonRB(): number;
  52014. /**
  52015. * Sets the value of the `Right` button
  52016. */
  52017. set buttonRB(value: number);
  52018. /**
  52019. * Gets the value of the Left joystick
  52020. */
  52021. get buttonLeftStick(): number;
  52022. /**
  52023. * Sets the value of the Left joystick
  52024. */
  52025. set buttonLeftStick(value: number);
  52026. /**
  52027. * Gets the value of the Right joystick
  52028. */
  52029. get buttonRightStick(): number;
  52030. /**
  52031. * Sets the value of the Right joystick
  52032. */
  52033. set buttonRightStick(value: number);
  52034. /**
  52035. * Gets the value of D-pad up
  52036. */
  52037. get dPadUp(): number;
  52038. /**
  52039. * Sets the value of D-pad up
  52040. */
  52041. set dPadUp(value: number);
  52042. /**
  52043. * Gets the value of D-pad down
  52044. */
  52045. get dPadDown(): number;
  52046. /**
  52047. * Sets the value of D-pad down
  52048. */
  52049. set dPadDown(value: number);
  52050. /**
  52051. * Gets the value of D-pad left
  52052. */
  52053. get dPadLeft(): number;
  52054. /**
  52055. * Sets the value of D-pad left
  52056. */
  52057. set dPadLeft(value: number);
  52058. /**
  52059. * Gets the value of D-pad right
  52060. */
  52061. get dPadRight(): number;
  52062. /**
  52063. * Sets the value of D-pad right
  52064. */
  52065. set dPadRight(value: number);
  52066. /**
  52067. * Force the gamepad to synchronize with device values
  52068. */
  52069. update(): void;
  52070. /**
  52071. * Disposes the gamepad
  52072. */
  52073. dispose(): void;
  52074. }
  52075. }
  52076. declare module BABYLON {
  52077. /**
  52078. * Defines supported buttons for DualShock compatible gamepads
  52079. */
  52080. export enum DualShockButton {
  52081. /** Cross */
  52082. Cross = 0,
  52083. /** Circle */
  52084. Circle = 1,
  52085. /** Square */
  52086. Square = 2,
  52087. /** Triangle */
  52088. Triangle = 3,
  52089. /** L1 */
  52090. L1 = 4,
  52091. /** R1 */
  52092. R1 = 5,
  52093. /** Share */
  52094. Share = 8,
  52095. /** Options */
  52096. Options = 9,
  52097. /** Left stick */
  52098. LeftStick = 10,
  52099. /** Right stick */
  52100. RightStick = 11
  52101. }
  52102. /** Defines values for DualShock DPad */
  52103. export enum DualShockDpad {
  52104. /** Up */
  52105. Up = 12,
  52106. /** Down */
  52107. Down = 13,
  52108. /** Left */
  52109. Left = 14,
  52110. /** Right */
  52111. Right = 15
  52112. }
  52113. /**
  52114. * Defines a DualShock gamepad
  52115. */
  52116. export class DualShockPad extends Gamepad {
  52117. private _leftTrigger;
  52118. private _rightTrigger;
  52119. private _onlefttriggerchanged;
  52120. private _onrighttriggerchanged;
  52121. private _onbuttondown;
  52122. private _onbuttonup;
  52123. private _ondpaddown;
  52124. private _ondpadup;
  52125. /** Observable raised when a button is pressed */
  52126. onButtonDownObservable: Observable<DualShockButton>;
  52127. /** Observable raised when a button is released */
  52128. onButtonUpObservable: Observable<DualShockButton>;
  52129. /** Observable raised when a pad is pressed */
  52130. onPadDownObservable: Observable<DualShockDpad>;
  52131. /** Observable raised when a pad is released */
  52132. onPadUpObservable: Observable<DualShockDpad>;
  52133. private _buttonCross;
  52134. private _buttonCircle;
  52135. private _buttonSquare;
  52136. private _buttonTriangle;
  52137. private _buttonShare;
  52138. private _buttonOptions;
  52139. private _buttonL1;
  52140. private _buttonR1;
  52141. private _buttonLeftStick;
  52142. private _buttonRightStick;
  52143. private _dPadUp;
  52144. private _dPadDown;
  52145. private _dPadLeft;
  52146. private _dPadRight;
  52147. /**
  52148. * Creates a new DualShock gamepad object
  52149. * @param id defines the id of this gamepad
  52150. * @param index defines its index
  52151. * @param gamepad defines the internal HTML gamepad object
  52152. */
  52153. constructor(id: string, index: number, gamepad: any);
  52154. /**
  52155. * Defines the callback to call when left trigger is pressed
  52156. * @param callback defines the callback to use
  52157. */
  52158. onlefttriggerchanged(callback: (value: number) => void): void;
  52159. /**
  52160. * Defines the callback to call when right trigger is pressed
  52161. * @param callback defines the callback to use
  52162. */
  52163. onrighttriggerchanged(callback: (value: number) => void): void;
  52164. /**
  52165. * Gets the left trigger value
  52166. */
  52167. get leftTrigger(): number;
  52168. /**
  52169. * Sets the left trigger value
  52170. */
  52171. set leftTrigger(newValue: number);
  52172. /**
  52173. * Gets the right trigger value
  52174. */
  52175. get rightTrigger(): number;
  52176. /**
  52177. * Sets the right trigger value
  52178. */
  52179. set rightTrigger(newValue: number);
  52180. /**
  52181. * Defines the callback to call when a button is pressed
  52182. * @param callback defines the callback to use
  52183. */
  52184. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  52185. /**
  52186. * Defines the callback to call when a button is released
  52187. * @param callback defines the callback to use
  52188. */
  52189. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  52190. /**
  52191. * Defines the callback to call when a pad is pressed
  52192. * @param callback defines the callback to use
  52193. */
  52194. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  52195. /**
  52196. * Defines the callback to call when a pad is released
  52197. * @param callback defines the callback to use
  52198. */
  52199. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  52200. private _setButtonValue;
  52201. private _setDPadValue;
  52202. /**
  52203. * Gets the value of the `Cross` button
  52204. */
  52205. get buttonCross(): number;
  52206. /**
  52207. * Sets the value of the `Cross` button
  52208. */
  52209. set buttonCross(value: number);
  52210. /**
  52211. * Gets the value of the `Circle` button
  52212. */
  52213. get buttonCircle(): number;
  52214. /**
  52215. * Sets the value of the `Circle` button
  52216. */
  52217. set buttonCircle(value: number);
  52218. /**
  52219. * Gets the value of the `Square` button
  52220. */
  52221. get buttonSquare(): number;
  52222. /**
  52223. * Sets the value of the `Square` button
  52224. */
  52225. set buttonSquare(value: number);
  52226. /**
  52227. * Gets the value of the `Triangle` button
  52228. */
  52229. get buttonTriangle(): number;
  52230. /**
  52231. * Sets the value of the `Triangle` button
  52232. */
  52233. set buttonTriangle(value: number);
  52234. /**
  52235. * Gets the value of the `Options` button
  52236. */
  52237. get buttonOptions(): number;
  52238. /**
  52239. * Sets the value of the `Options` button
  52240. */
  52241. set buttonOptions(value: number);
  52242. /**
  52243. * Gets the value of the `Share` button
  52244. */
  52245. get buttonShare(): number;
  52246. /**
  52247. * Sets the value of the `Share` button
  52248. */
  52249. set buttonShare(value: number);
  52250. /**
  52251. * Gets the value of the `L1` button
  52252. */
  52253. get buttonL1(): number;
  52254. /**
  52255. * Sets the value of the `L1` button
  52256. */
  52257. set buttonL1(value: number);
  52258. /**
  52259. * Gets the value of the `R1` button
  52260. */
  52261. get buttonR1(): number;
  52262. /**
  52263. * Sets the value of the `R1` button
  52264. */
  52265. set buttonR1(value: number);
  52266. /**
  52267. * Gets the value of the Left joystick
  52268. */
  52269. get buttonLeftStick(): number;
  52270. /**
  52271. * Sets the value of the Left joystick
  52272. */
  52273. set buttonLeftStick(value: number);
  52274. /**
  52275. * Gets the value of the Right joystick
  52276. */
  52277. get buttonRightStick(): number;
  52278. /**
  52279. * Sets the value of the Right joystick
  52280. */
  52281. set buttonRightStick(value: number);
  52282. /**
  52283. * Gets the value of D-pad up
  52284. */
  52285. get dPadUp(): number;
  52286. /**
  52287. * Sets the value of D-pad up
  52288. */
  52289. set dPadUp(value: number);
  52290. /**
  52291. * Gets the value of D-pad down
  52292. */
  52293. get dPadDown(): number;
  52294. /**
  52295. * Sets the value of D-pad down
  52296. */
  52297. set dPadDown(value: number);
  52298. /**
  52299. * Gets the value of D-pad left
  52300. */
  52301. get dPadLeft(): number;
  52302. /**
  52303. * Sets the value of D-pad left
  52304. */
  52305. set dPadLeft(value: number);
  52306. /**
  52307. * Gets the value of D-pad right
  52308. */
  52309. get dPadRight(): number;
  52310. /**
  52311. * Sets the value of D-pad right
  52312. */
  52313. set dPadRight(value: number);
  52314. /**
  52315. * Force the gamepad to synchronize with device values
  52316. */
  52317. update(): void;
  52318. /**
  52319. * Disposes the gamepad
  52320. */
  52321. dispose(): void;
  52322. }
  52323. }
  52324. declare module BABYLON {
  52325. /**
  52326. * Manager for handling gamepads
  52327. */
  52328. export class GamepadManager {
  52329. private _scene?;
  52330. private _babylonGamepads;
  52331. private _oneGamepadConnected;
  52332. /** @hidden */
  52333. _isMonitoring: boolean;
  52334. private _gamepadEventSupported;
  52335. private _gamepadSupport?;
  52336. /**
  52337. * observable to be triggered when the gamepad controller has been connected
  52338. */
  52339. onGamepadConnectedObservable: Observable<Gamepad>;
  52340. /**
  52341. * observable to be triggered when the gamepad controller has been disconnected
  52342. */
  52343. onGamepadDisconnectedObservable: Observable<Gamepad>;
  52344. private _onGamepadConnectedEvent;
  52345. private _onGamepadDisconnectedEvent;
  52346. /**
  52347. * Initializes the gamepad manager
  52348. * @param _scene BabylonJS scene
  52349. */
  52350. constructor(_scene?: Scene | undefined);
  52351. /**
  52352. * The gamepads in the game pad manager
  52353. */
  52354. get gamepads(): Gamepad[];
  52355. /**
  52356. * Get the gamepad controllers based on type
  52357. * @param type The type of gamepad controller
  52358. * @returns Nullable gamepad
  52359. */
  52360. getGamepadByType(type?: number): Nullable<Gamepad>;
  52361. /**
  52362. * Disposes the gamepad manager
  52363. */
  52364. dispose(): void;
  52365. private _addNewGamepad;
  52366. private _startMonitoringGamepads;
  52367. private _stopMonitoringGamepads;
  52368. /** @hidden */
  52369. _checkGamepadsStatus(): void;
  52370. private _updateGamepadObjects;
  52371. }
  52372. }
  52373. declare module BABYLON {
  52374. interface Scene {
  52375. /** @hidden */
  52376. _gamepadManager: Nullable<GamepadManager>;
  52377. /**
  52378. * Gets the gamepad manager associated with the scene
  52379. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  52380. */
  52381. gamepadManager: GamepadManager;
  52382. }
  52383. /**
  52384. * Interface representing a free camera inputs manager
  52385. */
  52386. interface FreeCameraInputsManager {
  52387. /**
  52388. * Adds gamepad input support to the FreeCameraInputsManager.
  52389. * @returns the FreeCameraInputsManager
  52390. */
  52391. addGamepad(): FreeCameraInputsManager;
  52392. }
  52393. /**
  52394. * Interface representing an arc rotate camera inputs manager
  52395. */
  52396. interface ArcRotateCameraInputsManager {
  52397. /**
  52398. * Adds gamepad input support to the ArcRotateCamera InputManager.
  52399. * @returns the camera inputs manager
  52400. */
  52401. addGamepad(): ArcRotateCameraInputsManager;
  52402. }
  52403. /**
  52404. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  52405. */
  52406. export class GamepadSystemSceneComponent implements ISceneComponent {
  52407. /**
  52408. * The component name helpfull to identify the component in the list of scene components.
  52409. */
  52410. readonly name: string;
  52411. /**
  52412. * The scene the component belongs to.
  52413. */
  52414. scene: Scene;
  52415. /**
  52416. * Creates a new instance of the component for the given scene
  52417. * @param scene Defines the scene to register the component in
  52418. */
  52419. constructor(scene: Scene);
  52420. /**
  52421. * Registers the component in a given scene
  52422. */
  52423. register(): void;
  52424. /**
  52425. * Rebuilds the elements related to this component in case of
  52426. * context lost for instance.
  52427. */
  52428. rebuild(): void;
  52429. /**
  52430. * Disposes the component and the associated ressources
  52431. */
  52432. dispose(): void;
  52433. private _beforeCameraUpdate;
  52434. }
  52435. }
  52436. declare module BABYLON {
  52437. /**
  52438. * 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,
  52439. * which still works and will still be found in many Playgrounds.
  52440. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52441. */
  52442. export class UniversalCamera extends TouchCamera {
  52443. /**
  52444. * Defines the gamepad rotation sensiblity.
  52445. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  52446. */
  52447. get gamepadAngularSensibility(): number;
  52448. set gamepadAngularSensibility(value: number);
  52449. /**
  52450. * Defines the gamepad move sensiblity.
  52451. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  52452. */
  52453. get gamepadMoveSensibility(): number;
  52454. set gamepadMoveSensibility(value: number);
  52455. /**
  52456. * 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,
  52457. * which still works and will still be found in many Playgrounds.
  52458. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52459. * @param name Define the name of the camera in the scene
  52460. * @param position Define the start position of the camera in the scene
  52461. * @param scene Define the scene the camera belongs to
  52462. */
  52463. constructor(name: string, position: Vector3, scene: Scene);
  52464. /**
  52465. * Gets the current object class name.
  52466. * @return the class name
  52467. */
  52468. getClassName(): string;
  52469. }
  52470. }
  52471. declare module BABYLON {
  52472. /**
  52473. * This represents a FPS type of camera. This is only here for back compat purpose.
  52474. * Please use the UniversalCamera instead as both are identical.
  52475. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52476. */
  52477. export class GamepadCamera extends UniversalCamera {
  52478. /**
  52479. * Instantiates a new Gamepad Camera
  52480. * This represents a FPS type of camera. This is only here for back compat purpose.
  52481. * Please use the UniversalCamera instead as both are identical.
  52482. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  52483. * @param name Define the name of the camera in the scene
  52484. * @param position Define the start position of the camera in the scene
  52485. * @param scene Define the scene the camera belongs to
  52486. */
  52487. constructor(name: string, position: Vector3, scene: Scene);
  52488. /**
  52489. * Gets the current object class name.
  52490. * @return the class name
  52491. */
  52492. getClassName(): string;
  52493. }
  52494. }
  52495. declare module BABYLON {
  52496. /** @hidden */
  52497. export var anaglyphPixelShader: {
  52498. name: string;
  52499. shader: string;
  52500. };
  52501. }
  52502. declare module BABYLON {
  52503. /**
  52504. * Postprocess used to generate anaglyphic rendering
  52505. */
  52506. export class AnaglyphPostProcess extends PostProcess {
  52507. private _passedProcess;
  52508. /**
  52509. * Gets a string identifying the name of the class
  52510. * @returns "AnaglyphPostProcess" string
  52511. */
  52512. getClassName(): string;
  52513. /**
  52514. * Creates a new AnaglyphPostProcess
  52515. * @param name defines postprocess name
  52516. * @param options defines creation options or target ratio scale
  52517. * @param rigCameras defines cameras using this postprocess
  52518. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  52519. * @param engine defines hosting engine
  52520. * @param reusable defines if the postprocess will be reused multiple times per frame
  52521. */
  52522. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  52523. }
  52524. }
  52525. declare module BABYLON {
  52526. /**
  52527. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  52528. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52529. */
  52530. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  52531. /**
  52532. * Creates a new AnaglyphArcRotateCamera
  52533. * @param name defines camera name
  52534. * @param alpha defines alpha angle (in radians)
  52535. * @param beta defines beta angle (in radians)
  52536. * @param radius defines radius
  52537. * @param target defines camera target
  52538. * @param interaxialDistance defines distance between each color axis
  52539. * @param scene defines the hosting scene
  52540. */
  52541. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  52542. /**
  52543. * Gets camera class name
  52544. * @returns AnaglyphArcRotateCamera
  52545. */
  52546. getClassName(): string;
  52547. }
  52548. }
  52549. declare module BABYLON {
  52550. /**
  52551. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  52552. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52553. */
  52554. export class AnaglyphFreeCamera extends FreeCamera {
  52555. /**
  52556. * Creates a new AnaglyphFreeCamera
  52557. * @param name defines camera name
  52558. * @param position defines initial position
  52559. * @param interaxialDistance defines distance between each color axis
  52560. * @param scene defines the hosting scene
  52561. */
  52562. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52563. /**
  52564. * Gets camera class name
  52565. * @returns AnaglyphFreeCamera
  52566. */
  52567. getClassName(): string;
  52568. }
  52569. }
  52570. declare module BABYLON {
  52571. /**
  52572. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  52573. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52574. */
  52575. export class AnaglyphGamepadCamera extends GamepadCamera {
  52576. /**
  52577. * Creates a new AnaglyphGamepadCamera
  52578. * @param name defines camera name
  52579. * @param position defines initial position
  52580. * @param interaxialDistance defines distance between each color axis
  52581. * @param scene defines the hosting scene
  52582. */
  52583. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52584. /**
  52585. * Gets camera class name
  52586. * @returns AnaglyphGamepadCamera
  52587. */
  52588. getClassName(): string;
  52589. }
  52590. }
  52591. declare module BABYLON {
  52592. /**
  52593. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  52594. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  52595. */
  52596. export class AnaglyphUniversalCamera extends UniversalCamera {
  52597. /**
  52598. * Creates a new AnaglyphUniversalCamera
  52599. * @param name defines camera name
  52600. * @param position defines initial position
  52601. * @param interaxialDistance defines distance between each color axis
  52602. * @param scene defines the hosting scene
  52603. */
  52604. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  52605. /**
  52606. * Gets camera class name
  52607. * @returns AnaglyphUniversalCamera
  52608. */
  52609. getClassName(): string;
  52610. }
  52611. }
  52612. declare module BABYLON {
  52613. /** @hidden */
  52614. export var stereoscopicInterlacePixelShader: {
  52615. name: string;
  52616. shader: string;
  52617. };
  52618. }
  52619. declare module BABYLON {
  52620. /**
  52621. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  52622. */
  52623. export class StereoscopicInterlacePostProcessI extends PostProcess {
  52624. private _stepSize;
  52625. private _passedProcess;
  52626. /**
  52627. * Gets a string identifying the name of the class
  52628. * @returns "StereoscopicInterlacePostProcessI" string
  52629. */
  52630. getClassName(): string;
  52631. /**
  52632. * Initializes a StereoscopicInterlacePostProcessI
  52633. * @param name The name of the effect.
  52634. * @param rigCameras The rig cameras to be appled to the post process
  52635. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  52636. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  52637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52638. * @param engine The engine which the post process will be applied. (default: current engine)
  52639. * @param reusable If the post process can be reused on the same frame. (default: false)
  52640. */
  52641. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52642. }
  52643. /**
  52644. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  52645. */
  52646. export class StereoscopicInterlacePostProcess extends PostProcess {
  52647. private _stepSize;
  52648. private _passedProcess;
  52649. /**
  52650. * Gets a string identifying the name of the class
  52651. * @returns "StereoscopicInterlacePostProcess" string
  52652. */
  52653. getClassName(): string;
  52654. /**
  52655. * Initializes a StereoscopicInterlacePostProcess
  52656. * @param name The name of the effect.
  52657. * @param rigCameras The rig cameras to be appled to the post process
  52658. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  52659. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  52660. * @param engine The engine which the post process will be applied. (default: current engine)
  52661. * @param reusable If the post process can be reused on the same frame. (default: false)
  52662. */
  52663. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  52664. }
  52665. }
  52666. declare module BABYLON {
  52667. /**
  52668. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  52669. * @see https://doc.babylonjs.com/features/cameras
  52670. */
  52671. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  52672. /**
  52673. * Creates a new StereoscopicArcRotateCamera
  52674. * @param name defines camera name
  52675. * @param alpha defines alpha angle (in radians)
  52676. * @param beta defines beta angle (in radians)
  52677. * @param radius defines radius
  52678. * @param target defines camera target
  52679. * @param interaxialDistance defines distance between each color axis
  52680. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52681. * @param scene defines the hosting scene
  52682. */
  52683. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52684. /**
  52685. * Gets camera class name
  52686. * @returns StereoscopicArcRotateCamera
  52687. */
  52688. getClassName(): string;
  52689. }
  52690. }
  52691. declare module BABYLON {
  52692. /**
  52693. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  52694. * @see https://doc.babylonjs.com/features/cameras
  52695. */
  52696. export class StereoscopicFreeCamera extends FreeCamera {
  52697. /**
  52698. * Creates a new StereoscopicFreeCamera
  52699. * @param name defines camera name
  52700. * @param position defines initial position
  52701. * @param interaxialDistance defines distance between each color axis
  52702. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52703. * @param scene defines the hosting scene
  52704. */
  52705. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52706. /**
  52707. * Gets camera class name
  52708. * @returns StereoscopicFreeCamera
  52709. */
  52710. getClassName(): string;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /**
  52715. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  52716. * @see https://doc.babylonjs.com/features/cameras
  52717. */
  52718. export class StereoscopicGamepadCamera extends GamepadCamera {
  52719. /**
  52720. * Creates a new StereoscopicGamepadCamera
  52721. * @param name defines camera name
  52722. * @param position defines initial position
  52723. * @param interaxialDistance defines distance between each color axis
  52724. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52725. * @param scene defines the hosting scene
  52726. */
  52727. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52728. /**
  52729. * Gets camera class name
  52730. * @returns StereoscopicGamepadCamera
  52731. */
  52732. getClassName(): string;
  52733. }
  52734. }
  52735. declare module BABYLON {
  52736. /**
  52737. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  52738. * @see https://doc.babylonjs.com/features/cameras
  52739. */
  52740. export class StereoscopicUniversalCamera extends UniversalCamera {
  52741. /**
  52742. * Creates a new StereoscopicUniversalCamera
  52743. * @param name defines camera name
  52744. * @param position defines initial position
  52745. * @param interaxialDistance defines distance between each color axis
  52746. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  52747. * @param scene defines the hosting scene
  52748. */
  52749. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  52750. /**
  52751. * Gets camera class name
  52752. * @returns StereoscopicUniversalCamera
  52753. */
  52754. getClassName(): string;
  52755. }
  52756. }
  52757. declare module BABYLON {
  52758. /**
  52759. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  52760. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52761. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52762. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52763. */
  52764. export class VirtualJoysticksCamera extends FreeCamera {
  52765. /**
  52766. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  52767. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  52768. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  52769. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  52770. * @param name Define the name of the camera in the scene
  52771. * @param position Define the start position of the camera in the scene
  52772. * @param scene Define the scene the camera belongs to
  52773. */
  52774. constructor(name: string, position: Vector3, scene: Scene);
  52775. /**
  52776. * Gets the current object class name.
  52777. * @return the class name
  52778. */
  52779. getClassName(): string;
  52780. }
  52781. }
  52782. declare module BABYLON {
  52783. /**
  52784. * This represents all the required metrics to create a VR camera.
  52785. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  52786. */
  52787. export class VRCameraMetrics {
  52788. /**
  52789. * Define the horizontal resolution off the screen.
  52790. */
  52791. hResolution: number;
  52792. /**
  52793. * Define the vertical resolution off the screen.
  52794. */
  52795. vResolution: number;
  52796. /**
  52797. * Define the horizontal screen size.
  52798. */
  52799. hScreenSize: number;
  52800. /**
  52801. * Define the vertical screen size.
  52802. */
  52803. vScreenSize: number;
  52804. /**
  52805. * Define the vertical screen center position.
  52806. */
  52807. vScreenCenter: number;
  52808. /**
  52809. * Define the distance of the eyes to the screen.
  52810. */
  52811. eyeToScreenDistance: number;
  52812. /**
  52813. * Define the distance between both lenses
  52814. */
  52815. lensSeparationDistance: number;
  52816. /**
  52817. * Define the distance between both viewer's eyes.
  52818. */
  52819. interpupillaryDistance: number;
  52820. /**
  52821. * Define the distortion factor of the VR postprocess.
  52822. * Please, touch with care.
  52823. */
  52824. distortionK: number[];
  52825. /**
  52826. * Define the chromatic aberration correction factors for the VR post process.
  52827. */
  52828. chromaAbCorrection: number[];
  52829. /**
  52830. * Define the scale factor of the post process.
  52831. * The smaller the better but the slower.
  52832. */
  52833. postProcessScaleFactor: number;
  52834. /**
  52835. * Define an offset for the lens center.
  52836. */
  52837. lensCenterOffset: number;
  52838. /**
  52839. * Define if the current vr camera should compensate the distortion of the lense or not.
  52840. */
  52841. compensateDistortion: boolean;
  52842. /**
  52843. * Defines if multiview should be enabled when rendering (Default: false)
  52844. */
  52845. multiviewEnabled: boolean;
  52846. /**
  52847. * Gets the rendering aspect ratio based on the provided resolutions.
  52848. */
  52849. get aspectRatio(): number;
  52850. /**
  52851. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  52852. */
  52853. get aspectRatioFov(): number;
  52854. /**
  52855. * @hidden
  52856. */
  52857. get leftHMatrix(): Matrix;
  52858. /**
  52859. * @hidden
  52860. */
  52861. get rightHMatrix(): Matrix;
  52862. /**
  52863. * @hidden
  52864. */
  52865. get leftPreViewMatrix(): Matrix;
  52866. /**
  52867. * @hidden
  52868. */
  52869. get rightPreViewMatrix(): Matrix;
  52870. /**
  52871. * Get the default VRMetrics based on the most generic setup.
  52872. * @returns the default vr metrics
  52873. */
  52874. static GetDefault(): VRCameraMetrics;
  52875. }
  52876. }
  52877. declare module BABYLON {
  52878. /** @hidden */
  52879. export var vrDistortionCorrectionPixelShader: {
  52880. name: string;
  52881. shader: string;
  52882. };
  52883. }
  52884. declare module BABYLON {
  52885. /**
  52886. * VRDistortionCorrectionPostProcess used for mobile VR
  52887. */
  52888. export class VRDistortionCorrectionPostProcess extends PostProcess {
  52889. private _isRightEye;
  52890. private _distortionFactors;
  52891. private _postProcessScaleFactor;
  52892. private _lensCenterOffset;
  52893. private _scaleIn;
  52894. private _scaleFactor;
  52895. private _lensCenter;
  52896. /**
  52897. * Gets a string identifying the name of the class
  52898. * @returns "VRDistortionCorrectionPostProcess" string
  52899. */
  52900. getClassName(): string;
  52901. /**
  52902. * Initializes the VRDistortionCorrectionPostProcess
  52903. * @param name The name of the effect.
  52904. * @param camera The camera to apply the render pass to.
  52905. * @param isRightEye If this is for the right eye distortion
  52906. * @param vrMetrics All the required metrics for the VR camera
  52907. */
  52908. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  52909. }
  52910. }
  52911. declare module BABYLON {
  52912. /**
  52913. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  52914. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52915. */
  52916. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  52917. /**
  52918. * Creates a new VRDeviceOrientationArcRotateCamera
  52919. * @param name defines camera name
  52920. * @param alpha defines the camera rotation along the logitudinal axis
  52921. * @param beta defines the camera rotation along the latitudinal axis
  52922. * @param radius defines the camera distance from its target
  52923. * @param target defines the camera target
  52924. * @param scene defines the scene the camera belongs to
  52925. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52926. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52927. */
  52928. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52929. /**
  52930. * Gets camera class name
  52931. * @returns VRDeviceOrientationArcRotateCamera
  52932. */
  52933. getClassName(): string;
  52934. }
  52935. }
  52936. declare module BABYLON {
  52937. /**
  52938. * Camera used to simulate VR rendering (based on FreeCamera)
  52939. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52940. */
  52941. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  52942. /**
  52943. * Creates a new VRDeviceOrientationFreeCamera
  52944. * @param name defines camera name
  52945. * @param position defines the start position of the camera
  52946. * @param scene defines the scene the camera belongs to
  52947. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52948. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52949. */
  52950. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52951. /**
  52952. * Gets camera class name
  52953. * @returns VRDeviceOrientationFreeCamera
  52954. */
  52955. getClassName(): string;
  52956. }
  52957. }
  52958. declare module BABYLON {
  52959. /**
  52960. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  52961. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  52962. */
  52963. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  52964. /**
  52965. * Creates a new VRDeviceOrientationGamepadCamera
  52966. * @param name defines camera name
  52967. * @param position defines the start position of the camera
  52968. * @param scene defines the scene the camera belongs to
  52969. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  52970. * @param vrCameraMetrics defines the vr metrics associated to the camera
  52971. */
  52972. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  52973. /**
  52974. * Gets camera class name
  52975. * @returns VRDeviceOrientationGamepadCamera
  52976. */
  52977. getClassName(): string;
  52978. }
  52979. }
  52980. declare module BABYLON {
  52981. /**
  52982. * A class extending Texture allowing drawing on a texture
  52983. * @see https://doc.babylonjs.com/how_to/dynamictexture
  52984. */
  52985. export class DynamicTexture extends Texture {
  52986. private _generateMipMaps;
  52987. private _canvas;
  52988. private _context;
  52989. /**
  52990. * Creates a DynamicTexture
  52991. * @param name defines the name of the texture
  52992. * @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
  52993. * @param scene defines the scene where you want the texture
  52994. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  52995. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  52996. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  52997. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  52998. */
  52999. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  53000. /**
  53001. * Get the current class name of the texture useful for serialization or dynamic coding.
  53002. * @returns "DynamicTexture"
  53003. */
  53004. getClassName(): string;
  53005. /**
  53006. * Gets the current state of canRescale
  53007. */
  53008. get canRescale(): boolean;
  53009. private _recreate;
  53010. /**
  53011. * Scales the texture
  53012. * @param ratio the scale factor to apply to both width and height
  53013. */
  53014. scale(ratio: number): void;
  53015. /**
  53016. * Resizes the texture
  53017. * @param width the new width
  53018. * @param height the new height
  53019. */
  53020. scaleTo(width: number, height: number): void;
  53021. /**
  53022. * Gets the context of the canvas used by the texture
  53023. * @returns the canvas context of the dynamic texture
  53024. */
  53025. getContext(): CanvasRenderingContext2D;
  53026. /**
  53027. * Clears the texture
  53028. */
  53029. clear(): void;
  53030. /**
  53031. * Updates the texture
  53032. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53033. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  53034. */
  53035. update(invertY?: boolean, premulAlpha?: boolean): void;
  53036. /**
  53037. * Draws text onto the texture
  53038. * @param text defines the text to be drawn
  53039. * @param x defines the placement of the text from the left
  53040. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  53041. * @param font defines the font to be used with font-style, font-size, font-name
  53042. * @param color defines the color used for the text
  53043. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  53044. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  53045. * @param update defines whether texture is immediately update (default is true)
  53046. */
  53047. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  53048. /**
  53049. * Clones the texture
  53050. * @returns the clone of the texture.
  53051. */
  53052. clone(): DynamicTexture;
  53053. /**
  53054. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  53055. * @returns a serialized dynamic texture object
  53056. */
  53057. serialize(): any;
  53058. private _IsCanvasElement;
  53059. /** @hidden */
  53060. _rebuild(): void;
  53061. }
  53062. }
  53063. declare module BABYLON {
  53064. /**
  53065. * Class containing static functions to help procedurally build meshes
  53066. */
  53067. export class GroundBuilder {
  53068. /**
  53069. * Creates a ground mesh
  53070. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  53071. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  53072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53073. * @param name defines the name of the mesh
  53074. * @param options defines the options used to create the mesh
  53075. * @param scene defines the hosting scene
  53076. * @returns the ground mesh
  53077. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  53078. */
  53079. static CreateGround(name: string, options: {
  53080. width?: number;
  53081. height?: number;
  53082. subdivisions?: number;
  53083. subdivisionsX?: number;
  53084. subdivisionsY?: number;
  53085. updatable?: boolean;
  53086. }, scene: any): Mesh;
  53087. /**
  53088. * Creates a tiled ground mesh
  53089. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  53090. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  53091. * * 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
  53092. * * 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
  53093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53094. * @param name defines the name of the mesh
  53095. * @param options defines the options used to create the mesh
  53096. * @param scene defines the hosting scene
  53097. * @returns the tiled ground mesh
  53098. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  53099. */
  53100. static CreateTiledGround(name: string, options: {
  53101. xmin: number;
  53102. zmin: number;
  53103. xmax: number;
  53104. zmax: number;
  53105. subdivisions?: {
  53106. w: number;
  53107. h: number;
  53108. };
  53109. precision?: {
  53110. w: number;
  53111. h: number;
  53112. };
  53113. updatable?: boolean;
  53114. }, scene?: Nullable<Scene>): Mesh;
  53115. /**
  53116. * Creates a ground mesh from a height map
  53117. * * The parameter `url` sets the URL of the height map image resource.
  53118. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  53119. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  53120. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  53121. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  53122. * * 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.
  53123. * * 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).
  53124. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  53125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53126. * @param name defines the name of the mesh
  53127. * @param url defines the url to the height map
  53128. * @param options defines the options used to create the mesh
  53129. * @param scene defines the hosting scene
  53130. * @returns the ground mesh
  53131. * @see https://doc.babylonjs.com/babylon101/height_map
  53132. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  53133. */
  53134. static CreateGroundFromHeightMap(name: string, url: string, options: {
  53135. width?: number;
  53136. height?: number;
  53137. subdivisions?: number;
  53138. minHeight?: number;
  53139. maxHeight?: number;
  53140. colorFilter?: Color3;
  53141. alphaFilter?: number;
  53142. updatable?: boolean;
  53143. onReady?: (mesh: GroundMesh) => void;
  53144. }, scene?: Nullable<Scene>): GroundMesh;
  53145. }
  53146. }
  53147. declare module BABYLON {
  53148. /**
  53149. * Class containing static functions to help procedurally build meshes
  53150. */
  53151. export class TorusBuilder {
  53152. /**
  53153. * Creates a torus mesh
  53154. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53155. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53156. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53158. * * 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
  53159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53160. * @param name defines the name of the mesh
  53161. * @param options defines the options used to create the mesh
  53162. * @param scene defines the hosting scene
  53163. * @returns the torus mesh
  53164. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53165. */
  53166. static CreateTorus(name: string, options: {
  53167. diameter?: number;
  53168. thickness?: number;
  53169. tessellation?: number;
  53170. updatable?: boolean;
  53171. sideOrientation?: number;
  53172. frontUVs?: Vector4;
  53173. backUVs?: Vector4;
  53174. }, scene: any): Mesh;
  53175. }
  53176. }
  53177. declare module BABYLON {
  53178. /**
  53179. * Class containing static functions to help procedurally build meshes
  53180. */
  53181. export class CylinderBuilder {
  53182. /**
  53183. * Creates a cylinder or a cone mesh
  53184. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53185. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53186. * * 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.
  53187. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53188. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53189. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53190. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53191. * * 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).
  53192. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53193. * * 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).
  53194. * * 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
  53195. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53196. * * 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
  53197. * * 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.
  53198. * * If `enclose` is false, a ring surface is one element.
  53199. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53200. * * 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
  53201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53202. * * 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
  53203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53204. * @param name defines the name of the mesh
  53205. * @param options defines the options used to create the mesh
  53206. * @param scene defines the hosting scene
  53207. * @returns the cylinder mesh
  53208. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53209. */
  53210. static CreateCylinder(name: string, options: {
  53211. height?: number;
  53212. diameterTop?: number;
  53213. diameterBottom?: number;
  53214. diameter?: number;
  53215. tessellation?: number;
  53216. subdivisions?: number;
  53217. arc?: number;
  53218. faceColors?: Color4[];
  53219. faceUV?: Vector4[];
  53220. updatable?: boolean;
  53221. hasRings?: boolean;
  53222. enclose?: boolean;
  53223. cap?: number;
  53224. sideOrientation?: number;
  53225. frontUVs?: Vector4;
  53226. backUVs?: Vector4;
  53227. }, scene: any): Mesh;
  53228. }
  53229. }
  53230. declare module BABYLON {
  53231. /**
  53232. * States of the webXR experience
  53233. */
  53234. export enum WebXRState {
  53235. /**
  53236. * Transitioning to being in XR mode
  53237. */
  53238. ENTERING_XR = 0,
  53239. /**
  53240. * Transitioning to non XR mode
  53241. */
  53242. EXITING_XR = 1,
  53243. /**
  53244. * In XR mode and presenting
  53245. */
  53246. IN_XR = 2,
  53247. /**
  53248. * Not entered XR mode
  53249. */
  53250. NOT_IN_XR = 3
  53251. }
  53252. /**
  53253. * The state of the XR camera's tracking
  53254. */
  53255. export enum WebXRTrackingState {
  53256. /**
  53257. * No transformation received, device is not being tracked
  53258. */
  53259. NOT_TRACKING = 0,
  53260. /**
  53261. * Tracking lost - using emulated position
  53262. */
  53263. TRACKING_LOST = 1,
  53264. /**
  53265. * Transformation tracking works normally
  53266. */
  53267. TRACKING = 2
  53268. }
  53269. /**
  53270. * Abstraction of the XR render target
  53271. */
  53272. export interface WebXRRenderTarget extends IDisposable {
  53273. /**
  53274. * xrpresent context of the canvas which can be used to display/mirror xr content
  53275. */
  53276. canvasContext: WebGLRenderingContext;
  53277. /**
  53278. * xr layer for the canvas
  53279. */
  53280. xrLayer: Nullable<XRWebGLLayer>;
  53281. /**
  53282. * Initializes the xr layer for the session
  53283. * @param xrSession xr session
  53284. * @returns a promise that will resolve once the XR Layer has been created
  53285. */
  53286. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53287. }
  53288. }
  53289. declare module BABYLON {
  53290. /**
  53291. * COnfiguration object for WebXR output canvas
  53292. */
  53293. export class WebXRManagedOutputCanvasOptions {
  53294. /**
  53295. * An optional canvas in case you wish to create it yourself and provide it here.
  53296. * If not provided, a new canvas will be created
  53297. */
  53298. canvasElement?: HTMLCanvasElement;
  53299. /**
  53300. * Options for this XR Layer output
  53301. */
  53302. canvasOptions?: XRWebGLLayerInit;
  53303. /**
  53304. * CSS styling for a newly created canvas (if not provided)
  53305. */
  53306. newCanvasCssStyle?: string;
  53307. /**
  53308. * Get the default values of the configuration object
  53309. * @param engine defines the engine to use (can be null)
  53310. * @returns default values of this configuration object
  53311. */
  53312. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  53313. }
  53314. /**
  53315. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  53316. */
  53317. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  53318. private _options;
  53319. private _canvas;
  53320. private _engine;
  53321. private _originalCanvasSize;
  53322. /**
  53323. * Rendering context of the canvas which can be used to display/mirror xr content
  53324. */
  53325. canvasContext: WebGLRenderingContext;
  53326. /**
  53327. * xr layer for the canvas
  53328. */
  53329. xrLayer: Nullable<XRWebGLLayer>;
  53330. /**
  53331. * Obseervers registered here will be triggered when the xr layer was initialized
  53332. */
  53333. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  53334. /**
  53335. * Initializes the canvas to be added/removed upon entering/exiting xr
  53336. * @param _xrSessionManager The XR Session manager
  53337. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  53338. */
  53339. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  53340. /**
  53341. * Disposes of the object
  53342. */
  53343. dispose(): void;
  53344. /**
  53345. * Initializes the xr layer for the session
  53346. * @param xrSession xr session
  53347. * @returns a promise that will resolve once the XR Layer has been created
  53348. */
  53349. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  53350. private _addCanvas;
  53351. private _removeCanvas;
  53352. private _setCanvasSize;
  53353. private _setManagedOutputCanvas;
  53354. }
  53355. }
  53356. declare module BABYLON {
  53357. /**
  53358. * Manages an XRSession to work with Babylon's engine
  53359. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  53360. */
  53361. export class WebXRSessionManager implements IDisposable {
  53362. /** The scene which the session should be created for */
  53363. scene: Scene;
  53364. private _referenceSpace;
  53365. private _rttProvider;
  53366. private _sessionEnded;
  53367. private _xrNavigator;
  53368. private baseLayer;
  53369. /**
  53370. * The base reference space from which the session started. good if you want to reset your
  53371. * reference space
  53372. */
  53373. baseReferenceSpace: XRReferenceSpace;
  53374. /**
  53375. * Current XR frame
  53376. */
  53377. currentFrame: Nullable<XRFrame>;
  53378. /** WebXR timestamp updated every frame */
  53379. currentTimestamp: number;
  53380. /**
  53381. * Used just in case of a failure to initialize an immersive session.
  53382. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  53383. */
  53384. defaultHeightCompensation: number;
  53385. /**
  53386. * Fires every time a new xrFrame arrives which can be used to update the camera
  53387. */
  53388. onXRFrameObservable: Observable<XRFrame>;
  53389. /**
  53390. * Fires when the reference space changed
  53391. */
  53392. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  53393. /**
  53394. * Fires when the xr session is ended either by the device or manually done
  53395. */
  53396. onXRSessionEnded: Observable<any>;
  53397. /**
  53398. * Fires when the xr session is ended either by the device or manually done
  53399. */
  53400. onXRSessionInit: Observable<XRSession>;
  53401. /**
  53402. * Underlying xr session
  53403. */
  53404. session: XRSession;
  53405. /**
  53406. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  53407. * or get the offset the player is currently at.
  53408. */
  53409. viewerReferenceSpace: XRReferenceSpace;
  53410. /**
  53411. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  53412. * @param scene The scene which the session should be created for
  53413. */
  53414. constructor(
  53415. /** The scene which the session should be created for */
  53416. scene: Scene);
  53417. /**
  53418. * The current reference space used in this session. This reference space can constantly change!
  53419. * It is mainly used to offset the camera's position.
  53420. */
  53421. get referenceSpace(): XRReferenceSpace;
  53422. /**
  53423. * Set a new reference space and triggers the observable
  53424. */
  53425. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  53426. /**
  53427. * Disposes of the session manager
  53428. */
  53429. dispose(): void;
  53430. /**
  53431. * Stops the xrSession and restores the render loop
  53432. * @returns Promise which resolves after it exits XR
  53433. */
  53434. exitXRAsync(): Promise<void>;
  53435. /**
  53436. * Gets the correct render target texture to be rendered this frame for this eye
  53437. * @param eye the eye for which to get the render target
  53438. * @returns the render target for the specified eye
  53439. */
  53440. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  53441. /**
  53442. * Creates a WebXRRenderTarget object for the XR session
  53443. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  53444. * @param options optional options to provide when creating a new render target
  53445. * @returns a WebXR render target to which the session can render
  53446. */
  53447. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  53448. /**
  53449. * Initializes the manager
  53450. * After initialization enterXR can be called to start an XR session
  53451. * @returns Promise which resolves after it is initialized
  53452. */
  53453. initializeAsync(): Promise<void>;
  53454. /**
  53455. * Initializes an xr session
  53456. * @param xrSessionMode mode to initialize
  53457. * @param xrSessionInit defines optional and required values to pass to the session builder
  53458. * @returns a promise which will resolve once the session has been initialized
  53459. */
  53460. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  53461. /**
  53462. * Checks if a session would be supported for the creation options specified
  53463. * @param sessionMode session mode to check if supported eg. immersive-vr
  53464. * @returns A Promise that resolves to true if supported and false if not
  53465. */
  53466. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53467. /**
  53468. * Resets the reference space to the one started the session
  53469. */
  53470. resetReferenceSpace(): void;
  53471. /**
  53472. * Starts rendering to the xr layer
  53473. */
  53474. runXRRenderLoop(): void;
  53475. /**
  53476. * Sets the reference space on the xr session
  53477. * @param referenceSpaceType space to set
  53478. * @returns a promise that will resolve once the reference space has been set
  53479. */
  53480. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  53481. /**
  53482. * Updates the render state of the session
  53483. * @param state state to set
  53484. * @returns a promise that resolves once the render state has been updated
  53485. */
  53486. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  53487. /**
  53488. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  53489. * @param sessionMode defines the session to test
  53490. * @returns a promise with boolean as final value
  53491. */
  53492. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  53493. /**
  53494. * Returns true if Babylon.js is using the BabylonNative backend, otherwise false
  53495. */
  53496. get isNative(): boolean;
  53497. private _createRenderTargetTexture;
  53498. }
  53499. }
  53500. declare module BABYLON {
  53501. /**
  53502. * WebXR Camera which holds the views for the xrSession
  53503. * @see https://doc.babylonjs.com/how_to/webxr_camera
  53504. */
  53505. export class WebXRCamera extends FreeCamera {
  53506. private _xrSessionManager;
  53507. private _firstFrame;
  53508. private _referenceQuaternion;
  53509. private _referencedPosition;
  53510. private _xrInvPositionCache;
  53511. private _xrInvQuaternionCache;
  53512. private _trackingState;
  53513. /**
  53514. * Observable raised before camera teleportation
  53515. */
  53516. onBeforeCameraTeleport: Observable<Vector3>;
  53517. /**
  53518. * Observable raised after camera teleportation
  53519. */
  53520. onAfterCameraTeleport: Observable<Vector3>;
  53521. /**
  53522. * Notifies when the camera's tracking state has changed.
  53523. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  53524. */
  53525. onTrackingStateChanged: Observable<WebXRTrackingState>;
  53526. /**
  53527. * Should position compensation execute on first frame.
  53528. * This is used when copying the position from a native (non XR) camera
  53529. */
  53530. compensateOnFirstFrame: boolean;
  53531. /**
  53532. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  53533. * @param name the name of the camera
  53534. * @param scene the scene to add the camera to
  53535. * @param _xrSessionManager a constructed xr session manager
  53536. */
  53537. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  53538. /**
  53539. * Get the current XR tracking state of the camera
  53540. */
  53541. get trackingState(): WebXRTrackingState;
  53542. private _setTrackingState;
  53543. /**
  53544. * Return the user's height, unrelated to the current ground.
  53545. * This will be the y position of this camera, when ground level is 0.
  53546. */
  53547. get realWorldHeight(): number;
  53548. /** @hidden */
  53549. _updateForDualEyeDebugging(): void;
  53550. /**
  53551. * Sets this camera's transformation based on a non-vr camera
  53552. * @param otherCamera the non-vr camera to copy the transformation from
  53553. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  53554. */
  53555. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  53556. /**
  53557. * Gets the current instance class name ("WebXRCamera").
  53558. * @returns the class name
  53559. */
  53560. getClassName(): string;
  53561. private _rotate180;
  53562. private _updateFromXRSession;
  53563. private _updateNumberOfRigCameras;
  53564. private _updateReferenceSpace;
  53565. private _updateReferenceSpaceOffset;
  53566. }
  53567. }
  53568. declare module BABYLON {
  53569. /**
  53570. * Defining the interface required for a (webxr) feature
  53571. */
  53572. export interface IWebXRFeature extends IDisposable {
  53573. /**
  53574. * Is this feature attached
  53575. */
  53576. attached: boolean;
  53577. /**
  53578. * Should auto-attach be disabled?
  53579. */
  53580. disableAutoAttach: boolean;
  53581. /**
  53582. * Attach the feature to the session
  53583. * Will usually be called by the features manager
  53584. *
  53585. * @param force should attachment be forced (even when already attached)
  53586. * @returns true if successful.
  53587. */
  53588. attach(force?: boolean): boolean;
  53589. /**
  53590. * Detach the feature from the session
  53591. * Will usually be called by the features manager
  53592. *
  53593. * @returns true if successful.
  53594. */
  53595. detach(): boolean;
  53596. /**
  53597. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  53598. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  53599. *
  53600. * @returns whether or not the feature is compatible in this environment
  53601. */
  53602. isCompatible(): boolean;
  53603. /**
  53604. * Was this feature disposed;
  53605. */
  53606. isDisposed: boolean;
  53607. /**
  53608. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  53609. */
  53610. xrNativeFeatureName?: string;
  53611. /**
  53612. * A list of (Babylon WebXR) features this feature depends on
  53613. */
  53614. dependsOn?: string[];
  53615. /**
  53616. * If this feature requires to extend the XRSessionInit object, this function will return the partial XR session init object
  53617. */
  53618. getXRSessionInitExtension?: () => Promise<Partial<XRSessionInit>>;
  53619. }
  53620. /**
  53621. * A list of the currently available features without referencing them
  53622. */
  53623. export class WebXRFeatureName {
  53624. /**
  53625. * The name of the anchor system feature
  53626. */
  53627. static readonly ANCHOR_SYSTEM: string;
  53628. /**
  53629. * The name of the background remover feature
  53630. */
  53631. static readonly BACKGROUND_REMOVER: string;
  53632. /**
  53633. * The name of the hit test feature
  53634. */
  53635. static readonly HIT_TEST: string;
  53636. /**
  53637. * The name of the mesh detection feature
  53638. */
  53639. static readonly MESH_DETECTION: string;
  53640. /**
  53641. * physics impostors for xr controllers feature
  53642. */
  53643. static readonly PHYSICS_CONTROLLERS: string;
  53644. /**
  53645. * The name of the plane detection feature
  53646. */
  53647. static readonly PLANE_DETECTION: string;
  53648. /**
  53649. * The name of the pointer selection feature
  53650. */
  53651. static readonly POINTER_SELECTION: string;
  53652. /**
  53653. * The name of the teleportation feature
  53654. */
  53655. static readonly TELEPORTATION: string;
  53656. /**
  53657. * The name of the feature points feature.
  53658. */
  53659. static readonly FEATURE_POINTS: string;
  53660. /**
  53661. * The name of the hand tracking feature.
  53662. */
  53663. static readonly HAND_TRACKING: string;
  53664. /**
  53665. * The name of the image tracking feature
  53666. */
  53667. static readonly IMAGE_TRACKING: string;
  53668. }
  53669. /**
  53670. * Defining the constructor of a feature. Used to register the modules.
  53671. */
  53672. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  53673. /**
  53674. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  53675. * It is mainly used in AR sessions.
  53676. *
  53677. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  53678. */
  53679. export class WebXRFeaturesManager implements IDisposable {
  53680. private _xrSessionManager;
  53681. private static readonly _AvailableFeatures;
  53682. private _features;
  53683. /**
  53684. * constructs a new features manages.
  53685. *
  53686. * @param _xrSessionManager an instance of WebXRSessionManager
  53687. */
  53688. constructor(_xrSessionManager: WebXRSessionManager);
  53689. /**
  53690. * Used to register a module. After calling this function a developer can use this feature in the scene.
  53691. * Mainly used internally.
  53692. *
  53693. * @param featureName the name of the feature to register
  53694. * @param constructorFunction the function used to construct the module
  53695. * @param version the (babylon) version of the module
  53696. * @param stable is that a stable version of this module
  53697. */
  53698. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  53699. /**
  53700. * Returns a constructor of a specific feature.
  53701. *
  53702. * @param featureName the name of the feature to construct
  53703. * @param version the version of the feature to load
  53704. * @param xrSessionManager the xrSessionManager. Used to construct the module
  53705. * @param options optional options provided to the module.
  53706. * @returns a function that, when called, will return a new instance of this feature
  53707. */
  53708. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  53709. /**
  53710. * Can be used to return the list of features currently registered
  53711. *
  53712. * @returns an Array of available features
  53713. */
  53714. static GetAvailableFeatures(): string[];
  53715. /**
  53716. * Gets the versions available for a specific feature
  53717. * @param featureName the name of the feature
  53718. * @returns an array with the available versions
  53719. */
  53720. static GetAvailableVersions(featureName: string): string[];
  53721. /**
  53722. * Return the latest unstable version of this feature
  53723. * @param featureName the name of the feature to search
  53724. * @returns the version number. if not found will return -1
  53725. */
  53726. static GetLatestVersionOfFeature(featureName: string): number;
  53727. /**
  53728. * Return the latest stable version of this feature
  53729. * @param featureName the name of the feature to search
  53730. * @returns the version number. if not found will return -1
  53731. */
  53732. static GetStableVersionOfFeature(featureName: string): number;
  53733. /**
  53734. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  53735. * Can be used during a session to start a feature
  53736. * @param featureName the name of feature to attach
  53737. */
  53738. attachFeature(featureName: string): void;
  53739. /**
  53740. * Can be used inside a session or when the session ends to detach a specific feature
  53741. * @param featureName the name of the feature to detach
  53742. */
  53743. detachFeature(featureName: string): void;
  53744. /**
  53745. * Used to disable an already-enabled feature
  53746. * The feature will be disposed and will be recreated once enabled.
  53747. * @param featureName the feature to disable
  53748. * @returns true if disable was successful
  53749. */
  53750. disableFeature(featureName: string | {
  53751. Name: string;
  53752. }): boolean;
  53753. /**
  53754. * dispose this features manager
  53755. */
  53756. dispose(): void;
  53757. /**
  53758. * 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.
  53759. * 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.
  53760. *
  53761. * @param featureName the name of the feature to load or the class of the feature
  53762. * @param version optional version to load. if not provided the latest version will be enabled
  53763. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  53764. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  53765. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  53766. * @returns a new constructed feature or throws an error if feature not found.
  53767. */
  53768. enableFeature(featureName: string | {
  53769. Name: string;
  53770. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  53771. /**
  53772. * get the implementation of an enabled feature.
  53773. * @param featureName the name of the feature to load
  53774. * @returns the feature class, if found
  53775. */
  53776. getEnabledFeature(featureName: string): IWebXRFeature;
  53777. /**
  53778. * Get the list of enabled features
  53779. * @returns an array of enabled features
  53780. */
  53781. getEnabledFeatures(): string[];
  53782. /**
  53783. * This function will extend the session creation configuration object with enabled features.
  53784. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  53785. * according to the defined "required" variable, provided during enableFeature call
  53786. * @param xrSessionInit the xr Session init object to extend
  53787. *
  53788. * @returns an extended XRSessionInit object
  53789. */
  53790. _extendXRSessionInitObject(xrSessionInit: XRSessionInit): Promise<XRSessionInit>;
  53791. }
  53792. }
  53793. declare module BABYLON {
  53794. /**
  53795. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  53796. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  53797. */
  53798. export class WebXRExperienceHelper implements IDisposable {
  53799. private scene;
  53800. private _nonVRCamera;
  53801. private _originalSceneAutoClear;
  53802. private _supported;
  53803. /**
  53804. * Camera used to render xr content
  53805. */
  53806. camera: WebXRCamera;
  53807. /** A features manager for this xr session */
  53808. featuresManager: WebXRFeaturesManager;
  53809. /**
  53810. * Observers registered here will be triggered after the camera's initial transformation is set
  53811. * This can be used to set a different ground level or an extra rotation.
  53812. *
  53813. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  53814. * to the position set after this observable is done executing.
  53815. */
  53816. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  53817. /**
  53818. * Fires when the state of the experience helper has changed
  53819. */
  53820. onStateChangedObservable: Observable<WebXRState>;
  53821. /** Session manager used to keep track of xr session */
  53822. sessionManager: WebXRSessionManager;
  53823. /**
  53824. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  53825. */
  53826. state: WebXRState;
  53827. /**
  53828. * Creates a WebXRExperienceHelper
  53829. * @param scene The scene the helper should be created in
  53830. */
  53831. private constructor();
  53832. /**
  53833. * Creates the experience helper
  53834. * @param scene the scene to attach the experience helper to
  53835. * @returns a promise for the experience helper
  53836. */
  53837. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  53838. /**
  53839. * Disposes of the experience helper
  53840. */
  53841. dispose(): void;
  53842. /**
  53843. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  53844. * @param sessionMode options for the XR session
  53845. * @param referenceSpaceType frame of reference of the XR session
  53846. * @param renderTarget the output canvas that will be used to enter XR mode
  53847. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  53848. * @returns promise that resolves after xr mode has entered
  53849. */
  53850. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  53851. /**
  53852. * Exits XR mode and returns the scene to its original state
  53853. * @returns promise that resolves after xr mode has exited
  53854. */
  53855. exitXRAsync(): Promise<void>;
  53856. private _nonXRToXRCamera;
  53857. private _setState;
  53858. }
  53859. }
  53860. declare module BABYLON {
  53861. /**
  53862. * X-Y values for axes in WebXR
  53863. */
  53864. export interface IWebXRMotionControllerAxesValue {
  53865. /**
  53866. * The value of the x axis
  53867. */
  53868. x: number;
  53869. /**
  53870. * The value of the y-axis
  53871. */
  53872. y: number;
  53873. }
  53874. /**
  53875. * changed / previous values for the values of this component
  53876. */
  53877. export interface IWebXRMotionControllerComponentChangesValues<T> {
  53878. /**
  53879. * current (this frame) value
  53880. */
  53881. current: T;
  53882. /**
  53883. * previous (last change) value
  53884. */
  53885. previous: T;
  53886. }
  53887. /**
  53888. * Represents changes in the component between current frame and last values recorded
  53889. */
  53890. export interface IWebXRMotionControllerComponentChanges {
  53891. /**
  53892. * will be populated with previous and current values if axes changed
  53893. */
  53894. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  53895. /**
  53896. * will be populated with previous and current values if pressed changed
  53897. */
  53898. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53899. /**
  53900. * will be populated with previous and current values if touched changed
  53901. */
  53902. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  53903. /**
  53904. * will be populated with previous and current values if value changed
  53905. */
  53906. value?: IWebXRMotionControllerComponentChangesValues<number>;
  53907. }
  53908. /**
  53909. * This class represents a single component (for example button or thumbstick) of a motion controller
  53910. */
  53911. export class WebXRControllerComponent implements IDisposable {
  53912. /**
  53913. * the id of this component
  53914. */
  53915. id: string;
  53916. /**
  53917. * the type of the component
  53918. */
  53919. type: MotionControllerComponentType;
  53920. private _buttonIndex;
  53921. private _axesIndices;
  53922. private _axes;
  53923. private _changes;
  53924. private _currentValue;
  53925. private _hasChanges;
  53926. private _pressed;
  53927. private _touched;
  53928. /**
  53929. * button component type
  53930. */
  53931. static BUTTON_TYPE: MotionControllerComponentType;
  53932. /**
  53933. * squeeze component type
  53934. */
  53935. static SQUEEZE_TYPE: MotionControllerComponentType;
  53936. /**
  53937. * Thumbstick component type
  53938. */
  53939. static THUMBSTICK_TYPE: MotionControllerComponentType;
  53940. /**
  53941. * Touchpad component type
  53942. */
  53943. static TOUCHPAD_TYPE: MotionControllerComponentType;
  53944. /**
  53945. * trigger component type
  53946. */
  53947. static TRIGGER_TYPE: MotionControllerComponentType;
  53948. /**
  53949. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  53950. * the axes data changes
  53951. */
  53952. onAxisValueChangedObservable: Observable<{
  53953. x: number;
  53954. y: number;
  53955. }>;
  53956. /**
  53957. * Observers registered here will be triggered when the state of a button changes
  53958. * State change is either pressed / touched / value
  53959. */
  53960. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  53961. /**
  53962. * Creates a new component for a motion controller.
  53963. * It is created by the motion controller itself
  53964. *
  53965. * @param id the id of this component
  53966. * @param type the type of the component
  53967. * @param _buttonIndex index in the buttons array of the gamepad
  53968. * @param _axesIndices indices of the values in the axes array of the gamepad
  53969. */
  53970. constructor(
  53971. /**
  53972. * the id of this component
  53973. */
  53974. id: string,
  53975. /**
  53976. * the type of the component
  53977. */
  53978. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  53979. /**
  53980. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  53981. */
  53982. get axes(): IWebXRMotionControllerAxesValue;
  53983. /**
  53984. * Get the changes. Elements will be populated only if they changed with their previous and current value
  53985. */
  53986. get changes(): IWebXRMotionControllerComponentChanges;
  53987. /**
  53988. * Return whether or not the component changed the last frame
  53989. */
  53990. get hasChanges(): boolean;
  53991. /**
  53992. * is the button currently pressed
  53993. */
  53994. get pressed(): boolean;
  53995. /**
  53996. * is the button currently touched
  53997. */
  53998. get touched(): boolean;
  53999. /**
  54000. * Get the current value of this component
  54001. */
  54002. get value(): number;
  54003. /**
  54004. * Dispose this component
  54005. */
  54006. dispose(): void;
  54007. /**
  54008. * Are there axes correlating to this component
  54009. * @return true is axes data is available
  54010. */
  54011. isAxes(): boolean;
  54012. /**
  54013. * Is this component a button (hence - pressable)
  54014. * @returns true if can be pressed
  54015. */
  54016. isButton(): boolean;
  54017. /**
  54018. * update this component using the gamepad object it is in. Called on every frame
  54019. * @param nativeController the native gamepad controller object
  54020. */
  54021. update(nativeController: IMinimalMotionControllerObject): void;
  54022. }
  54023. }
  54024. declare module BABYLON {
  54025. /**
  54026. * Type used for the success callback of ImportMesh
  54027. */
  54028. export type SceneLoaderSuccessCallback = (meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[], transformNodes: TransformNode[], geometries: Geometry[], lights: Light[]) => void;
  54029. /**
  54030. * Interface used for the result of ImportMeshAsync
  54031. */
  54032. export interface ISceneLoaderAsyncResult {
  54033. /**
  54034. * The array of loaded meshes
  54035. */
  54036. readonly meshes: AbstractMesh[];
  54037. /**
  54038. * The array of loaded particle systems
  54039. */
  54040. readonly particleSystems: IParticleSystem[];
  54041. /**
  54042. * The array of loaded skeletons
  54043. */
  54044. readonly skeletons: Skeleton[];
  54045. /**
  54046. * The array of loaded animation groups
  54047. */
  54048. readonly animationGroups: AnimationGroup[];
  54049. /**
  54050. * The array of loaded transform nodes
  54051. */
  54052. readonly transformNodes: TransformNode[];
  54053. /**
  54054. * The array of loaded geometries
  54055. */
  54056. readonly geometries: Geometry[];
  54057. /**
  54058. * The array of loaded lights
  54059. */
  54060. readonly lights: Light[];
  54061. }
  54062. /**
  54063. * Interface used to represent data loading progression
  54064. */
  54065. export interface ISceneLoaderProgressEvent {
  54066. /**
  54067. * Defines if data length to load can be evaluated
  54068. */
  54069. readonly lengthComputable: boolean;
  54070. /**
  54071. * Defines the loaded data length
  54072. */
  54073. readonly loaded: number;
  54074. /**
  54075. * Defines the data length to load
  54076. */
  54077. readonly total: number;
  54078. }
  54079. /**
  54080. * Interface used by SceneLoader plugins to define supported file extensions
  54081. */
  54082. export interface ISceneLoaderPluginExtensions {
  54083. /**
  54084. * Defines the list of supported extensions
  54085. */
  54086. [extension: string]: {
  54087. isBinary: boolean;
  54088. };
  54089. }
  54090. /**
  54091. * Interface used by SceneLoader plugin factory
  54092. */
  54093. export interface ISceneLoaderPluginFactory {
  54094. /**
  54095. * Defines the name of the factory
  54096. */
  54097. name: string;
  54098. /**
  54099. * Function called to create a new plugin
  54100. * @return the new plugin
  54101. */
  54102. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  54103. /**
  54104. * The callback that returns true if the data can be directly loaded.
  54105. * @param data string containing the file data
  54106. * @returns if the data can be loaded directly
  54107. */
  54108. canDirectLoad?(data: string): boolean;
  54109. }
  54110. /**
  54111. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  54112. */
  54113. export interface ISceneLoaderPluginBase {
  54114. /**
  54115. * The friendly name of this plugin.
  54116. */
  54117. name: string;
  54118. /**
  54119. * The file extensions supported by this plugin.
  54120. */
  54121. extensions: string | ISceneLoaderPluginExtensions;
  54122. /**
  54123. * The callback called when loading from a url.
  54124. * @param scene scene loading this url
  54125. * @param url url to load
  54126. * @param onSuccess callback called when the file successfully loads
  54127. * @param onProgress callback called while file is loading (if the server supports this mode)
  54128. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  54129. * @param onError callback called when the file fails to load
  54130. * @returns a file request object
  54131. */
  54132. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54133. /**
  54134. * The callback called when loading from a file object.
  54135. * @param scene scene loading this file
  54136. * @param file defines the file to load
  54137. * @param onSuccess defines the callback to call when data is loaded
  54138. * @param onProgress defines the callback to call during loading process
  54139. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  54140. * @param onError defines the callback to call when an error occurs
  54141. * @returns a file request object
  54142. */
  54143. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  54144. /**
  54145. * The callback that returns true if the data can be directly loaded.
  54146. * @param data string containing the file data
  54147. * @returns if the data can be loaded directly
  54148. */
  54149. canDirectLoad?(data: string): boolean;
  54150. /**
  54151. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  54152. * @param scene scene loading this data
  54153. * @param data string containing the data
  54154. * @returns data to pass to the plugin
  54155. */
  54156. directLoad?(scene: Scene, data: string): any;
  54157. /**
  54158. * The callback that allows custom handling of the root url based on the response url.
  54159. * @param rootUrl the original root url
  54160. * @param responseURL the response url if available
  54161. * @returns the new root url
  54162. */
  54163. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  54164. }
  54165. /**
  54166. * Interface used to define a SceneLoader plugin
  54167. */
  54168. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  54169. /**
  54170. * Import meshes into a scene.
  54171. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54172. * @param scene The scene to import into
  54173. * @param data The data to import
  54174. * @param rootUrl The root url for scene and resources
  54175. * @param meshes The meshes array to import into
  54176. * @param particleSystems The particle systems array to import into
  54177. * @param skeletons The skeletons array to import into
  54178. * @param onError The callback when import fails
  54179. * @returns True if successful or false otherwise
  54180. */
  54181. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  54182. /**
  54183. * Load into a scene.
  54184. * @param scene The scene to load into
  54185. * @param data The data to import
  54186. * @param rootUrl The root url for scene and resources
  54187. * @param onError The callback when import fails
  54188. * @returns True if successful or false otherwise
  54189. */
  54190. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  54191. /**
  54192. * Load into an asset container.
  54193. * @param scene The scene to load into
  54194. * @param data The data to import
  54195. * @param rootUrl The root url for scene and resources
  54196. * @param onError The callback when import fails
  54197. * @returns The loaded asset container
  54198. */
  54199. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  54200. }
  54201. /**
  54202. * Interface used to define an async SceneLoader plugin
  54203. */
  54204. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  54205. /**
  54206. * Import meshes into a scene.
  54207. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54208. * @param scene The scene to import into
  54209. * @param data The data to import
  54210. * @param rootUrl The root url for scene and resources
  54211. * @param onProgress The callback when the load progresses
  54212. * @param fileName Defines the name of the file to load
  54213. * @returns The loaded objects (e.g. meshes, particle systems, skeletons, animation groups, etc.)
  54214. */
  54215. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  54216. /**
  54217. * Load into a scene.
  54218. * @param scene The scene to load into
  54219. * @param data The data to import
  54220. * @param rootUrl The root url for scene and resources
  54221. * @param onProgress The callback when the load progresses
  54222. * @param fileName Defines the name of the file to load
  54223. * @returns Nothing
  54224. */
  54225. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  54226. /**
  54227. * Load into an asset container.
  54228. * @param scene The scene to load into
  54229. * @param data The data to import
  54230. * @param rootUrl The root url for scene and resources
  54231. * @param onProgress The callback when the load progresses
  54232. * @param fileName Defines the name of the file to load
  54233. * @returns The loaded asset container
  54234. */
  54235. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  54236. }
  54237. /**
  54238. * Mode that determines how to handle old animation groups before loading new ones.
  54239. */
  54240. export enum SceneLoaderAnimationGroupLoadingMode {
  54241. /**
  54242. * Reset all old animations to initial state then dispose them.
  54243. */
  54244. Clean = 0,
  54245. /**
  54246. * Stop all old animations.
  54247. */
  54248. Stop = 1,
  54249. /**
  54250. * Restart old animations from first frame.
  54251. */
  54252. Sync = 2,
  54253. /**
  54254. * Old animations remains untouched.
  54255. */
  54256. NoSync = 3
  54257. }
  54258. /**
  54259. * Defines a plugin registered by the SceneLoader
  54260. */
  54261. interface IRegisteredPlugin {
  54262. /**
  54263. * Defines the plugin to use
  54264. */
  54265. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54266. /**
  54267. * Defines if the plugin supports binary data
  54268. */
  54269. isBinary: boolean;
  54270. }
  54271. /**
  54272. * Class used to load scene from various file formats using registered plugins
  54273. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  54274. */
  54275. export class SceneLoader {
  54276. /**
  54277. * No logging while loading
  54278. */
  54279. static readonly NO_LOGGING: number;
  54280. /**
  54281. * Minimal logging while loading
  54282. */
  54283. static readonly MINIMAL_LOGGING: number;
  54284. /**
  54285. * Summary logging while loading
  54286. */
  54287. static readonly SUMMARY_LOGGING: number;
  54288. /**
  54289. * Detailled logging while loading
  54290. */
  54291. static readonly DETAILED_LOGGING: number;
  54292. /**
  54293. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  54294. */
  54295. static get ForceFullSceneLoadingForIncremental(): boolean;
  54296. static set ForceFullSceneLoadingForIncremental(value: boolean);
  54297. /**
  54298. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  54299. */
  54300. static get ShowLoadingScreen(): boolean;
  54301. static set ShowLoadingScreen(value: boolean);
  54302. /**
  54303. * Defines the current logging level (while loading the scene)
  54304. * @ignorenaming
  54305. */
  54306. static get loggingLevel(): number;
  54307. static set loggingLevel(value: number);
  54308. /**
  54309. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  54310. */
  54311. static get CleanBoneMatrixWeights(): boolean;
  54312. static set CleanBoneMatrixWeights(value: boolean);
  54313. /**
  54314. * Event raised when a plugin is used to load a scene
  54315. */
  54316. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  54317. private static _registeredPlugins;
  54318. private static _showingLoadingScreen;
  54319. /**
  54320. * Gets the default plugin (used to load Babylon files)
  54321. * @returns the .babylon plugin
  54322. */
  54323. static GetDefaultPlugin(): IRegisteredPlugin;
  54324. private static _GetPluginForExtension;
  54325. private static _GetPluginForDirectLoad;
  54326. private static _GetPluginForFilename;
  54327. private static _GetDirectLoad;
  54328. private static _LoadData;
  54329. private static _GetFileInfo;
  54330. /**
  54331. * Gets a plugin that can load the given extension
  54332. * @param extension defines the extension to load
  54333. * @returns a plugin or null if none works
  54334. */
  54335. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  54336. /**
  54337. * Gets a boolean indicating that the given extension can be loaded
  54338. * @param extension defines the extension to load
  54339. * @returns true if the extension is supported
  54340. */
  54341. static IsPluginForExtensionAvailable(extension: string): boolean;
  54342. /**
  54343. * Adds a new plugin to the list of registered plugins
  54344. * @param plugin defines the plugin to add
  54345. */
  54346. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  54347. /**
  54348. * Import meshes into a scene
  54349. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54350. * @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)
  54351. * @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)
  54352. * @param scene the instance of BABYLON.Scene to append to
  54353. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  54354. * @param onProgress a callback with a progress event for each file being loaded
  54355. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54356. * @param pluginExtension the extension used to determine the plugin
  54357. * @returns The loaded plugin
  54358. */
  54359. 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>;
  54360. /**
  54361. * Import meshes into a scene
  54362. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  54363. * @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)
  54364. * @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)
  54365. * @param scene the instance of BABYLON.Scene to append to
  54366. * @param onProgress a callback with a progress event for each file being loaded
  54367. * @param pluginExtension the extension used to determine the plugin
  54368. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  54369. */
  54370. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<ISceneLoaderAsyncResult>;
  54371. /**
  54372. * Load a scene
  54373. * @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)
  54374. * @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)
  54375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54376. * @param onSuccess a callback with the scene when import succeeds
  54377. * @param onProgress a callback with a progress event for each file being loaded
  54378. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54379. * @param pluginExtension the extension used to determine the plugin
  54380. * @returns The loaded plugin
  54381. */
  54382. 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>;
  54383. /**
  54384. * Load a scene
  54385. * @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)
  54386. * @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)
  54387. * @param engine is the instance of BABYLON.Engine to use to create the scene
  54388. * @param onProgress a callback with a progress event for each file being loaded
  54389. * @param pluginExtension the extension used to determine the plugin
  54390. * @returns The loaded scene
  54391. */
  54392. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54393. /**
  54394. * Append a scene
  54395. * @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)
  54396. * @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)
  54397. * @param scene is the instance of BABYLON.Scene to append to
  54398. * @param onSuccess a callback with the scene when import succeeds
  54399. * @param onProgress a callback with a progress event for each file being loaded
  54400. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54401. * @param pluginExtension the extension used to determine the plugin
  54402. * @returns The loaded plugin
  54403. */
  54404. 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>;
  54405. /**
  54406. * Append a scene
  54407. * @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)
  54408. * @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)
  54409. * @param scene is the instance of BABYLON.Scene to append to
  54410. * @param onProgress a callback with a progress event for each file being loaded
  54411. * @param pluginExtension the extension used to determine the plugin
  54412. * @returns The given scene
  54413. */
  54414. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  54415. /**
  54416. * Load a scene into an asset container
  54417. * @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)
  54418. * @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)
  54419. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54420. * @param onSuccess a callback with the scene when import succeeds
  54421. * @param onProgress a callback with a progress event for each file being loaded
  54422. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54423. * @param pluginExtension the extension used to determine the plugin
  54424. * @returns The loaded plugin
  54425. */
  54426. 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>;
  54427. /**
  54428. * Load a scene into an asset container
  54429. * @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)
  54430. * @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)
  54431. * @param scene is the instance of Scene to append to
  54432. * @param onProgress a callback with a progress event for each file being loaded
  54433. * @param pluginExtension the extension used to determine the plugin
  54434. * @returns The loaded asset container
  54435. */
  54436. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  54437. /**
  54438. * Import animations from a file into a scene
  54439. * @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)
  54440. * @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)
  54441. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54442. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54443. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54444. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54445. * @param onSuccess a callback with the scene when import succeeds
  54446. * @param onProgress a callback with a progress event for each file being loaded
  54447. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54448. * @param pluginExtension the extension used to determine the plugin
  54449. */
  54450. 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;
  54451. /**
  54452. * Import animations from a file into a scene
  54453. * @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)
  54454. * @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)
  54455. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  54456. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  54457. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  54458. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  54459. * @param onSuccess a callback with the scene when import succeeds
  54460. * @param onProgress a callback with a progress event for each file being loaded
  54461. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  54462. * @param pluginExtension the extension used to determine the plugin
  54463. * @returns the updated scene with imported animations
  54464. */
  54465. 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>;
  54466. }
  54467. }
  54468. declare module BABYLON {
  54469. /**
  54470. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  54471. */
  54472. export type MotionControllerHandedness = "none" | "left" | "right";
  54473. /**
  54474. * The type of components available in motion controllers.
  54475. * This is not the name of the component.
  54476. */
  54477. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  54478. /**
  54479. * The state of a controller component
  54480. */
  54481. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  54482. /**
  54483. * The schema of motion controller layout.
  54484. * No object will be initialized using this interface
  54485. * This is used just to define the profile.
  54486. */
  54487. export interface IMotionControllerLayout {
  54488. /**
  54489. * Path to load the assets. Usually relative to the base path
  54490. */
  54491. assetPath: string;
  54492. /**
  54493. * Available components (unsorted)
  54494. */
  54495. components: {
  54496. /**
  54497. * A map of component Ids
  54498. */
  54499. [componentId: string]: {
  54500. /**
  54501. * The type of input the component outputs
  54502. */
  54503. type: MotionControllerComponentType;
  54504. /**
  54505. * The indices of this component in the gamepad object
  54506. */
  54507. gamepadIndices: {
  54508. /**
  54509. * Index of button
  54510. */
  54511. button?: number;
  54512. /**
  54513. * If available, index of x-axis
  54514. */
  54515. xAxis?: number;
  54516. /**
  54517. * If available, index of y-axis
  54518. */
  54519. yAxis?: number;
  54520. };
  54521. /**
  54522. * The mesh's root node name
  54523. */
  54524. rootNodeName: string;
  54525. /**
  54526. * Animation definitions for this model
  54527. */
  54528. visualResponses: {
  54529. [stateKey: string]: {
  54530. /**
  54531. * What property will be animated
  54532. */
  54533. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  54534. /**
  54535. * What states influence this visual response
  54536. */
  54537. states: MotionControllerComponentStateType[];
  54538. /**
  54539. * Type of animation - movement or visibility
  54540. */
  54541. valueNodeProperty: "transform" | "visibility";
  54542. /**
  54543. * Base node name to move. Its position will be calculated according to the min and max nodes
  54544. */
  54545. valueNodeName?: string;
  54546. /**
  54547. * Minimum movement node
  54548. */
  54549. minNodeName?: string;
  54550. /**
  54551. * Max movement node
  54552. */
  54553. maxNodeName?: string;
  54554. };
  54555. };
  54556. /**
  54557. * If touch enabled, what is the name of node to display user feedback
  54558. */
  54559. touchPointNodeName?: string;
  54560. };
  54561. };
  54562. /**
  54563. * Is it xr standard mapping or not
  54564. */
  54565. gamepadMapping: "" | "xr-standard";
  54566. /**
  54567. * Base root node of this entire model
  54568. */
  54569. rootNodeName: string;
  54570. /**
  54571. * Defines the main button component id
  54572. */
  54573. selectComponentId: string;
  54574. }
  54575. /**
  54576. * A definition for the layout map in the input profile
  54577. */
  54578. export interface IMotionControllerLayoutMap {
  54579. /**
  54580. * Layouts with handedness type as a key
  54581. */
  54582. [handedness: string]: IMotionControllerLayout;
  54583. }
  54584. /**
  54585. * The XR Input profile schema
  54586. * Profiles can be found here:
  54587. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  54588. */
  54589. export interface IMotionControllerProfile {
  54590. /**
  54591. * fallback profiles for this profileId
  54592. */
  54593. fallbackProfileIds: string[];
  54594. /**
  54595. * The layout map, with handedness as key
  54596. */
  54597. layouts: IMotionControllerLayoutMap;
  54598. /**
  54599. * The id of this profile
  54600. * correlates to the profile(s) in the xrInput.profiles array
  54601. */
  54602. profileId: string;
  54603. }
  54604. /**
  54605. * A helper-interface for the 3 meshes needed for controller button animation
  54606. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  54607. */
  54608. export interface IMotionControllerButtonMeshMap {
  54609. /**
  54610. * the mesh that defines the pressed value mesh position.
  54611. * This is used to find the max-position of this button
  54612. */
  54613. pressedMesh: AbstractMesh;
  54614. /**
  54615. * the mesh that defines the unpressed value mesh position.
  54616. * This is used to find the min (or initial) position of this button
  54617. */
  54618. unpressedMesh: AbstractMesh;
  54619. /**
  54620. * The mesh that will be changed when value changes
  54621. */
  54622. valueMesh: AbstractMesh;
  54623. }
  54624. /**
  54625. * A helper-interface for the 3 meshes needed for controller axis animation.
  54626. * This will be expanded when touchpad animations are fully supported
  54627. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  54628. */
  54629. export interface IMotionControllerMeshMap {
  54630. /**
  54631. * the mesh that defines the maximum value mesh position.
  54632. */
  54633. maxMesh?: AbstractMesh;
  54634. /**
  54635. * the mesh that defines the minimum value mesh position.
  54636. */
  54637. minMesh?: AbstractMesh;
  54638. /**
  54639. * The mesh that will be changed when axis value changes
  54640. */
  54641. valueMesh?: AbstractMesh;
  54642. }
  54643. /**
  54644. * The elements needed for change-detection of the gamepad objects in motion controllers
  54645. */
  54646. export interface IMinimalMotionControllerObject {
  54647. /**
  54648. * Available axes of this controller
  54649. */
  54650. axes: number[];
  54651. /**
  54652. * An array of available buttons
  54653. */
  54654. buttons: Array<{
  54655. /**
  54656. * Value of the button/trigger
  54657. */
  54658. value: number;
  54659. /**
  54660. * If the button/trigger is currently touched
  54661. */
  54662. touched: boolean;
  54663. /**
  54664. * If the button/trigger is currently pressed
  54665. */
  54666. pressed: boolean;
  54667. }>;
  54668. /**
  54669. * EXPERIMENTAL haptic support.
  54670. */
  54671. hapticActuators?: Array<{
  54672. pulse: (value: number, duration: number) => Promise<boolean>;
  54673. }>;
  54674. }
  54675. /**
  54676. * An Abstract Motion controller
  54677. * This class receives an xrInput and a profile layout and uses those to initialize the components
  54678. * Each component has an observable to check for changes in value and state
  54679. */
  54680. export abstract class WebXRAbstractMotionController implements IDisposable {
  54681. protected scene: Scene;
  54682. protected layout: IMotionControllerLayout;
  54683. /**
  54684. * The gamepad object correlating to this controller
  54685. */
  54686. gamepadObject: IMinimalMotionControllerObject;
  54687. /**
  54688. * handedness (left/right/none) of this controller
  54689. */
  54690. handedness: MotionControllerHandedness;
  54691. private _initComponent;
  54692. private _modelReady;
  54693. /**
  54694. * A map of components (WebXRControllerComponent) in this motion controller
  54695. * Components have a ComponentType and can also have both button and axis definitions
  54696. */
  54697. readonly components: {
  54698. [id: string]: WebXRControllerComponent;
  54699. };
  54700. /**
  54701. * Disable the model's animation. Can be set at any time.
  54702. */
  54703. disableAnimation: boolean;
  54704. /**
  54705. * Observers registered here will be triggered when the model of this controller is done loading
  54706. */
  54707. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  54708. /**
  54709. * The profile id of this motion controller
  54710. */
  54711. abstract profileId: string;
  54712. /**
  54713. * The root mesh of the model. It is null if the model was not yet initialized
  54714. */
  54715. rootMesh: Nullable<AbstractMesh>;
  54716. /**
  54717. * constructs a new abstract motion controller
  54718. * @param scene the scene to which the model of the controller will be added
  54719. * @param layout The profile layout to load
  54720. * @param gamepadObject The gamepad object correlating to this controller
  54721. * @param handedness handedness (left/right/none) of this controller
  54722. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  54723. */
  54724. constructor(scene: Scene, layout: IMotionControllerLayout,
  54725. /**
  54726. * The gamepad object correlating to this controller
  54727. */
  54728. gamepadObject: IMinimalMotionControllerObject,
  54729. /**
  54730. * handedness (left/right/none) of this controller
  54731. */
  54732. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  54733. /**
  54734. * Dispose this controller, the model mesh and all its components
  54735. */
  54736. dispose(): void;
  54737. /**
  54738. * Returns all components of specific type
  54739. * @param type the type to search for
  54740. * @return an array of components with this type
  54741. */
  54742. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  54743. /**
  54744. * get a component based an its component id as defined in layout.components
  54745. * @param id the id of the component
  54746. * @returns the component correlates to the id or undefined if not found
  54747. */
  54748. getComponent(id: string): WebXRControllerComponent;
  54749. /**
  54750. * Get the list of components available in this motion controller
  54751. * @returns an array of strings correlating to available components
  54752. */
  54753. getComponentIds(): string[];
  54754. /**
  54755. * Get the first component of specific type
  54756. * @param type type of component to find
  54757. * @return a controller component or null if not found
  54758. */
  54759. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  54760. /**
  54761. * Get the main (Select) component of this controller as defined in the layout
  54762. * @returns the main component of this controller
  54763. */
  54764. getMainComponent(): WebXRControllerComponent;
  54765. /**
  54766. * Loads the model correlating to this controller
  54767. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  54768. * @returns A promise fulfilled with the result of the model loading
  54769. */
  54770. loadModel(): Promise<boolean>;
  54771. /**
  54772. * Update this model using the current XRFrame
  54773. * @param xrFrame the current xr frame to use and update the model
  54774. */
  54775. updateFromXRFrame(xrFrame: XRFrame): void;
  54776. /**
  54777. * Backwards compatibility due to a deeply-integrated typo
  54778. */
  54779. get handness(): XREye;
  54780. /**
  54781. * Pulse (vibrate) this controller
  54782. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  54783. * Consecutive calls to this function will cancel the last pulse call
  54784. *
  54785. * @param value the strength of the pulse in 0.0...1.0 range
  54786. * @param duration Duration of the pulse in milliseconds
  54787. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  54788. * @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
  54789. */
  54790. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  54791. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54792. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  54793. /**
  54794. * Moves the axis on the controller mesh based on its current state
  54795. * @param axis the index of the axis
  54796. * @param axisValue the value of the axis which determines the meshes new position
  54797. * @hidden
  54798. */
  54799. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  54800. /**
  54801. * Update the model itself with the current frame data
  54802. * @param xrFrame the frame to use for updating the model mesh
  54803. */
  54804. protected updateModel(xrFrame: XRFrame): void;
  54805. /**
  54806. * Get the filename and path for this controller's model
  54807. * @returns a map of filename and path
  54808. */
  54809. protected abstract _getFilenameAndPath(): {
  54810. filename: string;
  54811. path: string;
  54812. };
  54813. /**
  54814. * This function is called before the mesh is loaded. It checks for loading constraints.
  54815. * For example, this function can check if the GLB loader is available
  54816. * If this function returns false, the generic controller will be loaded instead
  54817. * @returns Is the client ready to load the mesh
  54818. */
  54819. protected abstract _getModelLoadingConstraints(): boolean;
  54820. /**
  54821. * This function will be called after the model was successfully loaded and can be used
  54822. * for mesh transformations before it is available for the user
  54823. * @param meshes the loaded meshes
  54824. */
  54825. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  54826. /**
  54827. * Set the root mesh for this controller. Important for the WebXR controller class
  54828. * @param meshes the loaded meshes
  54829. */
  54830. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  54831. /**
  54832. * A function executed each frame that updates the mesh (if needed)
  54833. * @param xrFrame the current xrFrame
  54834. */
  54835. protected abstract _updateModel(xrFrame: XRFrame): void;
  54836. private _getGenericFilenameAndPath;
  54837. private _getGenericParentMesh;
  54838. }
  54839. }
  54840. declare module BABYLON {
  54841. /**
  54842. * A generic trigger-only motion controller for WebXR
  54843. */
  54844. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  54845. /**
  54846. * Static version of the profile id of this controller
  54847. */
  54848. static ProfileId: string;
  54849. profileId: string;
  54850. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  54851. protected _getFilenameAndPath(): {
  54852. filename: string;
  54853. path: string;
  54854. };
  54855. protected _getModelLoadingConstraints(): boolean;
  54856. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  54857. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54858. protected _updateModel(): void;
  54859. }
  54860. }
  54861. declare module BABYLON {
  54862. /**
  54863. * Class containing static functions to help procedurally build meshes
  54864. */
  54865. export class SphereBuilder {
  54866. /**
  54867. * Creates a sphere mesh
  54868. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54869. * * 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`)
  54870. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54871. * * 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
  54872. * * 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)
  54873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54874. * * 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
  54875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54876. * @param name defines the name of the mesh
  54877. * @param options defines the options used to create the mesh
  54878. * @param scene defines the hosting scene
  54879. * @returns the sphere mesh
  54880. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54881. */
  54882. static CreateSphere(name: string, options: {
  54883. segments?: number;
  54884. diameter?: number;
  54885. diameterX?: number;
  54886. diameterY?: number;
  54887. diameterZ?: number;
  54888. arc?: number;
  54889. slice?: number;
  54890. sideOrientation?: number;
  54891. frontUVs?: Vector4;
  54892. backUVs?: Vector4;
  54893. updatable?: boolean;
  54894. }, scene?: Nullable<Scene>): Mesh;
  54895. }
  54896. }
  54897. declare module BABYLON {
  54898. /**
  54899. * A profiled motion controller has its profile loaded from an online repository.
  54900. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  54901. */
  54902. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  54903. private _repositoryUrl;
  54904. private _buttonMeshMapping;
  54905. private _touchDots;
  54906. /**
  54907. * The profile ID of this controller. Will be populated when the controller initializes.
  54908. */
  54909. profileId: string;
  54910. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  54911. dispose(): void;
  54912. protected _getFilenameAndPath(): {
  54913. filename: string;
  54914. path: string;
  54915. };
  54916. protected _getModelLoadingConstraints(): boolean;
  54917. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  54918. protected _setRootMesh(meshes: AbstractMesh[]): void;
  54919. protected _updateModel(_xrFrame: XRFrame): void;
  54920. }
  54921. }
  54922. declare module BABYLON {
  54923. /**
  54924. * A construction function type to create a new controller based on an xrInput object
  54925. */
  54926. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  54927. /**
  54928. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  54929. *
  54930. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  54931. * it should be replaced with auto-loaded controllers.
  54932. *
  54933. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  54934. */
  54935. export class WebXRMotionControllerManager {
  54936. private static _AvailableControllers;
  54937. private static _Fallbacks;
  54938. private static _ProfileLoadingPromises;
  54939. private static _ProfilesList;
  54940. /**
  54941. * The base URL of the online controller repository. Can be changed at any time.
  54942. */
  54943. static BaseRepositoryUrl: string;
  54944. /**
  54945. * Which repository gets priority - local or online
  54946. */
  54947. static PrioritizeOnlineRepository: boolean;
  54948. /**
  54949. * Use the online repository, or use only locally-defined controllers
  54950. */
  54951. static UseOnlineRepository: boolean;
  54952. /**
  54953. * Clear the cache used for profile loading and reload when requested again
  54954. */
  54955. static ClearProfilesCache(): void;
  54956. /**
  54957. * Register the default fallbacks.
  54958. * This function is called automatically when this file is imported.
  54959. */
  54960. static DefaultFallbacks(): void;
  54961. /**
  54962. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  54963. * @param profileId the profile to which a fallback needs to be found
  54964. * @return an array with corresponding fallback profiles
  54965. */
  54966. static FindFallbackWithProfileId(profileId: string): string[];
  54967. /**
  54968. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  54969. * The order of search:
  54970. *
  54971. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  54972. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  54973. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  54974. * 4) return the generic trigger controller if none were found
  54975. *
  54976. * @param xrInput the xrInput to which a new controller is initialized
  54977. * @param scene the scene to which the model will be added
  54978. * @param forceProfile force a certain profile for this controller
  54979. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  54980. */
  54981. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  54982. /**
  54983. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  54984. *
  54985. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  54986. *
  54987. * @param type the profile type to register
  54988. * @param constructFunction the function to be called when loading this profile
  54989. */
  54990. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  54991. /**
  54992. * Register a fallback to a specific profile.
  54993. * @param profileId the profileId that will receive the fallbacks
  54994. * @param fallbacks A list of fallback profiles
  54995. */
  54996. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  54997. /**
  54998. * Will update the list of profiles available in the repository
  54999. * @return a promise that resolves to a map of profiles available online
  55000. */
  55001. static UpdateProfilesList(): Promise<{
  55002. [profile: string]: string;
  55003. }>;
  55004. private static _LoadProfileFromRepository;
  55005. private static _LoadProfilesFromAvailableControllers;
  55006. }
  55007. }
  55008. declare module BABYLON {
  55009. /**
  55010. * Configuration options for the WebXR controller creation
  55011. */
  55012. export interface IWebXRControllerOptions {
  55013. /**
  55014. * Should the controller mesh be animated when a user interacts with it
  55015. * The pressed buttons / thumbstick and touchpad animations will be disabled
  55016. */
  55017. disableMotionControllerAnimation?: boolean;
  55018. /**
  55019. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  55020. */
  55021. doNotLoadControllerMesh?: boolean;
  55022. /**
  55023. * Force a specific controller type for this controller.
  55024. * This can be used when creating your own profile or when testing different controllers
  55025. */
  55026. forceControllerProfile?: string;
  55027. /**
  55028. * Defines a rendering group ID for meshes that will be loaded.
  55029. * This is for the default controllers only.
  55030. */
  55031. renderingGroupId?: number;
  55032. }
  55033. /**
  55034. * Represents an XR controller
  55035. */
  55036. export class WebXRInputSource {
  55037. private _scene;
  55038. /** The underlying input source for the controller */
  55039. inputSource: XRInputSource;
  55040. private _options;
  55041. private _tmpVector;
  55042. private _uniqueId;
  55043. private _disposed;
  55044. /**
  55045. * Represents the part of the controller that is held. This may not exist if the controller is the head mounted display itself, if thats the case only the pointer from the head will be availible
  55046. */
  55047. grip?: AbstractMesh;
  55048. /**
  55049. * If available, this is the gamepad object related to this controller.
  55050. * Using this object it is possible to get click events and trackpad changes of the
  55051. * webxr controller that is currently being used.
  55052. */
  55053. motionController?: WebXRAbstractMotionController;
  55054. /**
  55055. * Event that fires when the controller is removed/disposed.
  55056. * The object provided as event data is this controller, after associated assets were disposed.
  55057. * uniqueId is still available.
  55058. */
  55059. onDisposeObservable: Observable<WebXRInputSource>;
  55060. /**
  55061. * Will be triggered when the mesh associated with the motion controller is done loading.
  55062. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  55063. * A shortened version of controller -> motion controller -> on mesh loaded.
  55064. */
  55065. onMeshLoadedObservable: Observable<AbstractMesh>;
  55066. /**
  55067. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  55068. */
  55069. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  55070. /**
  55071. * Pointer which can be used to select objects or attach a visible laser to
  55072. */
  55073. pointer: AbstractMesh;
  55074. /**
  55075. * Creates the input source object
  55076. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  55077. * @param _scene the scene which the controller should be associated to
  55078. * @param inputSource the underlying input source for the controller
  55079. * @param _options options for this controller creation
  55080. */
  55081. constructor(_scene: Scene,
  55082. /** The underlying input source for the controller */
  55083. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  55084. /**
  55085. * Get this controllers unique id
  55086. */
  55087. get uniqueId(): string;
  55088. /**
  55089. * Disposes of the object
  55090. */
  55091. dispose(): void;
  55092. /**
  55093. * Gets a world space ray coming from the pointer or grip
  55094. * @param result the resulting ray
  55095. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  55096. */
  55097. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  55098. /**
  55099. * Updates the controller pose based on the given XRFrame
  55100. * @param xrFrame xr frame to update the pose with
  55101. * @param referenceSpace reference space to use
  55102. */
  55103. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  55104. }
  55105. }
  55106. declare module BABYLON {
  55107. /**
  55108. * The schema for initialization options of the XR Input class
  55109. */
  55110. export interface IWebXRInputOptions {
  55111. /**
  55112. * If set to true no model will be automatically loaded
  55113. */
  55114. doNotLoadControllerMeshes?: boolean;
  55115. /**
  55116. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  55117. * If not found, the xr input profile data will be used.
  55118. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  55119. */
  55120. forceInputProfile?: string;
  55121. /**
  55122. * Do not send a request to the controller repository to load the profile.
  55123. *
  55124. * Instead, use the controllers available in babylon itself.
  55125. */
  55126. disableOnlineControllerRepository?: boolean;
  55127. /**
  55128. * A custom URL for the controllers repository
  55129. */
  55130. customControllersRepositoryURL?: string;
  55131. /**
  55132. * Should the controller model's components not move according to the user input
  55133. */
  55134. disableControllerAnimation?: boolean;
  55135. /**
  55136. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  55137. */
  55138. controllerOptions?: IWebXRControllerOptions;
  55139. }
  55140. /**
  55141. * XR input used to track XR inputs such as controllers/rays
  55142. */
  55143. export class WebXRInput implements IDisposable {
  55144. /**
  55145. * the xr session manager for this session
  55146. */
  55147. xrSessionManager: WebXRSessionManager;
  55148. /**
  55149. * the WebXR camera for this session. Mainly used for teleportation
  55150. */
  55151. xrCamera: WebXRCamera;
  55152. private readonly options;
  55153. /**
  55154. * XR controllers being tracked
  55155. */
  55156. controllers: Array<WebXRInputSource>;
  55157. private _frameObserver;
  55158. private _sessionEndedObserver;
  55159. private _sessionInitObserver;
  55160. /**
  55161. * Event when a controller has been connected/added
  55162. */
  55163. onControllerAddedObservable: Observable<WebXRInputSource>;
  55164. /**
  55165. * Event when a controller has been removed/disconnected
  55166. */
  55167. onControllerRemovedObservable: Observable<WebXRInputSource>;
  55168. /**
  55169. * Initializes the WebXRInput
  55170. * @param xrSessionManager the xr session manager for this session
  55171. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  55172. * @param options = initialization options for this xr input
  55173. */
  55174. constructor(
  55175. /**
  55176. * the xr session manager for this session
  55177. */
  55178. xrSessionManager: WebXRSessionManager,
  55179. /**
  55180. * the WebXR camera for this session. Mainly used for teleportation
  55181. */
  55182. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  55183. private _onInputSourcesChange;
  55184. private _addAndRemoveControllers;
  55185. /**
  55186. * Disposes of the object
  55187. */
  55188. dispose(): void;
  55189. }
  55190. }
  55191. declare module BABYLON {
  55192. /**
  55193. * This is the base class for all WebXR features.
  55194. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  55195. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  55196. */
  55197. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  55198. protected _xrSessionManager: WebXRSessionManager;
  55199. private _attached;
  55200. private _removeOnDetach;
  55201. /**
  55202. * Is this feature disposed?
  55203. */
  55204. isDisposed: boolean;
  55205. /**
  55206. * Should auto-attach be disabled?
  55207. */
  55208. disableAutoAttach: boolean;
  55209. /**
  55210. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  55211. */
  55212. xrNativeFeatureName: string;
  55213. /**
  55214. * Construct a new (abstract) WebXR feature
  55215. * @param _xrSessionManager the xr session manager for this feature
  55216. */
  55217. constructor(_xrSessionManager: WebXRSessionManager);
  55218. /**
  55219. * Is this feature attached
  55220. */
  55221. get attached(): boolean;
  55222. /**
  55223. * attach this feature
  55224. *
  55225. * @param force should attachment be forced (even when already attached)
  55226. * @returns true if successful, false is failed or already attached
  55227. */
  55228. attach(force?: boolean): boolean;
  55229. /**
  55230. * detach this feature.
  55231. *
  55232. * @returns true if successful, false if failed or already detached
  55233. */
  55234. detach(): boolean;
  55235. /**
  55236. * Dispose this feature and all of the resources attached
  55237. */
  55238. dispose(): void;
  55239. /**
  55240. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  55241. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  55242. *
  55243. * @returns whether or not the feature is compatible in this environment
  55244. */
  55245. isCompatible(): boolean;
  55246. /**
  55247. * This is used to register callbacks that will automatically be removed when detach is called.
  55248. * @param observable the observable to which the observer will be attached
  55249. * @param callback the callback to register
  55250. */
  55251. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  55252. /**
  55253. * Code in this function will be executed on each xrFrame received from the browser.
  55254. * This function will not execute after the feature is detached.
  55255. * @param _xrFrame the current frame
  55256. */
  55257. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  55258. }
  55259. }
  55260. declare module BABYLON {
  55261. /**
  55262. * Renders a layer on top of an existing scene
  55263. */
  55264. export class UtilityLayerRenderer implements IDisposable {
  55265. /** the original scene that will be rendered on top of */
  55266. originalScene: Scene;
  55267. private _pointerCaptures;
  55268. private _lastPointerEvents;
  55269. private static _DefaultUtilityLayer;
  55270. private static _DefaultKeepDepthUtilityLayer;
  55271. private _sharedGizmoLight;
  55272. private _renderCamera;
  55273. /**
  55274. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  55275. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  55276. * @returns the camera that is used when rendering the utility layer
  55277. */
  55278. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  55279. /**
  55280. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  55281. * @param cam the camera that should be used when rendering the utility layer
  55282. */
  55283. setRenderCamera(cam: Nullable<Camera>): void;
  55284. /**
  55285. * @hidden
  55286. * Light which used by gizmos to get light shading
  55287. */
  55288. _getSharedGizmoLight(): HemisphericLight;
  55289. /**
  55290. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  55291. */
  55292. pickUtilitySceneFirst: boolean;
  55293. /**
  55294. * 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)
  55295. */
  55296. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  55297. /**
  55298. * 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)
  55299. */
  55300. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  55301. /**
  55302. * The scene that is rendered on top of the original scene
  55303. */
  55304. utilityLayerScene: Scene;
  55305. /**
  55306. * If the utility layer should automatically be rendered on top of existing scene
  55307. */
  55308. shouldRender: boolean;
  55309. /**
  55310. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  55311. */
  55312. onlyCheckPointerDownEvents: boolean;
  55313. /**
  55314. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  55315. */
  55316. processAllEvents: boolean;
  55317. /**
  55318. * Observable raised when the pointer move from the utility layer scene to the main scene
  55319. */
  55320. onPointerOutObservable: Observable<number>;
  55321. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  55322. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  55323. private _afterRenderObserver;
  55324. private _sceneDisposeObserver;
  55325. private _originalPointerObserver;
  55326. /**
  55327. * Instantiates a UtilityLayerRenderer
  55328. * @param originalScene the original scene that will be rendered on top of
  55329. * @param handleEvents boolean indicating if the utility layer should handle events
  55330. */
  55331. constructor(
  55332. /** the original scene that will be rendered on top of */
  55333. originalScene: Scene, handleEvents?: boolean);
  55334. private _notifyObservers;
  55335. /**
  55336. * Renders the utility layers scene on top of the original scene
  55337. */
  55338. render(): void;
  55339. /**
  55340. * Disposes of the renderer
  55341. */
  55342. dispose(): void;
  55343. private _updateCamera;
  55344. }
  55345. }
  55346. declare module BABYLON {
  55347. /**
  55348. * Options interface for the pointer selection module
  55349. */
  55350. export interface IWebXRControllerPointerSelectionOptions {
  55351. /**
  55352. * if provided, this scene will be used to render meshes.
  55353. */
  55354. customUtilityLayerScene?: Scene;
  55355. /**
  55356. * 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)
  55357. * If not disabled, the last picked point will be used to execute a pointer up event
  55358. * If disabled, pointer up event will be triggered right after the pointer down event.
  55359. * Used in screen and gaze target ray mode only
  55360. */
  55361. disablePointerUpOnTouchOut: boolean;
  55362. /**
  55363. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  55364. */
  55365. forceGazeMode: boolean;
  55366. /**
  55367. * 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
  55368. * to start a new countdown to the pointer down event.
  55369. * Defaults to 1.
  55370. */
  55371. gazeModePointerMovedFactor?: number;
  55372. /**
  55373. * Different button type to use instead of the main component
  55374. */
  55375. overrideButtonId?: string;
  55376. /**
  55377. * use this rendering group id for the meshes (optional)
  55378. */
  55379. renderingGroupId?: number;
  55380. /**
  55381. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  55382. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  55383. * 3000 means 3 seconds between pointing at something and selecting it
  55384. */
  55385. timeToSelect?: number;
  55386. /**
  55387. * Should meshes created here be added to a utility layer or the main scene
  55388. */
  55389. useUtilityLayer?: boolean;
  55390. /**
  55391. * Optional WebXR camera to be used for gaze selection
  55392. */
  55393. gazeCamera?: WebXRCamera;
  55394. /**
  55395. * the xr input to use with this pointer selection
  55396. */
  55397. xrInput: WebXRInput;
  55398. /**
  55399. * Should the scene pointerX and pointerY update be disabled
  55400. * This is required for fullscreen AR GUI, but might slow down other experiences.
  55401. * Disable in VR, if not needed.
  55402. * The first rig camera (left eye) will be used to calculate the projection
  55403. */
  55404. disableScenePointerVectorUpdate: boolean;
  55405. /**
  55406. * Enable pointer selection on all controllers instead of switching between them
  55407. */
  55408. enablePointerSelectionOnAllControllers?: boolean;
  55409. /**
  55410. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  55411. * If switch is enabled, it will still allow the user to switch between the different controllers
  55412. */
  55413. preferredHandedness?: XRHandedness;
  55414. /**
  55415. * Disable switching the pointer selection from one controller to the other.
  55416. * 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
  55417. */
  55418. disableSwitchOnClick?: boolean;
  55419. /**
  55420. * The maximum distance of the pointer selection feature. Defaults to 100.
  55421. */
  55422. maxPointerDistance?: number;
  55423. }
  55424. /**
  55425. * A module that will enable pointer selection for motion controllers of XR Input Sources
  55426. */
  55427. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  55428. private readonly _options;
  55429. private static _idCounter;
  55430. private _attachController;
  55431. private _controllers;
  55432. private _scene;
  55433. private _tmpVectorForPickCompare;
  55434. private _attachedController;
  55435. /**
  55436. * The module's name
  55437. */
  55438. static readonly Name: string;
  55439. /**
  55440. * The (Babylon) version of this module.
  55441. * This is an integer representing the implementation version.
  55442. * This number does not correspond to the WebXR specs version
  55443. */
  55444. static readonly Version: number;
  55445. /**
  55446. * Disable lighting on the laser pointer (so it will always be visible)
  55447. */
  55448. disablePointerLighting: boolean;
  55449. /**
  55450. * Disable lighting on the selection mesh (so it will always be visible)
  55451. */
  55452. disableSelectionMeshLighting: boolean;
  55453. /**
  55454. * Should the laser pointer be displayed
  55455. */
  55456. displayLaserPointer: boolean;
  55457. /**
  55458. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  55459. */
  55460. displaySelectionMesh: boolean;
  55461. /**
  55462. * This color will be set to the laser pointer when selection is triggered
  55463. */
  55464. laserPointerPickedColor: Color3;
  55465. /**
  55466. * Default color of the laser pointer
  55467. */
  55468. laserPointerDefaultColor: Color3;
  55469. /**
  55470. * default color of the selection ring
  55471. */
  55472. selectionMeshDefaultColor: Color3;
  55473. /**
  55474. * This color will be applied to the selection ring when selection is triggered
  55475. */
  55476. selectionMeshPickedColor: Color3;
  55477. /**
  55478. * Optional filter to be used for ray selection. This predicate shares behavior with
  55479. * scene.pointerMovePredicate which takes priority if it is also assigned.
  55480. */
  55481. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55482. /**
  55483. * constructs a new background remover module
  55484. * @param _xrSessionManager the session manager for this module
  55485. * @param _options read-only options to be used in this module
  55486. */
  55487. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  55488. /**
  55489. * attach this feature
  55490. * Will usually be called by the features manager
  55491. *
  55492. * @returns true if successful.
  55493. */
  55494. attach(): boolean;
  55495. /**
  55496. * detach this feature.
  55497. * Will usually be called by the features manager
  55498. *
  55499. * @returns true if successful.
  55500. */
  55501. detach(): boolean;
  55502. /**
  55503. * Will get the mesh under a specific pointer.
  55504. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  55505. * @param controllerId the controllerId to check
  55506. * @returns The mesh under pointer or null if no mesh is under the pointer
  55507. */
  55508. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  55509. /**
  55510. * Get the xr controller that correlates to the pointer id in the pointer event
  55511. *
  55512. * @param id the pointer id to search for
  55513. * @returns the controller that correlates to this id or null if not found
  55514. */
  55515. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  55516. private _identityMatrix;
  55517. private _screenCoordinatesRef;
  55518. private _viewportRef;
  55519. protected _onXRFrame(_xrFrame: XRFrame): void;
  55520. private _attachGazeMode;
  55521. private _attachScreenRayMode;
  55522. private _attachTrackedPointerRayMode;
  55523. private _convertNormalToDirectionOfRay;
  55524. private _detachController;
  55525. private _generateNewMeshPair;
  55526. private _pickingMoved;
  55527. private _updatePointerDistance;
  55528. /** @hidden */
  55529. get lasterPointerDefaultColor(): Color3;
  55530. }
  55531. }
  55532. declare module BABYLON {
  55533. /**
  55534. * Button which can be used to enter a different mode of XR
  55535. */
  55536. export class WebXREnterExitUIButton {
  55537. /** button element */
  55538. element: HTMLElement;
  55539. /** XR initialization options for the button */
  55540. sessionMode: XRSessionMode;
  55541. /** Reference space type */
  55542. referenceSpaceType: XRReferenceSpaceType;
  55543. /**
  55544. * Creates a WebXREnterExitUIButton
  55545. * @param element button element
  55546. * @param sessionMode XR initialization session mode
  55547. * @param referenceSpaceType the type of reference space to be used
  55548. */
  55549. constructor(
  55550. /** button element */
  55551. element: HTMLElement,
  55552. /** XR initialization options for the button */
  55553. sessionMode: XRSessionMode,
  55554. /** Reference space type */
  55555. referenceSpaceType: XRReferenceSpaceType);
  55556. /**
  55557. * Extendable function which can be used to update the button's visuals when the state changes
  55558. * @param activeButton the current active button in the UI
  55559. */
  55560. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  55561. }
  55562. /**
  55563. * Options to create the webXR UI
  55564. */
  55565. export class WebXREnterExitUIOptions {
  55566. /**
  55567. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  55568. */
  55569. customButtons?: Array<WebXREnterExitUIButton>;
  55570. /**
  55571. * A reference space type to use when creating the default button.
  55572. * Default is local-floor
  55573. */
  55574. referenceSpaceType?: XRReferenceSpaceType;
  55575. /**
  55576. * Context to enter xr with
  55577. */
  55578. renderTarget?: Nullable<WebXRRenderTarget>;
  55579. /**
  55580. * A session mode to use when creating the default button.
  55581. * Default is immersive-vr
  55582. */
  55583. sessionMode?: XRSessionMode;
  55584. /**
  55585. * A list of optional features to init the session with
  55586. */
  55587. optionalFeatures?: string[];
  55588. /**
  55589. * A list of optional features to init the session with
  55590. */
  55591. requiredFeatures?: string[];
  55592. /**
  55593. * If defined, this function will be executed if the UI encounters an error when entering XR
  55594. */
  55595. onError?: (error: any) => void;
  55596. }
  55597. /**
  55598. * UI to allow the user to enter/exit XR mode
  55599. */
  55600. export class WebXREnterExitUI implements IDisposable {
  55601. private scene;
  55602. /** version of the options passed to this UI */
  55603. options: WebXREnterExitUIOptions;
  55604. private _activeButton;
  55605. private _buttons;
  55606. /**
  55607. * The HTML Div Element to which buttons are added.
  55608. */
  55609. readonly overlay: HTMLDivElement;
  55610. /**
  55611. * Fired every time the active button is changed.
  55612. *
  55613. * When xr is entered via a button that launches xr that button will be the callback parameter
  55614. *
  55615. * When exiting xr the callback parameter will be null)
  55616. */
  55617. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  55618. /**
  55619. *
  55620. * @param scene babylon scene object to use
  55621. * @param options (read-only) version of the options passed to this UI
  55622. */
  55623. private constructor();
  55624. /**
  55625. * Creates UI to allow the user to enter/exit XR mode
  55626. * @param scene the scene to add the ui to
  55627. * @param helper the xr experience helper to enter/exit xr with
  55628. * @param options options to configure the UI
  55629. * @returns the created ui
  55630. */
  55631. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  55632. /**
  55633. * Disposes of the XR UI component
  55634. */
  55635. dispose(): void;
  55636. private _updateButtons;
  55637. }
  55638. }
  55639. declare module BABYLON {
  55640. /**
  55641. * Class containing static functions to help procedurally build meshes
  55642. */
  55643. export class LinesBuilder {
  55644. /**
  55645. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  55646. * * 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
  55647. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  55648. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  55649. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  55650. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  55651. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55652. * * 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
  55653. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  55654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55655. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  55656. * @param name defines the name of the new line system
  55657. * @param options defines the options used to create the line system
  55658. * @param scene defines the hosting scene
  55659. * @returns a new line system mesh
  55660. */
  55661. static CreateLineSystem(name: string, options: {
  55662. lines: Vector3[][];
  55663. updatable?: boolean;
  55664. instance?: Nullable<LinesMesh>;
  55665. colors?: Nullable<Color4[][]>;
  55666. useVertexAlpha?: boolean;
  55667. }, scene: Nullable<Scene>): LinesMesh;
  55668. /**
  55669. * Creates a line mesh
  55670. * 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
  55671. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55672. * * The parameter `points` is an array successive Vector3
  55673. * * 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
  55674. * * The optional parameter `colors` is an array of successive Color4, one per line point
  55675. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  55676. * * When updating an instance, remember that only point positions can change, not the number of points
  55677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55678. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  55679. * @param name defines the name of the new line system
  55680. * @param options defines the options used to create the line system
  55681. * @param scene defines the hosting scene
  55682. * @returns a new line mesh
  55683. */
  55684. static CreateLines(name: string, options: {
  55685. points: Vector3[];
  55686. updatable?: boolean;
  55687. instance?: Nullable<LinesMesh>;
  55688. colors?: Color4[];
  55689. useVertexAlpha?: boolean;
  55690. }, scene?: Nullable<Scene>): LinesMesh;
  55691. /**
  55692. * Creates a dashed line mesh
  55693. * * 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
  55694. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  55695. * * The parameter `points` is an array successive Vector3
  55696. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55697. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55698. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55699. * * 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
  55700. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  55701. * * When updating an instance, remember that only point positions can change, not the number of points
  55702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55703. * @param name defines the name of the mesh
  55704. * @param options defines the options used to create the mesh
  55705. * @param scene defines the hosting scene
  55706. * @returns the dashed line mesh
  55707. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55708. */
  55709. static CreateDashedLines(name: string, options: {
  55710. points: Vector3[];
  55711. dashSize?: number;
  55712. gapSize?: number;
  55713. dashNb?: number;
  55714. updatable?: boolean;
  55715. instance?: LinesMesh;
  55716. useVertexAlpha?: boolean;
  55717. }, scene?: Nullable<Scene>): LinesMesh;
  55718. }
  55719. }
  55720. declare module BABYLON {
  55721. /**
  55722. * Construction options for a timer
  55723. */
  55724. export interface ITimerOptions<T> {
  55725. /**
  55726. * Time-to-end
  55727. */
  55728. timeout: number;
  55729. /**
  55730. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  55731. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  55732. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  55733. */
  55734. contextObservable: Observable<T>;
  55735. /**
  55736. * Optional parameters when adding an observer to the observable
  55737. */
  55738. observableParameters?: {
  55739. mask?: number;
  55740. insertFirst?: boolean;
  55741. scope?: any;
  55742. };
  55743. /**
  55744. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  55745. */
  55746. breakCondition?: (data?: ITimerData<T>) => boolean;
  55747. /**
  55748. * Will be triggered when the time condition has met
  55749. */
  55750. onEnded?: (data: ITimerData<any>) => void;
  55751. /**
  55752. * Will be triggered when the break condition has met (prematurely ended)
  55753. */
  55754. onAborted?: (data: ITimerData<any>) => void;
  55755. /**
  55756. * Optional function to execute on each tick (or count)
  55757. */
  55758. onTick?: (data: ITimerData<any>) => void;
  55759. }
  55760. /**
  55761. * An interface defining the data sent by the timer
  55762. */
  55763. export interface ITimerData<T> {
  55764. /**
  55765. * When did it start
  55766. */
  55767. startTime: number;
  55768. /**
  55769. * Time now
  55770. */
  55771. currentTime: number;
  55772. /**
  55773. * Time passed since started
  55774. */
  55775. deltaTime: number;
  55776. /**
  55777. * How much is completed, in [0.0...1.0].
  55778. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  55779. */
  55780. completeRate: number;
  55781. /**
  55782. * What the registered observable sent in the last count
  55783. */
  55784. payload: T;
  55785. }
  55786. /**
  55787. * The current state of the timer
  55788. */
  55789. export enum TimerState {
  55790. /**
  55791. * Timer initialized, not yet started
  55792. */
  55793. INIT = 0,
  55794. /**
  55795. * Timer started and counting
  55796. */
  55797. STARTED = 1,
  55798. /**
  55799. * Timer ended (whether aborted or time reached)
  55800. */
  55801. ENDED = 2
  55802. }
  55803. /**
  55804. * A simple version of the timer. Will take options and start the timer immediately after calling it
  55805. *
  55806. * @param options options with which to initialize this timer
  55807. */
  55808. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  55809. /**
  55810. * An advanced implementation of a timer class
  55811. */
  55812. export class AdvancedTimer<T = any> implements IDisposable {
  55813. /**
  55814. * Will notify each time the timer calculates the remaining time
  55815. */
  55816. onEachCountObservable: Observable<ITimerData<T>>;
  55817. /**
  55818. * Will trigger when the timer was aborted due to the break condition
  55819. */
  55820. onTimerAbortedObservable: Observable<ITimerData<T>>;
  55821. /**
  55822. * Will trigger when the timer ended successfully
  55823. */
  55824. onTimerEndedObservable: Observable<ITimerData<T>>;
  55825. /**
  55826. * Will trigger when the timer state has changed
  55827. */
  55828. onStateChangedObservable: Observable<TimerState>;
  55829. private _observer;
  55830. private _contextObservable;
  55831. private _observableParameters;
  55832. private _startTime;
  55833. private _timer;
  55834. private _state;
  55835. private _breakCondition;
  55836. private _timeToEnd;
  55837. private _breakOnNextTick;
  55838. /**
  55839. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  55840. * @param options construction options for this advanced timer
  55841. */
  55842. constructor(options: ITimerOptions<T>);
  55843. /**
  55844. * set a breaking condition for this timer. Default is to never break during count
  55845. * @param predicate the new break condition. Returns true to break, false otherwise
  55846. */
  55847. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  55848. /**
  55849. * Reset ALL associated observables in this advanced timer
  55850. */
  55851. clearObservables(): void;
  55852. /**
  55853. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  55854. *
  55855. * @param timeToEnd how much time to measure until timer ended
  55856. */
  55857. start(timeToEnd?: number): void;
  55858. /**
  55859. * Will force a stop on the next tick.
  55860. */
  55861. stop(): void;
  55862. /**
  55863. * Dispose this timer, clearing all resources
  55864. */
  55865. dispose(): void;
  55866. private _setState;
  55867. private _tick;
  55868. private _stop;
  55869. }
  55870. }
  55871. declare module BABYLON {
  55872. /**
  55873. * The options container for the teleportation module
  55874. */
  55875. export interface IWebXRTeleportationOptions {
  55876. /**
  55877. * if provided, this scene will be used to render meshes.
  55878. */
  55879. customUtilityLayerScene?: Scene;
  55880. /**
  55881. * Values to configure the default target mesh
  55882. */
  55883. defaultTargetMeshOptions?: {
  55884. /**
  55885. * Fill color of the teleportation area
  55886. */
  55887. teleportationFillColor?: string;
  55888. /**
  55889. * Border color for the teleportation area
  55890. */
  55891. teleportationBorderColor?: string;
  55892. /**
  55893. * Disable the mesh's animation sequence
  55894. */
  55895. disableAnimation?: boolean;
  55896. /**
  55897. * Disable lighting on the material or the ring and arrow
  55898. */
  55899. disableLighting?: boolean;
  55900. /**
  55901. * Override the default material of the torus and arrow
  55902. */
  55903. torusArrowMaterial?: Material;
  55904. };
  55905. /**
  55906. * A list of meshes to use as floor meshes.
  55907. * Meshes can be added and removed after initializing the feature using the
  55908. * addFloorMesh and removeFloorMesh functions
  55909. * If empty, rotation will still work
  55910. */
  55911. floorMeshes?: AbstractMesh[];
  55912. /**
  55913. * use this rendering group id for the meshes (optional)
  55914. */
  55915. renderingGroupId?: number;
  55916. /**
  55917. * Should teleportation move only to snap points
  55918. */
  55919. snapPointsOnly?: boolean;
  55920. /**
  55921. * An array of points to which the teleportation will snap to.
  55922. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  55923. */
  55924. snapPositions?: Vector3[];
  55925. /**
  55926. * How close should the teleportation ray be in order to snap to position.
  55927. * Default to 0.8 units (meters)
  55928. */
  55929. snapToPositionRadius?: number;
  55930. /**
  55931. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  55932. * If you want to support rotation, make sure your mesh has a direction indicator.
  55933. *
  55934. * When left untouched, the default mesh will be initialized.
  55935. */
  55936. teleportationTargetMesh?: AbstractMesh;
  55937. /**
  55938. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  55939. */
  55940. timeToTeleport?: number;
  55941. /**
  55942. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  55943. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  55944. */
  55945. useMainComponentOnly?: boolean;
  55946. /**
  55947. * Should meshes created here be added to a utility layer or the main scene
  55948. */
  55949. useUtilityLayer?: boolean;
  55950. /**
  55951. * Babylon XR Input class for controller
  55952. */
  55953. xrInput: WebXRInput;
  55954. /**
  55955. * Meshes that the teleportation ray cannot go through
  55956. */
  55957. pickBlockerMeshes?: AbstractMesh[];
  55958. /**
  55959. * Should teleport work only on a specific hand?
  55960. */
  55961. forceHandedness?: XRHandedness;
  55962. /**
  55963. * If provided, this function will be used to generate the ray mesh instead of the lines mesh being used per default
  55964. */
  55965. generateRayPathMesh?: (points: Vector3[]) => AbstractMesh;
  55966. }
  55967. /**
  55968. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  55969. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  55970. * the input of the attached controllers.
  55971. */
  55972. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  55973. private _options;
  55974. private _controllers;
  55975. private _currentTeleportationControllerId;
  55976. private _floorMeshes;
  55977. private _quadraticBezierCurve;
  55978. private _selectionFeature;
  55979. private _snapToPositions;
  55980. private _snappedToPoint;
  55981. private _teleportationRingMaterial?;
  55982. private _tmpRay;
  55983. private _tmpVector;
  55984. private _tmpQuaternion;
  55985. /**
  55986. * The module's name
  55987. */
  55988. static readonly Name: string;
  55989. /**
  55990. * The (Babylon) version of this module.
  55991. * This is an integer representing the implementation version.
  55992. * This number does not correspond to the webxr specs version
  55993. */
  55994. static readonly Version: number;
  55995. /**
  55996. * Is movement backwards enabled
  55997. */
  55998. backwardsMovementEnabled: boolean;
  55999. /**
  56000. * Distance to travel when moving backwards
  56001. */
  56002. backwardsTeleportationDistance: number;
  56003. /**
  56004. * The distance from the user to the inspection point in the direction of the controller
  56005. * A higher number will allow the user to move further
  56006. * defaults to 5 (meters, in xr units)
  56007. */
  56008. parabolicCheckRadius: number;
  56009. /**
  56010. * Should the module support parabolic ray on top of direct ray
  56011. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  56012. * Very helpful when moving between floors / different heights
  56013. */
  56014. parabolicRayEnabled: boolean;
  56015. /**
  56016. * The second type of ray - straight line.
  56017. * Should it be enabled or should the parabolic line be the only one.
  56018. */
  56019. straightRayEnabled: boolean;
  56020. /**
  56021. * How much rotation should be applied when rotating right and left
  56022. */
  56023. rotationAngle: number;
  56024. private _rotationEnabled;
  56025. /**
  56026. * Is rotation enabled when moving forward?
  56027. * Disabling this feature will prevent the user from deciding the direction when teleporting
  56028. */
  56029. get rotationEnabled(): boolean;
  56030. /**
  56031. * Sets wether rotation is enabled or not
  56032. * @param enabled is rotation enabled when teleportation is shown
  56033. */
  56034. set rotationEnabled(enabled: boolean);
  56035. /**
  56036. * Exposes the currently set teleportation target mesh.
  56037. */
  56038. get teleportationTargetMesh(): Nullable<AbstractMesh>;
  56039. /**
  56040. * constructs a new anchor system
  56041. * @param _xrSessionManager an instance of WebXRSessionManager
  56042. * @param _options configuration object for this feature
  56043. */
  56044. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  56045. /**
  56046. * Get the snapPointsOnly flag
  56047. */
  56048. get snapPointsOnly(): boolean;
  56049. /**
  56050. * Sets the snapPointsOnly flag
  56051. * @param snapToPoints should teleportation be exclusively to snap points
  56052. */
  56053. set snapPointsOnly(snapToPoints: boolean);
  56054. /**
  56055. * Add a new mesh to the floor meshes array
  56056. * @param mesh the mesh to use as floor mesh
  56057. */
  56058. addFloorMesh(mesh: AbstractMesh): void;
  56059. /**
  56060. * Add a new snap-to point to fix teleportation to this position
  56061. * @param newSnapPoint The new Snap-To point
  56062. */
  56063. addSnapPoint(newSnapPoint: Vector3): void;
  56064. attach(): boolean;
  56065. detach(): boolean;
  56066. dispose(): void;
  56067. /**
  56068. * Remove a mesh from the floor meshes array
  56069. * @param mesh the mesh to remove
  56070. */
  56071. removeFloorMesh(mesh: AbstractMesh): void;
  56072. /**
  56073. * Remove a mesh from the floor meshes array using its name
  56074. * @param name the mesh name to remove
  56075. */
  56076. removeFloorMeshByName(name: string): void;
  56077. /**
  56078. * 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
  56079. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  56080. * @returns was the point found and removed or not
  56081. */
  56082. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  56083. /**
  56084. * This function sets a selection feature that will be disabled when
  56085. * the forward ray is shown and will be reattached when hidden.
  56086. * This is used to remove the selection rays when moving.
  56087. * @param selectionFeature the feature to disable when forward movement is enabled
  56088. */
  56089. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  56090. protected _onXRFrame(_xrFrame: XRFrame): void;
  56091. private _attachController;
  56092. private _createDefaultTargetMesh;
  56093. private _detachController;
  56094. private _findClosestSnapPointWithRadius;
  56095. private _setTargetMeshPosition;
  56096. private _setTargetMeshVisibility;
  56097. private _showParabolicPath;
  56098. private _teleportForward;
  56099. }
  56100. }
  56101. declare module BABYLON {
  56102. /**
  56103. * Options for the default xr helper
  56104. */
  56105. export class WebXRDefaultExperienceOptions {
  56106. /**
  56107. * Enable or disable default UI to enter XR
  56108. */
  56109. disableDefaultUI?: boolean;
  56110. /**
  56111. * Should teleportation not initialize. defaults to false.
  56112. */
  56113. disableTeleportation?: boolean;
  56114. /**
  56115. * Floor meshes that will be used for teleport
  56116. */
  56117. floorMeshes?: Array<AbstractMesh>;
  56118. /**
  56119. * If set to true, the first frame will not be used to reset position
  56120. * The first frame is mainly used when copying transformation from the old camera
  56121. * Mainly used in AR
  56122. */
  56123. ignoreNativeCameraTransformation?: boolean;
  56124. /**
  56125. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  56126. */
  56127. inputOptions?: IWebXRInputOptions;
  56128. /**
  56129. * optional configuration for the output canvas
  56130. */
  56131. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  56132. /**
  56133. * optional UI options. This can be used among other to change session mode and reference space type
  56134. */
  56135. uiOptions?: WebXREnterExitUIOptions;
  56136. /**
  56137. * When loading teleportation and pointer select, use stable versions instead of latest.
  56138. */
  56139. useStablePlugins?: boolean;
  56140. /**
  56141. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  56142. */
  56143. renderingGroupId?: number;
  56144. /**
  56145. * A list of optional features to init the session with
  56146. * If set to true, all features we support will be added
  56147. */
  56148. optionalFeatures?: boolean | string[];
  56149. }
  56150. /**
  56151. * Default experience which provides a similar setup to the previous webVRExperience
  56152. */
  56153. export class WebXRDefaultExperience {
  56154. /**
  56155. * Base experience
  56156. */
  56157. baseExperience: WebXRExperienceHelper;
  56158. /**
  56159. * Enables ui for entering/exiting xr
  56160. */
  56161. enterExitUI: WebXREnterExitUI;
  56162. /**
  56163. * Input experience extension
  56164. */
  56165. input: WebXRInput;
  56166. /**
  56167. * Enables laser pointer and selection
  56168. */
  56169. pointerSelection: WebXRControllerPointerSelection;
  56170. /**
  56171. * Default target xr should render to
  56172. */
  56173. renderTarget: WebXRRenderTarget;
  56174. /**
  56175. * Enables teleportation
  56176. */
  56177. teleportation: WebXRMotionControllerTeleportation;
  56178. private constructor();
  56179. /**
  56180. * Creates the default xr experience
  56181. * @param scene scene
  56182. * @param options options for basic configuration
  56183. * @returns resulting WebXRDefaultExperience
  56184. */
  56185. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  56186. /**
  56187. * DIsposes of the experience helper
  56188. */
  56189. dispose(): void;
  56190. }
  56191. }
  56192. declare module BABYLON {
  56193. /**
  56194. * Options to modify the vr teleportation behavior.
  56195. */
  56196. export interface VRTeleportationOptions {
  56197. /**
  56198. * The name of the mesh which should be used as the teleportation floor. (default: null)
  56199. */
  56200. floorMeshName?: string;
  56201. /**
  56202. * A list of meshes to be used as the teleportation floor. (default: empty)
  56203. */
  56204. floorMeshes?: Mesh[];
  56205. /**
  56206. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  56207. */
  56208. teleportationMode?: number;
  56209. /**
  56210. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  56211. */
  56212. teleportationTime?: number;
  56213. /**
  56214. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  56215. */
  56216. teleportationSpeed?: number;
  56217. /**
  56218. * The easing function used in the animation or null for Linear. (default CircleEase)
  56219. */
  56220. easingFunction?: EasingFunction;
  56221. }
  56222. /**
  56223. * Options to modify the vr experience helper's behavior.
  56224. */
  56225. export interface VRExperienceHelperOptions extends WebVROptions {
  56226. /**
  56227. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  56228. */
  56229. createDeviceOrientationCamera?: boolean;
  56230. /**
  56231. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  56232. */
  56233. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  56234. /**
  56235. * Uses the main button on the controller to toggle the laser casted. (default: true)
  56236. */
  56237. laserToggle?: boolean;
  56238. /**
  56239. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  56240. */
  56241. floorMeshes?: Mesh[];
  56242. /**
  56243. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  56244. */
  56245. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  56246. /**
  56247. * Defines if WebXR should be used instead of WebVR (if available)
  56248. */
  56249. useXR?: boolean;
  56250. }
  56251. /**
  56252. * Event containing information after VR has been entered
  56253. */
  56254. export class OnAfterEnteringVRObservableEvent {
  56255. /**
  56256. * If entering vr was successful
  56257. */
  56258. success: boolean;
  56259. }
  56260. /**
  56261. * Helps to quickly add VR support to an existing scene.
  56262. * See https://doc.babylonjs.com/how_to/webvr_helper
  56263. */
  56264. export class VRExperienceHelper {
  56265. /** Options to modify the vr experience helper's behavior. */
  56266. webVROptions: VRExperienceHelperOptions;
  56267. private _scene;
  56268. private _position;
  56269. private _btnVR;
  56270. private _btnVRDisplayed;
  56271. private _webVRsupported;
  56272. private _webVRready;
  56273. private _webVRrequesting;
  56274. private _webVRpresenting;
  56275. private _hasEnteredVR;
  56276. private _fullscreenVRpresenting;
  56277. private _inputElement;
  56278. private _webVRCamera;
  56279. private _vrDeviceOrientationCamera;
  56280. private _deviceOrientationCamera;
  56281. private _existingCamera;
  56282. private _onKeyDown;
  56283. private _onVrDisplayPresentChange;
  56284. private _onVRDisplayChanged;
  56285. private _onVRRequestPresentStart;
  56286. private _onVRRequestPresentComplete;
  56287. /**
  56288. * 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)
  56289. */
  56290. enableGazeEvenWhenNoPointerLock: boolean;
  56291. /**
  56292. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  56293. */
  56294. exitVROnDoubleTap: boolean;
  56295. /**
  56296. * Observable raised right before entering VR.
  56297. */
  56298. onEnteringVRObservable: Observable<VRExperienceHelper>;
  56299. /**
  56300. * Observable raised when entering VR has completed.
  56301. */
  56302. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  56303. /**
  56304. * Observable raised when exiting VR.
  56305. */
  56306. onExitingVRObservable: Observable<VRExperienceHelper>;
  56307. /**
  56308. * Observable raised when controller mesh is loaded.
  56309. */
  56310. onControllerMeshLoadedObservable: Observable<WebVRController>;
  56311. /** Return this.onEnteringVRObservable
  56312. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  56313. */
  56314. get onEnteringVR(): Observable<VRExperienceHelper>;
  56315. /** Return this.onExitingVRObservable
  56316. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  56317. */
  56318. get onExitingVR(): Observable<VRExperienceHelper>;
  56319. /** Return this.onControllerMeshLoadedObservable
  56320. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  56321. */
  56322. get onControllerMeshLoaded(): Observable<WebVRController>;
  56323. private _rayLength;
  56324. private _useCustomVRButton;
  56325. private _teleportationRequested;
  56326. private _teleportActive;
  56327. private _floorMeshName;
  56328. private _floorMeshesCollection;
  56329. private _teleportationMode;
  56330. private _teleportationTime;
  56331. private _teleportationSpeed;
  56332. private _teleportationEasing;
  56333. private _rotationAllowed;
  56334. private _teleportBackwardsVector;
  56335. private _teleportationTarget;
  56336. private _isDefaultTeleportationTarget;
  56337. private _postProcessMove;
  56338. private _teleportationFillColor;
  56339. private _teleportationBorderColor;
  56340. private _rotationAngle;
  56341. private _haloCenter;
  56342. private _cameraGazer;
  56343. private _padSensibilityUp;
  56344. private _padSensibilityDown;
  56345. private _leftController;
  56346. private _rightController;
  56347. private _gazeColor;
  56348. private _laserColor;
  56349. private _pickedLaserColor;
  56350. private _pickedGazeColor;
  56351. /**
  56352. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  56353. */
  56354. onNewMeshSelected: Observable<AbstractMesh>;
  56355. /**
  56356. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  56357. * This observable will provide the mesh and the controller used to select the mesh
  56358. */
  56359. onMeshSelectedWithController: Observable<{
  56360. mesh: AbstractMesh;
  56361. controller: WebVRController;
  56362. }>;
  56363. /**
  56364. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  56365. */
  56366. onNewMeshPicked: Observable<PickingInfo>;
  56367. private _circleEase;
  56368. /**
  56369. * Observable raised before camera teleportation
  56370. */
  56371. onBeforeCameraTeleport: Observable<Vector3>;
  56372. /**
  56373. * Observable raised after camera teleportation
  56374. */
  56375. onAfterCameraTeleport: Observable<Vector3>;
  56376. /**
  56377. * Observable raised when current selected mesh gets unselected
  56378. */
  56379. onSelectedMeshUnselected: Observable<AbstractMesh>;
  56380. private _raySelectionPredicate;
  56381. /**
  56382. * To be optionaly changed by user to define custom ray selection
  56383. */
  56384. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  56385. /**
  56386. * To be optionaly changed by user to define custom selection logic (after ray selection)
  56387. */
  56388. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56389. /**
  56390. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  56391. */
  56392. teleportationEnabled: boolean;
  56393. private _defaultHeight;
  56394. private _teleportationInitialized;
  56395. private _interactionsEnabled;
  56396. private _interactionsRequested;
  56397. private _displayGaze;
  56398. private _displayLaserPointer;
  56399. /**
  56400. * The mesh used to display where the user is going to teleport.
  56401. */
  56402. get teleportationTarget(): Mesh;
  56403. /**
  56404. * Sets the mesh to be used to display where the user is going to teleport.
  56405. */
  56406. set teleportationTarget(value: Mesh);
  56407. /**
  56408. * 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
  56409. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  56410. * See https://doc.babylonjs.com/resources/baking_transformations
  56411. */
  56412. get gazeTrackerMesh(): Mesh;
  56413. set gazeTrackerMesh(value: Mesh);
  56414. /**
  56415. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  56416. */
  56417. updateGazeTrackerScale: boolean;
  56418. /**
  56419. * If the gaze trackers color should be updated when selecting meshes
  56420. */
  56421. updateGazeTrackerColor: boolean;
  56422. /**
  56423. * If the controller laser color should be updated when selecting meshes
  56424. */
  56425. updateControllerLaserColor: boolean;
  56426. /**
  56427. * The gaze tracking mesh corresponding to the left controller
  56428. */
  56429. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  56430. /**
  56431. * The gaze tracking mesh corresponding to the right controller
  56432. */
  56433. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  56434. /**
  56435. * If the ray of the gaze should be displayed.
  56436. */
  56437. get displayGaze(): boolean;
  56438. /**
  56439. * Sets if the ray of the gaze should be displayed.
  56440. */
  56441. set displayGaze(value: boolean);
  56442. /**
  56443. * If the ray of the LaserPointer should be displayed.
  56444. */
  56445. get displayLaserPointer(): boolean;
  56446. /**
  56447. * Sets if the ray of the LaserPointer should be displayed.
  56448. */
  56449. set displayLaserPointer(value: boolean);
  56450. /**
  56451. * The deviceOrientationCamera used as the camera when not in VR.
  56452. */
  56453. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  56454. /**
  56455. * Based on the current WebVR support, returns the current VR camera used.
  56456. */
  56457. get currentVRCamera(): Nullable<Camera>;
  56458. /**
  56459. * The webVRCamera which is used when in VR.
  56460. */
  56461. get webVRCamera(): WebVRFreeCamera;
  56462. /**
  56463. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  56464. */
  56465. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  56466. /**
  56467. * The html button that is used to trigger entering into VR.
  56468. */
  56469. get vrButton(): Nullable<HTMLButtonElement>;
  56470. private get _teleportationRequestInitiated();
  56471. /**
  56472. * Defines whether or not Pointer lock should be requested when switching to
  56473. * full screen.
  56474. */
  56475. requestPointerLockOnFullScreen: boolean;
  56476. /**
  56477. * If asking to force XR, this will be populated with the default xr experience
  56478. */
  56479. xr: WebXRDefaultExperience;
  56480. /**
  56481. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  56482. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  56483. */
  56484. xrTestDone: boolean;
  56485. /**
  56486. * Instantiates a VRExperienceHelper.
  56487. * Helps to quickly add VR support to an existing scene.
  56488. * @param scene The scene the VRExperienceHelper belongs to.
  56489. * @param webVROptions Options to modify the vr experience helper's behavior.
  56490. */
  56491. constructor(scene: Scene,
  56492. /** Options to modify the vr experience helper's behavior. */
  56493. webVROptions?: VRExperienceHelperOptions);
  56494. private completeVRInit;
  56495. private _onDefaultMeshLoaded;
  56496. private _onResize;
  56497. private _onFullscreenChange;
  56498. /**
  56499. * Gets a value indicating if we are currently in VR mode.
  56500. */
  56501. get isInVRMode(): boolean;
  56502. private onVrDisplayPresentChange;
  56503. private onVRDisplayChanged;
  56504. private moveButtonToBottomRight;
  56505. private displayVRButton;
  56506. private updateButtonVisibility;
  56507. private _cachedAngularSensibility;
  56508. /**
  56509. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  56510. * Otherwise, will use the fullscreen API.
  56511. */
  56512. enterVR(): void;
  56513. /**
  56514. * Attempt to exit VR, or fullscreen.
  56515. */
  56516. exitVR(): void;
  56517. /**
  56518. * The position of the vr experience helper.
  56519. */
  56520. get position(): Vector3;
  56521. /**
  56522. * Sets the position of the vr experience helper.
  56523. */
  56524. set position(value: Vector3);
  56525. /**
  56526. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  56527. */
  56528. enableInteractions(): void;
  56529. private get _noControllerIsActive();
  56530. private beforeRender;
  56531. private _isTeleportationFloor;
  56532. /**
  56533. * Adds a floor mesh to be used for teleportation.
  56534. * @param floorMesh the mesh to be used for teleportation.
  56535. */
  56536. addFloorMesh(floorMesh: Mesh): void;
  56537. /**
  56538. * Removes a floor mesh from being used for teleportation.
  56539. * @param floorMesh the mesh to be removed.
  56540. */
  56541. removeFloorMesh(floorMesh: Mesh): void;
  56542. /**
  56543. * Enables interactions and teleportation using the VR controllers and gaze.
  56544. * @param vrTeleportationOptions options to modify teleportation behavior.
  56545. */
  56546. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  56547. private _onNewGamepadConnected;
  56548. private _tryEnableInteractionOnController;
  56549. private _onNewGamepadDisconnected;
  56550. private _enableInteractionOnController;
  56551. private _checkTeleportWithRay;
  56552. private _checkRotate;
  56553. private _checkTeleportBackwards;
  56554. private _enableTeleportationOnController;
  56555. private _createTeleportationCircles;
  56556. private _displayTeleportationTarget;
  56557. private _hideTeleportationTarget;
  56558. private _rotateCamera;
  56559. private _moveTeleportationSelectorTo;
  56560. private _workingVector;
  56561. private _workingQuaternion;
  56562. private _workingMatrix;
  56563. /**
  56564. * Time Constant Teleportation Mode
  56565. */
  56566. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  56567. /**
  56568. * Speed Constant Teleportation Mode
  56569. */
  56570. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  56571. /**
  56572. * Teleports the users feet to the desired location
  56573. * @param location The location where the user's feet should be placed
  56574. */
  56575. teleportCamera(location: Vector3): void;
  56576. private _convertNormalToDirectionOfRay;
  56577. private _castRayAndSelectObject;
  56578. private _notifySelectedMeshUnselected;
  56579. /**
  56580. * Permanently set new colors for the laser pointer
  56581. * @param color the new laser color
  56582. * @param pickedColor the new laser color when picked mesh detected
  56583. */
  56584. setLaserColor(color: Color3, pickedColor?: Color3): void;
  56585. /**
  56586. * Set lighting enabled / disabled on the laser pointer of both controllers
  56587. * @param enabled should the lighting be enabled on the laser pointer
  56588. */
  56589. setLaserLightingState(enabled?: boolean): void;
  56590. /**
  56591. * Permanently set new colors for the gaze pointer
  56592. * @param color the new gaze color
  56593. * @param pickedColor the new gaze color when picked mesh detected
  56594. */
  56595. setGazeColor(color: Color3, pickedColor?: Color3): void;
  56596. /**
  56597. * Sets the color of the laser ray from the vr controllers.
  56598. * @param color new color for the ray.
  56599. */
  56600. changeLaserColor(color: Color3): void;
  56601. /**
  56602. * Sets the color of the ray from the vr headsets gaze.
  56603. * @param color new color for the ray.
  56604. */
  56605. changeGazeColor(color: Color3): void;
  56606. /**
  56607. * Exits VR and disposes of the vr experience helper
  56608. */
  56609. dispose(): void;
  56610. /**
  56611. * Gets the name of the VRExperienceHelper class
  56612. * @returns "VRExperienceHelper"
  56613. */
  56614. getClassName(): string;
  56615. }
  56616. }
  56617. declare module BABYLON {
  56618. /**
  56619. * Contains an array of blocks representing the octree
  56620. */
  56621. export interface IOctreeContainer<T> {
  56622. /**
  56623. * Blocks within the octree
  56624. */
  56625. blocks: Array<OctreeBlock<T>>;
  56626. }
  56627. /**
  56628. * Class used to store a cell in an octree
  56629. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56630. */
  56631. export class OctreeBlock<T> {
  56632. /**
  56633. * Gets the content of the current block
  56634. */
  56635. entries: T[];
  56636. /**
  56637. * Gets the list of block children
  56638. */
  56639. blocks: Array<OctreeBlock<T>>;
  56640. private _depth;
  56641. private _maxDepth;
  56642. private _capacity;
  56643. private _minPoint;
  56644. private _maxPoint;
  56645. private _boundingVectors;
  56646. private _creationFunc;
  56647. /**
  56648. * Creates a new block
  56649. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  56650. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  56651. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56652. * @param depth defines the current depth of this block in the octree
  56653. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  56654. * @param creationFunc defines a callback to call when an element is added to the block
  56655. */
  56656. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  56657. /**
  56658. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  56659. */
  56660. get capacity(): number;
  56661. /**
  56662. * Gets the minimum vector (in world space) of the block's bounding box
  56663. */
  56664. get minPoint(): Vector3;
  56665. /**
  56666. * Gets the maximum vector (in world space) of the block's bounding box
  56667. */
  56668. get maxPoint(): Vector3;
  56669. /**
  56670. * Add a new element to this block
  56671. * @param entry defines the element to add
  56672. */
  56673. addEntry(entry: T): void;
  56674. /**
  56675. * Remove an element from this block
  56676. * @param entry defines the element to remove
  56677. */
  56678. removeEntry(entry: T): void;
  56679. /**
  56680. * Add an array of elements to this block
  56681. * @param entries defines the array of elements to add
  56682. */
  56683. addEntries(entries: T[]): void;
  56684. /**
  56685. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  56686. * @param frustumPlanes defines the frustum planes to test
  56687. * @param selection defines the array to store current content if selection is positive
  56688. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56689. */
  56690. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56691. /**
  56692. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  56693. * @param sphereCenter defines the bounding sphere center
  56694. * @param sphereRadius defines the bounding sphere radius
  56695. * @param selection defines the array to store current content if selection is positive
  56696. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56697. */
  56698. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  56699. /**
  56700. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  56701. * @param ray defines the ray to test with
  56702. * @param selection defines the array to store current content if selection is positive
  56703. */
  56704. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  56705. /**
  56706. * Subdivide the content into child blocks (this block will then be empty)
  56707. */
  56708. createInnerBlocks(): void;
  56709. /**
  56710. * @hidden
  56711. */
  56712. 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;
  56713. }
  56714. }
  56715. declare module BABYLON {
  56716. /**
  56717. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  56718. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56719. */
  56720. export class Octree<T> {
  56721. /** 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.) */
  56722. maxDepth: number;
  56723. /**
  56724. * Blocks within the octree containing objects
  56725. */
  56726. blocks: Array<OctreeBlock<T>>;
  56727. /**
  56728. * Content stored in the octree
  56729. */
  56730. dynamicContent: T[];
  56731. private _maxBlockCapacity;
  56732. private _selectionContent;
  56733. private _creationFunc;
  56734. /**
  56735. * Creates a octree
  56736. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56737. * @param creationFunc function to be used to instatiate the octree
  56738. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  56739. * @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.)
  56740. */
  56741. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  56742. /** 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.) */
  56743. maxDepth?: number);
  56744. /**
  56745. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  56746. * @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);
  56747. * @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);
  56748. * @param entries meshes to be added to the octree blocks
  56749. */
  56750. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  56751. /**
  56752. * Adds a mesh to the octree
  56753. * @param entry Mesh to add to the octree
  56754. */
  56755. addMesh(entry: T): void;
  56756. /**
  56757. * Remove an element from the octree
  56758. * @param entry defines the element to remove
  56759. */
  56760. removeMesh(entry: T): void;
  56761. /**
  56762. * Selects an array of meshes within the frustum
  56763. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  56764. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  56765. * @returns array of meshes within the frustum
  56766. */
  56767. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  56768. /**
  56769. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  56770. * @param sphereCenter defines the bounding sphere center
  56771. * @param sphereRadius defines the bounding sphere radius
  56772. * @param allowDuplicate defines if the selection array can contains duplicated entries
  56773. * @returns an array of objects that intersect the sphere
  56774. */
  56775. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  56776. /**
  56777. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  56778. * @param ray defines the ray to test with
  56779. * @returns array of intersected objects
  56780. */
  56781. intersectsRay(ray: Ray): SmartArray<T>;
  56782. /**
  56783. * Adds a mesh into the octree block if it intersects the block
  56784. */
  56785. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  56786. /**
  56787. * Adds a submesh into the octree block if it intersects the block
  56788. */
  56789. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. interface Scene {
  56794. /**
  56795. * @hidden
  56796. * Backing Filed
  56797. */
  56798. _selectionOctree: Octree<AbstractMesh>;
  56799. /**
  56800. * Gets the octree used to boost mesh selection (picking)
  56801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56802. */
  56803. selectionOctree: Octree<AbstractMesh>;
  56804. /**
  56805. * Creates or updates the octree used to boost selection (picking)
  56806. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56807. * @param maxCapacity defines the maximum capacity per leaf
  56808. * @param maxDepth defines the maximum depth of the octree
  56809. * @returns an octree of AbstractMesh
  56810. */
  56811. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  56812. }
  56813. interface AbstractMesh {
  56814. /**
  56815. * @hidden
  56816. * Backing Field
  56817. */
  56818. _submeshesOctree: Octree<SubMesh>;
  56819. /**
  56820. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  56821. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  56822. * @param maxCapacity defines the maximum size of each block (64 by default)
  56823. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  56824. * @returns the new octree
  56825. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  56826. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  56827. */
  56828. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  56829. }
  56830. /**
  56831. * Defines the octree scene component responsible to manage any octrees
  56832. * in a given scene.
  56833. */
  56834. export class OctreeSceneComponent {
  56835. /**
  56836. * The component name help to identify the component in the list of scene components.
  56837. */
  56838. readonly name: string;
  56839. /**
  56840. * The scene the component belongs to.
  56841. */
  56842. scene: Scene;
  56843. /**
  56844. * Indicates if the meshes have been checked to make sure they are isEnabled()
  56845. */
  56846. readonly checksIsEnabled: boolean;
  56847. /**
  56848. * Creates a new instance of the component for the given scene
  56849. * @param scene Defines the scene to register the component in
  56850. */
  56851. constructor(scene: Scene);
  56852. /**
  56853. * Registers the component in a given scene
  56854. */
  56855. register(): void;
  56856. /**
  56857. * Return the list of active meshes
  56858. * @returns the list of active meshes
  56859. */
  56860. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  56861. /**
  56862. * Return the list of active sub meshes
  56863. * @param mesh The mesh to get the candidates sub meshes from
  56864. * @returns the list of active sub meshes
  56865. */
  56866. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  56867. private _tempRay;
  56868. /**
  56869. * Return the list of sub meshes intersecting with a given local ray
  56870. * @param mesh defines the mesh to find the submesh for
  56871. * @param localRay defines the ray in local space
  56872. * @returns the list of intersecting sub meshes
  56873. */
  56874. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  56875. /**
  56876. * Return the list of sub meshes colliding with a collider
  56877. * @param mesh defines the mesh to find the submesh for
  56878. * @param collider defines the collider to evaluate the collision against
  56879. * @returns the list of colliding sub meshes
  56880. */
  56881. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  56882. /**
  56883. * Rebuilds the elements related to this component in case of
  56884. * context lost for instance.
  56885. */
  56886. rebuild(): void;
  56887. /**
  56888. * Disposes the component and the associated ressources.
  56889. */
  56890. dispose(): void;
  56891. }
  56892. }
  56893. declare module BABYLON {
  56894. /**
  56895. * Cache built by each axis. Used for managing state between all elements of gizmo for enhanced UI
  56896. */
  56897. export interface GizmoAxisCache {
  56898. /** Mesh used to runder the Gizmo */
  56899. gizmoMeshes: Mesh[];
  56900. /** Mesh used to detect user interaction with Gizmo */
  56901. colliderMeshes: Mesh[];
  56902. /** Material used to inicate color of gizmo mesh */
  56903. material: StandardMaterial;
  56904. /** Material used to inicate hover state of the Gizmo */
  56905. hoverMaterial: StandardMaterial;
  56906. /** Material used to inicate disabled state of the Gizmo */
  56907. disableMaterial: StandardMaterial;
  56908. /** Used to indicate Active state of the Gizmo */
  56909. active: boolean;
  56910. }
  56911. /**
  56912. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  56913. */
  56914. export class Gizmo implements IDisposable {
  56915. /** The utility layer the gizmo will be added to */
  56916. gizmoLayer: UtilityLayerRenderer;
  56917. /**
  56918. * The root mesh of the gizmo
  56919. */
  56920. _rootMesh: Mesh;
  56921. private _attachedMesh;
  56922. private _attachedNode;
  56923. /**
  56924. * Ratio for the scale of the gizmo (Default: 1)
  56925. */
  56926. protected _scaleRatio: number;
  56927. /**
  56928. * boolean updated by pointermove when a gizmo mesh is hovered
  56929. */
  56930. protected _isHovered: boolean;
  56931. /**
  56932. * Ratio for the scale of the gizmo (Default: 1)
  56933. */
  56934. set scaleRatio(value: number);
  56935. get scaleRatio(): number;
  56936. /**
  56937. * True when the mouse pointer is hovered a gizmo mesh
  56938. */
  56939. get isHovered(): boolean;
  56940. /**
  56941. * If a custom mesh has been set (Default: false)
  56942. */
  56943. protected _customMeshSet: boolean;
  56944. /**
  56945. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  56946. * * When set, interactions will be enabled
  56947. */
  56948. get attachedMesh(): Nullable<AbstractMesh>;
  56949. set attachedMesh(value: Nullable<AbstractMesh>);
  56950. /**
  56951. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  56952. * * When set, interactions will be enabled
  56953. */
  56954. get attachedNode(): Nullable<Node>;
  56955. set attachedNode(value: Nullable<Node>);
  56956. /**
  56957. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56958. * @param mesh The mesh to replace the default mesh of the gizmo
  56959. */
  56960. setCustomMesh(mesh: Mesh): void;
  56961. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  56962. /**
  56963. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  56964. */
  56965. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56966. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56967. /**
  56968. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  56969. */
  56970. updateGizmoPositionToMatchAttachedMesh: boolean;
  56971. /**
  56972. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  56973. */
  56974. updateScale: boolean;
  56975. protected _interactionsEnabled: boolean;
  56976. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56977. private _beforeRenderObserver;
  56978. private _tempQuaternion;
  56979. private _tempVector;
  56980. private _tempVector2;
  56981. private _tempMatrix1;
  56982. private _tempMatrix2;
  56983. private _rightHandtoLeftHandMatrix;
  56984. /**
  56985. * Creates a gizmo
  56986. * @param gizmoLayer The utility layer the gizmo will be added to
  56987. */
  56988. constructor(
  56989. /** The utility layer the gizmo will be added to */
  56990. gizmoLayer?: UtilityLayerRenderer);
  56991. /**
  56992. * Updates the gizmo to match the attached mesh's position/rotation
  56993. */
  56994. protected _update(): void;
  56995. /**
  56996. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56997. * @param value Node, TransformNode or mesh
  56998. */
  56999. protected _matrixChanged(): void;
  57000. /**
  57001. * Subscribes to pointer up, down, and hover events. Used for responsive gizmos.
  57002. * @param gizmoLayer The utility layer the gizmo will be added to
  57003. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57004. * @returns {Observer<PointerInfo>} pointerObserver
  57005. */
  57006. static GizmoAxisPointerObserver(gizmoLayer: UtilityLayerRenderer, gizmoAxisCache: Map<Mesh, GizmoAxisCache>): Observer<PointerInfo>;
  57007. /**
  57008. * Disposes of the gizmo
  57009. */
  57010. dispose(): void;
  57011. }
  57012. }
  57013. declare module BABYLON {
  57014. /**
  57015. * Single plane drag gizmo
  57016. */
  57017. export class PlaneDragGizmo extends Gizmo {
  57018. /**
  57019. * Drag behavior responsible for the gizmos dragging interactions
  57020. */
  57021. dragBehavior: PointerDragBehavior;
  57022. private _pointerObserver;
  57023. /**
  57024. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57025. */
  57026. snapDistance: number;
  57027. /**
  57028. * Event that fires each time the gizmo snaps to a new location.
  57029. * * snapDistance is the the change in distance
  57030. */
  57031. onSnapObservable: Observable<{
  57032. snapDistance: number;
  57033. }>;
  57034. private _gizmoMesh;
  57035. private _coloredMaterial;
  57036. private _hoverMaterial;
  57037. private _disableMaterial;
  57038. private _isEnabled;
  57039. private _parent;
  57040. private _dragging;
  57041. /** @hidden */
  57042. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  57043. /**
  57044. * Creates a PlaneDragGizmo
  57045. * @param gizmoLayer The utility layer the gizmo will be added to
  57046. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  57047. * @param color The color of the gizmo
  57048. */
  57049. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  57050. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57051. /**
  57052. * If the gizmo is enabled
  57053. */
  57054. set isEnabled(value: boolean);
  57055. get isEnabled(): boolean;
  57056. /**
  57057. * Disposes of the gizmo
  57058. */
  57059. dispose(): void;
  57060. }
  57061. }
  57062. declare module BABYLON {
  57063. /**
  57064. * Single plane rotation gizmo
  57065. */
  57066. export class PlaneRotationGizmo extends Gizmo {
  57067. /**
  57068. * Drag behavior responsible for the gizmos dragging interactions
  57069. */
  57070. dragBehavior: PointerDragBehavior;
  57071. private _pointerObserver;
  57072. /**
  57073. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  57074. */
  57075. snapDistance: number;
  57076. /**
  57077. * Event that fires each time the gizmo snaps to a new location.
  57078. * * snapDistance is the the change in distance
  57079. */
  57080. onSnapObservable: Observable<{
  57081. snapDistance: number;
  57082. }>;
  57083. private _isEnabled;
  57084. private _parent;
  57085. private _coloredMaterial;
  57086. private _hoverMaterial;
  57087. private _disableMaterial;
  57088. private _gizmoMesh;
  57089. private _rotationCircle;
  57090. private _dragging;
  57091. private static _CircleConstants;
  57092. /**
  57093. * Creates a PlaneRotationGizmo
  57094. * @param gizmoLayer The utility layer the gizmo will be added to
  57095. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  57096. * @param color The color of the gizmo
  57097. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57098. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57099. * @param thickness display gizmo axis thickness
  57100. */
  57101. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  57102. /** Create Geometry for Gizmo */
  57103. private _createGizmoMesh;
  57104. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57105. private setupRotationCircle;
  57106. private updateRotationPath;
  57107. private updateRotationCircle;
  57108. /**
  57109. * If the gizmo is enabled
  57110. */
  57111. set isEnabled(value: boolean);
  57112. get isEnabled(): boolean;
  57113. /**
  57114. * Disposes of the gizmo
  57115. */
  57116. dispose(): void;
  57117. }
  57118. }
  57119. declare module BABYLON {
  57120. /**
  57121. * Gizmo that enables rotating a mesh along 3 axis
  57122. */
  57123. export class RotationGizmo extends Gizmo {
  57124. /**
  57125. * Internal gizmo used for interactions on the x axis
  57126. */
  57127. xGizmo: PlaneRotationGizmo;
  57128. /**
  57129. * Internal gizmo used for interactions on the y axis
  57130. */
  57131. yGizmo: PlaneRotationGizmo;
  57132. /**
  57133. * Internal gizmo used for interactions on the z axis
  57134. */
  57135. zGizmo: PlaneRotationGizmo;
  57136. /** Fires an event when any of it's sub gizmos are dragged */
  57137. onDragStartObservable: Observable<unknown>;
  57138. /** Fires an event when any of it's sub gizmos are released from dragging */
  57139. onDragEndObservable: Observable<unknown>;
  57140. private _meshAttached;
  57141. private _nodeAttached;
  57142. private _observables;
  57143. /** Node Caching for quick lookup */
  57144. private _gizmoAxisCache;
  57145. get attachedMesh(): Nullable<AbstractMesh>;
  57146. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57147. get attachedNode(): Nullable<Node>;
  57148. set attachedNode(node: Nullable<Node>);
  57149. protected _checkBillboardTransform(): void;
  57150. /**
  57151. * True when the mouse pointer is hovering a gizmo mesh
  57152. */
  57153. get isHovered(): boolean;
  57154. /**
  57155. * Creates a RotationGizmo
  57156. * @param gizmoLayer The utility layer the gizmo will be added to
  57157. * @param tessellation Amount of tessellation to be used when creating rotation circles
  57158. * @param useEulerRotation Use and update Euler angle instead of quaternion
  57159. * @param thickness display gizmo axis thickness
  57160. */
  57161. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number, gizmoManager?: GizmoManager);
  57162. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57163. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57164. /**
  57165. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57166. */
  57167. set snapDistance(value: number);
  57168. get snapDistance(): number;
  57169. /**
  57170. * Ratio for the scale of the gizmo (Default: 1)
  57171. */
  57172. set scaleRatio(value: number);
  57173. get scaleRatio(): number;
  57174. /**
  57175. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57176. * @param mesh Axis gizmo mesh
  57177. * @param cache Gizmo axis definition used for reactive gizmo UI
  57178. */
  57179. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57180. /**
  57181. * Disposes of the gizmo
  57182. */
  57183. dispose(): void;
  57184. /**
  57185. * CustomMeshes are not supported by this gizmo
  57186. * @param mesh The mesh to replace the default mesh of the gizmo
  57187. */
  57188. setCustomMesh(mesh: Mesh): void;
  57189. }
  57190. }
  57191. declare module BABYLON {
  57192. /**
  57193. * Class containing static functions to help procedurally build meshes
  57194. */
  57195. export class PolyhedronBuilder {
  57196. /**
  57197. * Creates a polyhedron mesh
  57198. * * 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
  57199. * * The parameter `size` (positive float, default 1) sets the polygon size
  57200. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  57201. * * 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`
  57202. * * 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
  57203. * * 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)`)
  57204. * * 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
  57205. * * 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
  57206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57207. * * 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
  57208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57209. * @param name defines the name of the mesh
  57210. * @param options defines the options used to create the mesh
  57211. * @param scene defines the hosting scene
  57212. * @returns the polyhedron mesh
  57213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  57214. */
  57215. static CreatePolyhedron(name: string, options: {
  57216. type?: number;
  57217. size?: number;
  57218. sizeX?: number;
  57219. sizeY?: number;
  57220. sizeZ?: number;
  57221. custom?: any;
  57222. faceUV?: Vector4[];
  57223. faceColors?: Color4[];
  57224. flat?: boolean;
  57225. updatable?: boolean;
  57226. sideOrientation?: number;
  57227. frontUVs?: Vector4;
  57228. backUVs?: Vector4;
  57229. }, scene?: Nullable<Scene>): Mesh;
  57230. }
  57231. }
  57232. declare module BABYLON {
  57233. /**
  57234. * Class containing static functions to help procedurally build meshes
  57235. */
  57236. export class BoxBuilder {
  57237. /**
  57238. * Creates a box mesh
  57239. * * The parameter `size` sets the size (float) of each box side (default 1)
  57240. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  57241. * * 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)
  57242. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  57243. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57244. * * 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
  57245. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57246. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  57247. * @param name defines the name of the mesh
  57248. * @param options defines the options used to create the mesh
  57249. * @param scene defines the hosting scene
  57250. * @returns the box mesh
  57251. */
  57252. static CreateBox(name: string, options: {
  57253. size?: number;
  57254. width?: number;
  57255. height?: number;
  57256. depth?: number;
  57257. faceUV?: Vector4[];
  57258. faceColors?: Color4[];
  57259. sideOrientation?: number;
  57260. frontUVs?: Vector4;
  57261. backUVs?: Vector4;
  57262. wrap?: boolean;
  57263. topBaseAt?: number;
  57264. bottomBaseAt?: number;
  57265. updatable?: boolean;
  57266. }, scene?: Nullable<Scene>): Mesh;
  57267. }
  57268. }
  57269. declare module BABYLON {
  57270. /**
  57271. * Single axis scale gizmo
  57272. */
  57273. export class AxisScaleGizmo extends Gizmo {
  57274. /**
  57275. * Drag behavior responsible for the gizmos dragging interactions
  57276. */
  57277. dragBehavior: PointerDragBehavior;
  57278. private _pointerObserver;
  57279. /**
  57280. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57281. */
  57282. snapDistance: number;
  57283. /**
  57284. * Event that fires each time the gizmo snaps to a new location.
  57285. * * snapDistance is the the change in distance
  57286. */
  57287. onSnapObservable: Observable<{
  57288. snapDistance: number;
  57289. }>;
  57290. /**
  57291. * If the scaling operation should be done on all axis (default: false)
  57292. */
  57293. uniformScaling: boolean;
  57294. /**
  57295. * Custom sensitivity value for the drag strength
  57296. */
  57297. sensitivity: number;
  57298. private _isEnabled;
  57299. private _parent;
  57300. private _gizmoMesh;
  57301. private _coloredMaterial;
  57302. private _hoverMaterial;
  57303. private _disableMaterial;
  57304. private _dragging;
  57305. private _tmpVector;
  57306. private _tmpMatrix;
  57307. private _tmpMatrix2;
  57308. /**
  57309. * Creates an AxisScaleGizmo
  57310. * @param gizmoLayer The utility layer the gizmo will be added to
  57311. * @param dragAxis The axis which the gizmo will be able to scale on
  57312. * @param color The color of the gizmo
  57313. * @param thickness display gizmo axis thickness
  57314. */
  57315. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  57316. /** Create Geometry for Gizmo */
  57317. private _createGizmoMesh;
  57318. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57319. /**
  57320. * If the gizmo is enabled
  57321. */
  57322. set isEnabled(value: boolean);
  57323. get isEnabled(): boolean;
  57324. /**
  57325. * Disposes of the gizmo
  57326. */
  57327. dispose(): void;
  57328. /**
  57329. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  57330. * @param mesh The mesh to replace the default mesh of the gizmo
  57331. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  57332. */
  57333. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  57334. }
  57335. }
  57336. declare module BABYLON {
  57337. /**
  57338. * Gizmo that enables scaling a mesh along 3 axis
  57339. */
  57340. export class ScaleGizmo extends Gizmo {
  57341. /**
  57342. * Internal gizmo used for interactions on the x axis
  57343. */
  57344. xGizmo: AxisScaleGizmo;
  57345. /**
  57346. * Internal gizmo used for interactions on the y axis
  57347. */
  57348. yGizmo: AxisScaleGizmo;
  57349. /**
  57350. * Internal gizmo used for interactions on the z axis
  57351. */
  57352. zGizmo: AxisScaleGizmo;
  57353. /**
  57354. * Internal gizmo used to scale all axis equally
  57355. */
  57356. uniformScaleGizmo: AxisScaleGizmo;
  57357. private _meshAttached;
  57358. private _nodeAttached;
  57359. private _snapDistance;
  57360. private _uniformScalingMesh;
  57361. private _octahedron;
  57362. private _sensitivity;
  57363. private _coloredMaterial;
  57364. private _hoverMaterial;
  57365. private _disableMaterial;
  57366. private _observables;
  57367. /** Node Caching for quick lookup */
  57368. private _gizmoAxisCache;
  57369. /** Fires an event when any of it's sub gizmos are dragged */
  57370. onDragStartObservable: Observable<unknown>;
  57371. /** Fires an event when any of it's sub gizmos are released from dragging */
  57372. onDragEndObservable: Observable<unknown>;
  57373. get attachedMesh(): Nullable<AbstractMesh>;
  57374. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57375. get attachedNode(): Nullable<Node>;
  57376. set attachedNode(node: Nullable<Node>);
  57377. /**
  57378. * True when the mouse pointer is hovering a gizmo mesh
  57379. */
  57380. get isHovered(): boolean;
  57381. /**
  57382. * Creates a ScaleGizmo
  57383. * @param gizmoLayer The utility layer the gizmo will be added to
  57384. * @param thickness display gizmo axis thickness
  57385. */
  57386. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57387. /** Create Geometry for Gizmo */
  57388. private _createUniformScaleMesh;
  57389. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57390. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57391. /**
  57392. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57393. */
  57394. set snapDistance(value: number);
  57395. get snapDistance(): number;
  57396. /**
  57397. * Ratio for the scale of the gizmo (Default: 1)
  57398. */
  57399. set scaleRatio(value: number);
  57400. get scaleRatio(): number;
  57401. /**
  57402. * Sensitivity factor for dragging (Default: 1)
  57403. */
  57404. set sensitivity(value: number);
  57405. get sensitivity(): number;
  57406. /**
  57407. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57408. * @param mesh Axis gizmo mesh
  57409. * @param cache Gizmo axis definition used for reactive gizmo UI
  57410. */
  57411. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57412. /**
  57413. * Disposes of the gizmo
  57414. */
  57415. dispose(): void;
  57416. }
  57417. }
  57418. declare module BABYLON {
  57419. /**
  57420. * Bounding box gizmo
  57421. */
  57422. export class BoundingBoxGizmo extends Gizmo {
  57423. private _lineBoundingBox;
  57424. private _rotateSpheresParent;
  57425. private _scaleBoxesParent;
  57426. private _boundingDimensions;
  57427. private _renderObserver;
  57428. private _pointerObserver;
  57429. private _scaleDragSpeed;
  57430. private _tmpQuaternion;
  57431. private _tmpVector;
  57432. private _tmpRotationMatrix;
  57433. /**
  57434. * If child meshes should be ignored when calculating the boudning box. This should be set to true to avoid perf hits with heavily nested meshes (Default: false)
  57435. */
  57436. ignoreChildren: boolean;
  57437. /**
  57438. * 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)
  57439. */
  57440. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  57441. /**
  57442. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  57443. */
  57444. rotationSphereSize: number;
  57445. /**
  57446. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  57447. */
  57448. scaleBoxSize: number;
  57449. /**
  57450. * 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)
  57451. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57452. */
  57453. fixedDragMeshScreenSize: boolean;
  57454. /**
  57455. * If set, the rotation spheres and scale boxes will increase in size based on the size of the bounding box
  57456. * Note : fixedDragMeshScreenSize takes precedence over fixedDragMeshBoundsSize if both are true
  57457. */
  57458. fixedDragMeshBoundsSize: boolean;
  57459. /**
  57460. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  57461. */
  57462. fixedDragMeshScreenSizeDistanceFactor: number;
  57463. /**
  57464. * Fired when a rotation sphere or scale box is dragged
  57465. */
  57466. onDragStartObservable: Observable<{}>;
  57467. /**
  57468. * Fired when a scale box is dragged
  57469. */
  57470. onScaleBoxDragObservable: Observable<{}>;
  57471. /**
  57472. * Fired when a scale box drag is ended
  57473. */
  57474. onScaleBoxDragEndObservable: Observable<{}>;
  57475. /**
  57476. * Fired when a rotation sphere is dragged
  57477. */
  57478. onRotationSphereDragObservable: Observable<{}>;
  57479. /**
  57480. * Fired when a rotation sphere drag is ended
  57481. */
  57482. onRotationSphereDragEndObservable: Observable<{}>;
  57483. /**
  57484. * 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)
  57485. */
  57486. scalePivot: Nullable<Vector3>;
  57487. /**
  57488. * Mesh used as a pivot to rotate the attached node
  57489. */
  57490. private _anchorMesh;
  57491. private _existingMeshScale;
  57492. private _dragMesh;
  57493. private pointerDragBehavior;
  57494. private coloredMaterial;
  57495. private hoverColoredMaterial;
  57496. /**
  57497. * Sets the color of the bounding box gizmo
  57498. * @param color the color to set
  57499. */
  57500. setColor(color: Color3): void;
  57501. /**
  57502. * Creates an BoundingBoxGizmo
  57503. * @param gizmoLayer The utility layer the gizmo will be added to
  57504. * @param color The color of the gizmo
  57505. */
  57506. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  57507. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  57508. private _selectNode;
  57509. /**
  57510. * Updates the bounding box information for the Gizmo
  57511. */
  57512. updateBoundingBox(): void;
  57513. private _updateRotationSpheres;
  57514. private _updateScaleBoxes;
  57515. /**
  57516. * Enables rotation on the specified axis and disables rotation on the others
  57517. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  57518. */
  57519. setEnabledRotationAxis(axis: string): void;
  57520. /**
  57521. * Enables/disables scaling
  57522. * @param enable if scaling should be enabled
  57523. * @param homogeneousScaling defines if scaling should only be homogeneous
  57524. */
  57525. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  57526. private _updateDummy;
  57527. /**
  57528. * Enables a pointer drag behavior on the bounding box of the gizmo
  57529. */
  57530. enableDragBehavior(): void;
  57531. /**
  57532. * Disposes of the gizmo
  57533. */
  57534. dispose(): void;
  57535. /**
  57536. * 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)
  57537. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  57538. * @returns the bounding box mesh with the passed in mesh as a child
  57539. */
  57540. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  57541. /**
  57542. * CustomMeshes are not supported by this gizmo
  57543. * @param mesh The mesh to replace the default mesh of the gizmo
  57544. */
  57545. setCustomMesh(mesh: Mesh): void;
  57546. }
  57547. }
  57548. declare module BABYLON {
  57549. /**
  57550. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  57551. */
  57552. export class GizmoManager implements IDisposable {
  57553. private scene;
  57554. /**
  57555. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  57556. */
  57557. gizmos: {
  57558. positionGizmo: Nullable<PositionGizmo>;
  57559. rotationGizmo: Nullable<RotationGizmo>;
  57560. scaleGizmo: Nullable<ScaleGizmo>;
  57561. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  57562. };
  57563. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  57564. clearGizmoOnEmptyPointerEvent: boolean;
  57565. /** Fires an event when the manager is attached to a mesh */
  57566. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  57567. /** Fires an event when the manager is attached to a node */
  57568. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  57569. private _gizmosEnabled;
  57570. private _pointerObservers;
  57571. private _attachedMesh;
  57572. private _attachedNode;
  57573. private _boundingBoxColor;
  57574. private _defaultUtilityLayer;
  57575. private _defaultKeepDepthUtilityLayer;
  57576. private _thickness;
  57577. /** Node Caching for quick lookup */
  57578. private _gizmoAxisCache;
  57579. /**
  57580. * When bounding box gizmo is enabled, this can be used to track drag/end events
  57581. */
  57582. boundingBoxDragBehavior: SixDofDragBehavior;
  57583. /**
  57584. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  57585. */
  57586. attachableMeshes: Nullable<Array<AbstractMesh>>;
  57587. /**
  57588. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  57589. */
  57590. attachableNodes: Nullable<Array<Node>>;
  57591. /**
  57592. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  57593. */
  57594. usePointerToAttachGizmos: boolean;
  57595. /**
  57596. * Utility layer that the bounding box gizmo belongs to
  57597. */
  57598. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  57599. /**
  57600. * Utility layer that all gizmos besides bounding box belong to
  57601. */
  57602. get utilityLayer(): UtilityLayerRenderer;
  57603. /**
  57604. * True when the mouse pointer is hovering a gizmo mesh
  57605. */
  57606. get isHovered(): boolean;
  57607. /**
  57608. * Instatiates a gizmo manager
  57609. * @param scene the scene to overlay the gizmos on top of
  57610. * @param thickness display gizmo axis thickness
  57611. * @param utilityLayer the layer where gizmos are rendered
  57612. * @param keepDepthUtilityLayer the layer where occluded gizmos are rendered
  57613. */
  57614. constructor(scene: Scene, thickness?: number, utilityLayer?: UtilityLayerRenderer, keepDepthUtilityLayer?: UtilityLayerRenderer);
  57615. /**
  57616. * Subscribes to pointer down events, for attaching and detaching mesh
  57617. * @param scene The sceme layer the observer will be added to
  57618. */
  57619. private _attachToMeshPointerObserver;
  57620. /**
  57621. * Attaches a set of gizmos to the specified mesh
  57622. * @param mesh The mesh the gizmo's should be attached to
  57623. */
  57624. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57625. /**
  57626. * Attaches a set of gizmos to the specified node
  57627. * @param node The node the gizmo's should be attached to
  57628. */
  57629. attachToNode(node: Nullable<Node>): void;
  57630. /**
  57631. * If the position gizmo is enabled
  57632. */
  57633. set positionGizmoEnabled(value: boolean);
  57634. get positionGizmoEnabled(): boolean;
  57635. /**
  57636. * If the rotation gizmo is enabled
  57637. */
  57638. set rotationGizmoEnabled(value: boolean);
  57639. get rotationGizmoEnabled(): boolean;
  57640. /**
  57641. * If the scale gizmo is enabled
  57642. */
  57643. set scaleGizmoEnabled(value: boolean);
  57644. get scaleGizmoEnabled(): boolean;
  57645. /**
  57646. * If the boundingBox gizmo is enabled
  57647. */
  57648. set boundingBoxGizmoEnabled(value: boolean);
  57649. get boundingBoxGizmoEnabled(): boolean;
  57650. /**
  57651. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57652. * @param gizmoAxisCache Gizmo axis definition used for reactive gizmo UI
  57653. */
  57654. addToAxisCache(gizmoAxisCache: Map<Mesh, GizmoAxisCache>): void;
  57655. /**
  57656. * Disposes of the gizmo manager
  57657. */
  57658. dispose(): void;
  57659. }
  57660. }
  57661. declare module BABYLON {
  57662. /**
  57663. * Gizmo that enables dragging a mesh along 3 axis
  57664. */
  57665. export class PositionGizmo extends Gizmo {
  57666. /**
  57667. * Internal gizmo used for interactions on the x axis
  57668. */
  57669. xGizmo: AxisDragGizmo;
  57670. /**
  57671. * Internal gizmo used for interactions on the y axis
  57672. */
  57673. yGizmo: AxisDragGizmo;
  57674. /**
  57675. * Internal gizmo used for interactions on the z axis
  57676. */
  57677. zGizmo: AxisDragGizmo;
  57678. /**
  57679. * Internal gizmo used for interactions on the yz plane
  57680. */
  57681. xPlaneGizmo: PlaneDragGizmo;
  57682. /**
  57683. * Internal gizmo used for interactions on the xz plane
  57684. */
  57685. yPlaneGizmo: PlaneDragGizmo;
  57686. /**
  57687. * Internal gizmo used for interactions on the xy plane
  57688. */
  57689. zPlaneGizmo: PlaneDragGizmo;
  57690. /**
  57691. * private variables
  57692. */
  57693. private _meshAttached;
  57694. private _nodeAttached;
  57695. private _snapDistance;
  57696. private _observables;
  57697. /** Node Caching for quick lookup */
  57698. private _gizmoAxisCache;
  57699. /** Fires an event when any of it's sub gizmos are dragged */
  57700. onDragStartObservable: Observable<unknown>;
  57701. /** Fires an event when any of it's sub gizmos are released from dragging */
  57702. onDragEndObservable: Observable<unknown>;
  57703. /**
  57704. * If set to true, planar drag is enabled
  57705. */
  57706. private _planarGizmoEnabled;
  57707. get attachedMesh(): Nullable<AbstractMesh>;
  57708. set attachedMesh(mesh: Nullable<AbstractMesh>);
  57709. get attachedNode(): Nullable<Node>;
  57710. set attachedNode(node: Nullable<Node>);
  57711. /**
  57712. * True when the mouse pointer is hovering a gizmo mesh
  57713. */
  57714. get isHovered(): boolean;
  57715. /**
  57716. * Creates a PositionGizmo
  57717. * @param gizmoLayer The utility layer the gizmo will be added to
  57718. @param thickness display gizmo axis thickness
  57719. */
  57720. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number, gizmoManager?: GizmoManager);
  57721. /**
  57722. * If the planar drag gizmo is enabled
  57723. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  57724. */
  57725. set planarGizmoEnabled(value: boolean);
  57726. get planarGizmoEnabled(): boolean;
  57727. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  57728. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  57729. /**
  57730. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57731. */
  57732. set snapDistance(value: number);
  57733. get snapDistance(): number;
  57734. /**
  57735. * Ratio for the scale of the gizmo (Default: 1)
  57736. */
  57737. set scaleRatio(value: number);
  57738. get scaleRatio(): number;
  57739. /**
  57740. * Builds Gizmo Axis Cache to enable features such as hover state preservation and graying out other axis during manipulation
  57741. * @param mesh Axis gizmo mesh
  57742. * @param cache Gizmo axis definition used for reactive gizmo UI
  57743. */
  57744. addToAxisCache(mesh: Mesh, cache: GizmoAxisCache): void;
  57745. /**
  57746. * Disposes of the gizmo
  57747. */
  57748. dispose(): void;
  57749. /**
  57750. * CustomMeshes are not supported by this gizmo
  57751. * @param mesh The mesh to replace the default mesh of the gizmo
  57752. */
  57753. setCustomMesh(mesh: Mesh): void;
  57754. }
  57755. }
  57756. declare module BABYLON {
  57757. /**
  57758. * Single axis drag gizmo
  57759. */
  57760. export class AxisDragGizmo extends Gizmo {
  57761. /**
  57762. * Drag behavior responsible for the gizmos dragging interactions
  57763. */
  57764. dragBehavior: PointerDragBehavior;
  57765. private _pointerObserver;
  57766. /**
  57767. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  57768. */
  57769. snapDistance: number;
  57770. /**
  57771. * Event that fires each time the gizmo snaps to a new location.
  57772. * * snapDistance is the the change in distance
  57773. */
  57774. onSnapObservable: Observable<{
  57775. snapDistance: number;
  57776. }>;
  57777. private _isEnabled;
  57778. private _parent;
  57779. private _gizmoMesh;
  57780. private _coloredMaterial;
  57781. private _hoverMaterial;
  57782. private _disableMaterial;
  57783. private _dragging;
  57784. /** @hidden */
  57785. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number, isCollider?: boolean): TransformNode;
  57786. /** @hidden */
  57787. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  57788. /**
  57789. * Creates an AxisDragGizmo
  57790. * @param gizmoLayer The utility layer the gizmo will be added to
  57791. * @param dragAxis The axis which the gizmo will be able to drag on
  57792. * @param color The color of the gizmo
  57793. * @param thickness display gizmo axis thickness
  57794. */
  57795. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  57796. protected _attachedNodeChanged(value: Nullable<Node>): void;
  57797. /**
  57798. * If the gizmo is enabled
  57799. */
  57800. set isEnabled(value: boolean);
  57801. get isEnabled(): boolean;
  57802. /**
  57803. * Disposes of the gizmo
  57804. */
  57805. dispose(): void;
  57806. }
  57807. }
  57808. declare module BABYLON.Debug {
  57809. /**
  57810. * The Axes viewer will show 3 axes in a specific point in space
  57811. */
  57812. export class AxesViewer {
  57813. private _xAxis;
  57814. private _yAxis;
  57815. private _zAxis;
  57816. private _scaleLinesFactor;
  57817. private _instanced;
  57818. /**
  57819. * Gets the hosting scene
  57820. */
  57821. scene: Nullable<Scene>;
  57822. /**
  57823. * Gets or sets a number used to scale line length
  57824. */
  57825. scaleLines: number;
  57826. /** Gets the node hierarchy used to render x-axis */
  57827. get xAxis(): TransformNode;
  57828. /** Gets the node hierarchy used to render y-axis */
  57829. get yAxis(): TransformNode;
  57830. /** Gets the node hierarchy used to render z-axis */
  57831. get zAxis(): TransformNode;
  57832. /**
  57833. * Creates a new AxesViewer
  57834. * @param scene defines the hosting scene
  57835. * @param scaleLines defines a number used to scale line length (1 by default)
  57836. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  57837. * @param xAxis defines the node hierarchy used to render the x-axis
  57838. * @param yAxis defines the node hierarchy used to render the y-axis
  57839. * @param zAxis defines the node hierarchy used to render the z-axis
  57840. */
  57841. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  57842. /**
  57843. * Force the viewer to update
  57844. * @param position defines the position of the viewer
  57845. * @param xaxis defines the x axis of the viewer
  57846. * @param yaxis defines the y axis of the viewer
  57847. * @param zaxis defines the z axis of the viewer
  57848. */
  57849. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  57850. /**
  57851. * Creates an instance of this axes viewer.
  57852. * @returns a new axes viewer with instanced meshes
  57853. */
  57854. createInstance(): AxesViewer;
  57855. /** Releases resources */
  57856. dispose(): void;
  57857. private static _SetRenderingGroupId;
  57858. }
  57859. }
  57860. declare module BABYLON.Debug {
  57861. /**
  57862. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  57863. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  57864. */
  57865. export class BoneAxesViewer extends AxesViewer {
  57866. /**
  57867. * Gets or sets the target mesh where to display the axes viewer
  57868. */
  57869. mesh: Nullable<Mesh>;
  57870. /**
  57871. * Gets or sets the target bone where to display the axes viewer
  57872. */
  57873. bone: Nullable<Bone>;
  57874. /** Gets current position */
  57875. pos: Vector3;
  57876. /** Gets direction of X axis */
  57877. xaxis: Vector3;
  57878. /** Gets direction of Y axis */
  57879. yaxis: Vector3;
  57880. /** Gets direction of Z axis */
  57881. zaxis: Vector3;
  57882. /**
  57883. * Creates a new BoneAxesViewer
  57884. * @param scene defines the hosting scene
  57885. * @param bone defines the target bone
  57886. * @param mesh defines the target mesh
  57887. * @param scaleLines defines a scaling factor for line length (1 by default)
  57888. */
  57889. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  57890. /**
  57891. * Force the viewer to update
  57892. */
  57893. update(): void;
  57894. /** Releases resources */
  57895. dispose(): void;
  57896. }
  57897. }
  57898. declare module BABYLON {
  57899. /**
  57900. * Interface used to define scene explorer extensibility option
  57901. */
  57902. export interface IExplorerExtensibilityOption {
  57903. /**
  57904. * Define the option label
  57905. */
  57906. label: string;
  57907. /**
  57908. * Defines the action to execute on click
  57909. */
  57910. action: (entity: any) => void;
  57911. }
  57912. /**
  57913. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  57914. */
  57915. export interface IExplorerExtensibilityGroup {
  57916. /**
  57917. * Defines a predicate to test if a given type mut be extended
  57918. */
  57919. predicate: (entity: any) => boolean;
  57920. /**
  57921. * Gets the list of options added to a type
  57922. */
  57923. entries: IExplorerExtensibilityOption[];
  57924. }
  57925. /**
  57926. * Interface used to define the options to use to create the Inspector
  57927. */
  57928. export interface IInspectorOptions {
  57929. /**
  57930. * Display in overlay mode (default: false)
  57931. */
  57932. overlay?: boolean;
  57933. /**
  57934. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  57935. */
  57936. globalRoot?: HTMLElement;
  57937. /**
  57938. * Display the Scene explorer
  57939. */
  57940. showExplorer?: boolean;
  57941. /**
  57942. * Display the property inspector
  57943. */
  57944. showInspector?: boolean;
  57945. /**
  57946. * Display in embed mode (both panes on the right)
  57947. */
  57948. embedMode?: boolean;
  57949. /**
  57950. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  57951. */
  57952. handleResize?: boolean;
  57953. /**
  57954. * Allow the panes to popup (default: true)
  57955. */
  57956. enablePopup?: boolean;
  57957. /**
  57958. * Allow the panes to be closed by users (default: true)
  57959. */
  57960. enableClose?: boolean;
  57961. /**
  57962. * Optional list of extensibility entries
  57963. */
  57964. explorerExtensibility?: IExplorerExtensibilityGroup[];
  57965. /**
  57966. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  57967. */
  57968. inspectorURL?: string;
  57969. /**
  57970. * Optional initial tab (default to DebugLayerTab.Properties)
  57971. */
  57972. initialTab?: DebugLayerTab;
  57973. }
  57974. interface Scene {
  57975. /**
  57976. * @hidden
  57977. * Backing field
  57978. */
  57979. _debugLayer: DebugLayer;
  57980. /**
  57981. * Gets the debug layer (aka Inspector) associated with the scene
  57982. * @see https://doc.babylonjs.com/features/playground_debuglayer
  57983. */
  57984. debugLayer: DebugLayer;
  57985. }
  57986. /**
  57987. * Enum of inspector action tab
  57988. */
  57989. export enum DebugLayerTab {
  57990. /**
  57991. * Properties tag (default)
  57992. */
  57993. Properties = 0,
  57994. /**
  57995. * Debug tab
  57996. */
  57997. Debug = 1,
  57998. /**
  57999. * Statistics tab
  58000. */
  58001. Statistics = 2,
  58002. /**
  58003. * Tools tab
  58004. */
  58005. Tools = 3,
  58006. /**
  58007. * Settings tab
  58008. */
  58009. Settings = 4
  58010. }
  58011. /**
  58012. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58013. * what is happening in your scene
  58014. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58015. */
  58016. export class DebugLayer {
  58017. /**
  58018. * Define the url to get the inspector script from.
  58019. * By default it uses the babylonjs CDN.
  58020. * @ignoreNaming
  58021. */
  58022. static InspectorURL: string;
  58023. private _scene;
  58024. private BJSINSPECTOR;
  58025. private _onPropertyChangedObservable?;
  58026. /**
  58027. * Observable triggered when a property is changed through the inspector.
  58028. */
  58029. get onPropertyChangedObservable(): any;
  58030. /**
  58031. * Instantiates a new debug layer.
  58032. * The debug layer (aka Inspector) is the go to tool in order to better understand
  58033. * what is happening in your scene
  58034. * @see https://doc.babylonjs.com/features/playground_debuglayer
  58035. * @param scene Defines the scene to inspect
  58036. */
  58037. constructor(scene: Scene);
  58038. /** Creates the inspector window. */
  58039. private _createInspector;
  58040. /**
  58041. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  58042. * @param entity defines the entity to select
  58043. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  58044. */
  58045. select(entity: any, lineContainerTitles?: string | string[]): void;
  58046. /** Get the inspector from bundle or global */
  58047. private _getGlobalInspector;
  58048. /**
  58049. * Get if the inspector is visible or not.
  58050. * @returns true if visible otherwise, false
  58051. */
  58052. isVisible(): boolean;
  58053. /**
  58054. * Hide the inspector and close its window.
  58055. */
  58056. hide(): void;
  58057. /**
  58058. * Update the scene in the inspector
  58059. */
  58060. setAsActiveScene(): void;
  58061. /**
  58062. * Launch the debugLayer.
  58063. * @param config Define the configuration of the inspector
  58064. * @return a promise fulfilled when the debug layer is visible
  58065. */
  58066. show(config?: IInspectorOptions): Promise<DebugLayer>;
  58067. }
  58068. }
  58069. declare module BABYLON.Debug {
  58070. /**
  58071. * Used to show the physics impostor around the specific mesh
  58072. */
  58073. export class PhysicsViewer {
  58074. /** @hidden */
  58075. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  58076. /** @hidden */
  58077. protected _meshes: Array<Nullable<AbstractMesh>>;
  58078. /** @hidden */
  58079. protected _scene: Nullable<Scene>;
  58080. /** @hidden */
  58081. protected _numMeshes: number;
  58082. /** @hidden */
  58083. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  58084. private _renderFunction;
  58085. private _utilityLayer;
  58086. private _debugBoxMesh;
  58087. private _debugSphereMesh;
  58088. private _debugCylinderMesh;
  58089. private _debugMaterial;
  58090. private _debugMeshMeshes;
  58091. /**
  58092. * Creates a new PhysicsViewer
  58093. * @param scene defines the hosting scene
  58094. */
  58095. constructor(scene: Scene);
  58096. /** @hidden */
  58097. protected _updateDebugMeshes(): void;
  58098. /**
  58099. * Renders a specified physic impostor
  58100. * @param impostor defines the impostor to render
  58101. * @param targetMesh defines the mesh represented by the impostor
  58102. * @returns the new debug mesh used to render the impostor
  58103. */
  58104. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  58105. /**
  58106. * Hides a specified physic impostor
  58107. * @param impostor defines the impostor to hide
  58108. */
  58109. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  58110. private _getDebugMaterial;
  58111. private _getDebugBoxMesh;
  58112. private _getDebugSphereMesh;
  58113. private _getDebugCylinderMesh;
  58114. private _getDebugMeshMesh;
  58115. private _getDebugMesh;
  58116. /** Releases all resources */
  58117. dispose(): void;
  58118. }
  58119. }
  58120. declare module BABYLON {
  58121. /**
  58122. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58123. * in order to better appreciate the issue one might have.
  58124. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58125. */
  58126. export class RayHelper {
  58127. /**
  58128. * Defines the ray we are currently tryin to visualize.
  58129. */
  58130. ray: Nullable<Ray>;
  58131. private _renderPoints;
  58132. private _renderLine;
  58133. private _renderFunction;
  58134. private _scene;
  58135. private _onAfterRenderObserver;
  58136. private _onAfterStepObserver;
  58137. private _attachedToMesh;
  58138. private _meshSpaceDirection;
  58139. private _meshSpaceOrigin;
  58140. /**
  58141. * Helper function to create a colored helper in a scene in one line.
  58142. * @param ray Defines the ray we are currently tryin to visualize
  58143. * @param scene Defines the scene the ray is used in
  58144. * @param color Defines the color we want to see the ray in
  58145. * @returns The newly created ray helper.
  58146. */
  58147. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  58148. /**
  58149. * Instantiate a new ray helper.
  58150. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  58151. * in order to better appreciate the issue one might have.
  58152. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  58153. * @param ray Defines the ray we are currently tryin to visualize
  58154. */
  58155. constructor(ray: Ray);
  58156. /**
  58157. * Shows the ray we are willing to debug.
  58158. * @param scene Defines the scene the ray needs to be rendered in
  58159. * @param color Defines the color the ray needs to be rendered in
  58160. */
  58161. show(scene: Scene, color?: Color3): void;
  58162. /**
  58163. * Hides the ray we are debugging.
  58164. */
  58165. hide(): void;
  58166. private _render;
  58167. /**
  58168. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  58169. * @param mesh Defines the mesh we want the helper attached to
  58170. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  58171. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  58172. * @param length Defines the length of the ray
  58173. */
  58174. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  58175. /**
  58176. * Detach the ray helper from the mesh it has previously been attached to.
  58177. */
  58178. detachFromMesh(): void;
  58179. private _updateToMesh;
  58180. /**
  58181. * Dispose the helper and release its associated resources.
  58182. */
  58183. dispose(): void;
  58184. }
  58185. }
  58186. declare module BABYLON {
  58187. /**
  58188. * Defines the options associated with the creation of a SkeletonViewer.
  58189. */
  58190. export interface ISkeletonViewerOptions {
  58191. /** Should the system pause animations before building the Viewer? */
  58192. pauseAnimations: boolean;
  58193. /** Should the system return the skeleton to rest before building? */
  58194. returnToRest: boolean;
  58195. /** public Display Mode of the Viewer */
  58196. displayMode: number;
  58197. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58198. displayOptions: ISkeletonViewerDisplayOptions;
  58199. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  58200. computeBonesUsingShaders: boolean;
  58201. /** Flag ignore non weighted bones */
  58202. useAllBones: boolean;
  58203. }
  58204. /**
  58205. * Defines how to display the various bone meshes for the viewer.
  58206. */
  58207. export interface ISkeletonViewerDisplayOptions {
  58208. /** How far down to start tapering the bone spurs */
  58209. midStep?: number;
  58210. /** How big is the midStep? */
  58211. midStepFactor?: number;
  58212. /** Base for the Sphere Size */
  58213. sphereBaseSize?: number;
  58214. /** The ratio of the sphere to the longest bone in units */
  58215. sphereScaleUnit?: number;
  58216. /** Ratio for the Sphere Size */
  58217. sphereFactor?: number;
  58218. /** Whether a spur should attach its far end to the child bone position */
  58219. spurFollowsChild?: boolean;
  58220. /** Whether to show local axes or not */
  58221. showLocalAxes?: boolean;
  58222. /** Length of each local axis */
  58223. localAxesSize?: number;
  58224. }
  58225. /**
  58226. * Defines the constructor options for the BoneWeight Shader.
  58227. */
  58228. export interface IBoneWeightShaderOptions {
  58229. /** Skeleton to Map */
  58230. skeleton: Skeleton;
  58231. /** Colors for Uninfluenced bones */
  58232. colorBase?: Color3;
  58233. /** Colors for 0.0-0.25 Weight bones */
  58234. colorZero?: Color3;
  58235. /** Color for 0.25-0.5 Weight Influence */
  58236. colorQuarter?: Color3;
  58237. /** Color for 0.5-0.75 Weight Influence */
  58238. colorHalf?: Color3;
  58239. /** Color for 0.75-1 Weight Influence */
  58240. colorFull?: Color3;
  58241. /** Color for Zero Weight Influence */
  58242. targetBoneIndex?: number;
  58243. }
  58244. /**
  58245. * Simple structure of the gradient steps for the Color Map.
  58246. */
  58247. export interface ISkeletonMapShaderColorMapKnot {
  58248. /** Color of the Knot */
  58249. color: Color3;
  58250. /** Location of the Knot */
  58251. location: number;
  58252. }
  58253. /**
  58254. * Defines the constructor options for the SkeletonMap Shader.
  58255. */
  58256. export interface ISkeletonMapShaderOptions {
  58257. /** Skeleton to Map */
  58258. skeleton: Skeleton;
  58259. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  58260. colorMap?: ISkeletonMapShaderColorMapKnot[];
  58261. }
  58262. }
  58263. declare module BABYLON {
  58264. /**
  58265. * Class containing static functions to help procedurally build meshes
  58266. */
  58267. export class RibbonBuilder {
  58268. /**
  58269. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58270. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58271. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58272. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58273. * * 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
  58274. * * 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
  58275. * * 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
  58276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58277. * * 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
  58278. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58279. * * 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
  58280. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58281. * * 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
  58282. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58284. * @param name defines the name of the mesh
  58285. * @param options defines the options used to create the mesh
  58286. * @param scene defines the hosting scene
  58287. * @returns the ribbon mesh
  58288. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58289. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58290. */
  58291. static CreateRibbon(name: string, options: {
  58292. pathArray: Vector3[][];
  58293. closeArray?: boolean;
  58294. closePath?: boolean;
  58295. offset?: number;
  58296. updatable?: boolean;
  58297. sideOrientation?: number;
  58298. frontUVs?: Vector4;
  58299. backUVs?: Vector4;
  58300. instance?: Mesh;
  58301. invertUV?: boolean;
  58302. uvs?: Vector2[];
  58303. colors?: Color4[];
  58304. }, scene?: Nullable<Scene>): Mesh;
  58305. }
  58306. }
  58307. declare module BABYLON {
  58308. /**
  58309. * Class containing static functions to help procedurally build meshes
  58310. */
  58311. export class ShapeBuilder {
  58312. /**
  58313. * 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.
  58314. * * 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.
  58315. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58316. * * 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.
  58317. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58318. * * 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
  58319. * * 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
  58320. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58321. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58322. * * 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
  58323. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58325. * @param name defines the name of the mesh
  58326. * @param options defines the options used to create the mesh
  58327. * @param scene defines the hosting scene
  58328. * @returns the extruded shape mesh
  58329. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58331. */
  58332. static ExtrudeShape(name: string, options: {
  58333. shape: Vector3[];
  58334. path: Vector3[];
  58335. scale?: number;
  58336. rotation?: number;
  58337. cap?: number;
  58338. updatable?: boolean;
  58339. sideOrientation?: number;
  58340. frontUVs?: Vector4;
  58341. backUVs?: Vector4;
  58342. instance?: Mesh;
  58343. invertUV?: boolean;
  58344. }, scene?: Nullable<Scene>): Mesh;
  58345. /**
  58346. * Creates an custom extruded shape mesh.
  58347. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58348. * * 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.
  58349. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58350. * * 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 begining of the path
  58351. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58352. * * 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
  58353. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58354. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58355. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58356. * * 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
  58357. * * 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
  58358. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58359. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58360. * * 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
  58361. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58362. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58363. * @param name defines the name of the mesh
  58364. * @param options defines the options used to create the mesh
  58365. * @param scene defines the hosting scene
  58366. * @returns the custom extruded shape mesh
  58367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58368. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58369. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58370. */
  58371. static ExtrudeShapeCustom(name: string, options: {
  58372. shape: Vector3[];
  58373. path: Vector3[];
  58374. scaleFunction?: any;
  58375. rotationFunction?: any;
  58376. ribbonCloseArray?: boolean;
  58377. ribbonClosePath?: boolean;
  58378. cap?: number;
  58379. updatable?: boolean;
  58380. sideOrientation?: number;
  58381. frontUVs?: Vector4;
  58382. backUVs?: Vector4;
  58383. instance?: Mesh;
  58384. invertUV?: boolean;
  58385. }, scene?: Nullable<Scene>): Mesh;
  58386. private static _ExtrudeShapeGeneric;
  58387. }
  58388. }
  58389. declare module BABYLON.Debug {
  58390. /**
  58391. * Class used to render a debug view of a given skeleton
  58392. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  58393. */
  58394. export class SkeletonViewer {
  58395. /** defines the skeleton to render */
  58396. skeleton: Skeleton;
  58397. /** defines the mesh attached to the skeleton */
  58398. mesh: AbstractMesh;
  58399. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58400. autoUpdateBonesMatrices: boolean;
  58401. /** defines the rendering group id to use with the viewer */
  58402. renderingGroupId: number;
  58403. /** is the options for the viewer */
  58404. options: Partial<ISkeletonViewerOptions>;
  58405. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  58406. static readonly DISPLAY_LINES: number;
  58407. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  58408. static readonly DISPLAY_SPHERES: number;
  58409. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  58410. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  58411. /** public static method to create a BoneWeight Shader
  58412. * @param options The constructor options
  58413. * @param scene The scene that the shader is scoped to
  58414. * @returns The created ShaderMaterial
  58415. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  58416. */
  58417. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  58418. /** public static method to create a BoneWeight Shader
  58419. * @param options The constructor options
  58420. * @param scene The scene that the shader is scoped to
  58421. * @returns The created ShaderMaterial
  58422. */
  58423. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  58424. /** private static method to create a BoneWeight Shader
  58425. * @param size The size of the buffer to create (usually the bone count)
  58426. * @param colorMap The gradient data to generate
  58427. * @param scene The scene that the shader is scoped to
  58428. * @returns an Array of floats from the color gradient values
  58429. */
  58430. private static _CreateBoneMapColorBuffer;
  58431. /** If SkeletonViewer scene scope. */
  58432. private _scene;
  58433. /** Gets or sets the color used to render the skeleton */
  58434. color: Color3;
  58435. /** Array of the points of the skeleton fo the line view. */
  58436. private _debugLines;
  58437. /** The SkeletonViewers Mesh. */
  58438. private _debugMesh;
  58439. /** The local axes Meshes. */
  58440. private _localAxes;
  58441. /** If SkeletonViewer is enabled. */
  58442. private _isEnabled;
  58443. /** If SkeletonViewer is ready. */
  58444. private _ready;
  58445. /** SkeletonViewer render observable. */
  58446. private _obs;
  58447. /** The Utility Layer to render the gizmos in. */
  58448. private _utilityLayer;
  58449. private _boneIndices;
  58450. /** Gets the Scene. */
  58451. get scene(): Scene;
  58452. /** Gets the utilityLayer. */
  58453. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  58454. /** Checks Ready Status. */
  58455. get isReady(): Boolean;
  58456. /** Sets Ready Status. */
  58457. set ready(value: boolean);
  58458. /** Gets the debugMesh */
  58459. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  58460. /** Sets the debugMesh */
  58461. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  58462. /** Gets the displayMode */
  58463. get displayMode(): number;
  58464. /** Sets the displayMode */
  58465. set displayMode(value: number);
  58466. /**
  58467. * Creates a new SkeletonViewer
  58468. * @param skeleton defines the skeleton to render
  58469. * @param mesh defines the mesh attached to the skeleton
  58470. * @param scene defines the hosting scene
  58471. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  58472. * @param renderingGroupId defines the rendering group id to use with the viewer
  58473. * @param options All of the extra constructor options for the SkeletonViewer
  58474. */
  58475. constructor(
  58476. /** defines the skeleton to render */
  58477. skeleton: Skeleton,
  58478. /** defines the mesh attached to the skeleton */
  58479. mesh: AbstractMesh,
  58480. /** The Scene scope*/
  58481. scene: Scene,
  58482. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  58483. autoUpdateBonesMatrices?: boolean,
  58484. /** defines the rendering group id to use with the viewer */
  58485. renderingGroupId?: number,
  58486. /** is the options for the viewer */
  58487. options?: Partial<ISkeletonViewerOptions>);
  58488. /** The Dynamic bindings for the update functions */
  58489. private _bindObs;
  58490. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  58491. update(): void;
  58492. /** Gets or sets a boolean indicating if the viewer is enabled */
  58493. set isEnabled(value: boolean);
  58494. get isEnabled(): boolean;
  58495. private _getBonePosition;
  58496. private _getLinesForBonesWithLength;
  58497. private _getLinesForBonesNoLength;
  58498. /** function to revert the mesh and scene back to the initial state. */
  58499. private _revert;
  58500. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  58501. private _getAbsoluteBindPoseToRef;
  58502. /** function to build and bind sphere joint points and spur bone representations. */
  58503. private _buildSpheresAndSpurs;
  58504. private _buildLocalAxes;
  58505. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  58506. private _displayLinesUpdate;
  58507. /** Changes the displayMode of the skeleton viewer
  58508. * @param mode The displayMode numerical value
  58509. */
  58510. changeDisplayMode(mode: number): void;
  58511. /** Sets a display option of the skeleton viewer
  58512. *
  58513. * | Option | Type | Default | Description |
  58514. * | ---------------- | ------- | ------- | ----------- |
  58515. * | 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`. |
  58516. * | 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`. |
  58517. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  58518. * | 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`. |
  58519. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  58520. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  58521. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  58522. *
  58523. * @param option String of the option name
  58524. * @param value The numerical option value
  58525. */
  58526. changeDisplayOptions(option: string, value: number): void;
  58527. /** Release associated resources */
  58528. dispose(): void;
  58529. }
  58530. }
  58531. declare module BABYLON {
  58532. /**
  58533. * Enum for Device Types
  58534. */
  58535. export enum DeviceType {
  58536. /** Generic */
  58537. Generic = 0,
  58538. /** Keyboard */
  58539. Keyboard = 1,
  58540. /** Mouse */
  58541. Mouse = 2,
  58542. /** Touch Pointers */
  58543. Touch = 3,
  58544. /** PS4 Dual Shock */
  58545. DualShock = 4,
  58546. /** Xbox */
  58547. Xbox = 5,
  58548. /** Switch Controller */
  58549. Switch = 6
  58550. }
  58551. /**
  58552. * Enum for All Pointers (Touch/Mouse)
  58553. */
  58554. export enum PointerInput {
  58555. /** Horizontal Axis */
  58556. Horizontal = 0,
  58557. /** Vertical Axis */
  58558. Vertical = 1,
  58559. /** Left Click or Touch */
  58560. LeftClick = 2,
  58561. /** Middle Click */
  58562. MiddleClick = 3,
  58563. /** Right Click */
  58564. RightClick = 4,
  58565. /** Browser Back */
  58566. BrowserBack = 5,
  58567. /** Browser Forward */
  58568. BrowserForward = 6
  58569. }
  58570. /**
  58571. * Enum for Dual Shock Gamepad
  58572. */
  58573. export enum DualShockInput {
  58574. /** Cross */
  58575. Cross = 0,
  58576. /** Circle */
  58577. Circle = 1,
  58578. /** Square */
  58579. Square = 2,
  58580. /** Triangle */
  58581. Triangle = 3,
  58582. /** L1 */
  58583. L1 = 4,
  58584. /** R1 */
  58585. R1 = 5,
  58586. /** L2 */
  58587. L2 = 6,
  58588. /** R2 */
  58589. R2 = 7,
  58590. /** Share */
  58591. Share = 8,
  58592. /** Options */
  58593. Options = 9,
  58594. /** L3 */
  58595. L3 = 10,
  58596. /** R3 */
  58597. R3 = 11,
  58598. /** DPadUp */
  58599. DPadUp = 12,
  58600. /** DPadDown */
  58601. DPadDown = 13,
  58602. /** DPadLeft */
  58603. DPadLeft = 14,
  58604. /** DRight */
  58605. DPadRight = 15,
  58606. /** Home */
  58607. Home = 16,
  58608. /** TouchPad */
  58609. TouchPad = 17,
  58610. /** LStickXAxis */
  58611. LStickXAxis = 18,
  58612. /** LStickYAxis */
  58613. LStickYAxis = 19,
  58614. /** RStickXAxis */
  58615. RStickXAxis = 20,
  58616. /** RStickYAxis */
  58617. RStickYAxis = 21
  58618. }
  58619. /**
  58620. * Enum for Xbox Gamepad
  58621. */
  58622. export enum XboxInput {
  58623. /** A */
  58624. A = 0,
  58625. /** B */
  58626. B = 1,
  58627. /** X */
  58628. X = 2,
  58629. /** Y */
  58630. Y = 3,
  58631. /** LB */
  58632. LB = 4,
  58633. /** RB */
  58634. RB = 5,
  58635. /** LT */
  58636. LT = 6,
  58637. /** RT */
  58638. RT = 7,
  58639. /** Back */
  58640. Back = 8,
  58641. /** Start */
  58642. Start = 9,
  58643. /** LS */
  58644. LS = 10,
  58645. /** RS */
  58646. RS = 11,
  58647. /** DPadUp */
  58648. DPadUp = 12,
  58649. /** DPadDown */
  58650. DPadDown = 13,
  58651. /** DPadLeft */
  58652. DPadLeft = 14,
  58653. /** DRight */
  58654. DPadRight = 15,
  58655. /** Home */
  58656. Home = 16,
  58657. /** LStickXAxis */
  58658. LStickXAxis = 17,
  58659. /** LStickYAxis */
  58660. LStickYAxis = 18,
  58661. /** RStickXAxis */
  58662. RStickXAxis = 19,
  58663. /** RStickYAxis */
  58664. RStickYAxis = 20
  58665. }
  58666. /**
  58667. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  58668. */
  58669. export enum SwitchInput {
  58670. /** B */
  58671. B = 0,
  58672. /** A */
  58673. A = 1,
  58674. /** Y */
  58675. Y = 2,
  58676. /** X */
  58677. X = 3,
  58678. /** L */
  58679. L = 4,
  58680. /** R */
  58681. R = 5,
  58682. /** ZL */
  58683. ZL = 6,
  58684. /** ZR */
  58685. ZR = 7,
  58686. /** Minus */
  58687. Minus = 8,
  58688. /** Plus */
  58689. Plus = 9,
  58690. /** LS */
  58691. LS = 10,
  58692. /** RS */
  58693. RS = 11,
  58694. /** DPadUp */
  58695. DPadUp = 12,
  58696. /** DPadDown */
  58697. DPadDown = 13,
  58698. /** DPadLeft */
  58699. DPadLeft = 14,
  58700. /** DRight */
  58701. DPadRight = 15,
  58702. /** Home */
  58703. Home = 16,
  58704. /** Capture */
  58705. Capture = 17,
  58706. /** LStickXAxis */
  58707. LStickXAxis = 18,
  58708. /** LStickYAxis */
  58709. LStickYAxis = 19,
  58710. /** RStickXAxis */
  58711. RStickXAxis = 20,
  58712. /** RStickYAxis */
  58713. RStickYAxis = 21
  58714. }
  58715. }
  58716. declare module BABYLON {
  58717. /**
  58718. * This class will take all inputs from Keyboard, Pointer, and
  58719. * any Gamepads and provide a polling system that all devices
  58720. * will use. This class assumes that there will only be one
  58721. * pointer device and one keyboard.
  58722. */
  58723. export class DeviceInputSystem implements IDisposable {
  58724. /**
  58725. * Returns onDeviceConnected callback property
  58726. * @returns Callback with function to execute when a device is connected
  58727. */
  58728. get onDeviceConnected(): (deviceType: DeviceType, deviceSlot: number) => void;
  58729. /**
  58730. * Sets callback function when a device is connected and executes against all connected devices
  58731. * @param callback Function to execute when a device is connected
  58732. */
  58733. set onDeviceConnected(callback: (deviceType: DeviceType, deviceSlot: number) => void);
  58734. /**
  58735. * Callback to be triggered when a device is disconnected
  58736. */
  58737. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  58738. /**
  58739. * Callback to be triggered when event driven input is updated
  58740. */
  58741. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  58742. private _inputs;
  58743. private _gamepads;
  58744. private _keyboardActive;
  58745. private _pointerActive;
  58746. private _elementToAttachTo;
  58747. private _keyboardDownEvent;
  58748. private _keyboardUpEvent;
  58749. private _pointerMoveEvent;
  58750. private _pointerDownEvent;
  58751. private _pointerUpEvent;
  58752. private _gamepadConnectedEvent;
  58753. private _gamepadDisconnectedEvent;
  58754. private _onDeviceConnected;
  58755. private static _MAX_KEYCODES;
  58756. private static _MAX_POINTER_INPUTS;
  58757. private constructor();
  58758. /**
  58759. * Creates a new DeviceInputSystem instance
  58760. * @param engine Engine to pull input element from
  58761. * @returns The new instance
  58762. */
  58763. static Create(engine: Engine): DeviceInputSystem;
  58764. /**
  58765. * Checks for current device input value, given an id and input index
  58766. * @param deviceName Id of connected device
  58767. * @param inputIndex Index of device input
  58768. * @returns Current value of input
  58769. */
  58770. /**
  58771. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  58772. * @param deviceType Enum specifiying device type
  58773. * @param deviceSlot "Slot" or index that device is referenced in
  58774. * @param inputIndex Id of input to be checked
  58775. * @returns Current value of input
  58776. */
  58777. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  58778. /**
  58779. * Dispose of all the eventlisteners
  58780. */
  58781. dispose(): void;
  58782. /**
  58783. * Checks for existing connections to devices and register them, if necessary
  58784. * Currently handles gamepads and mouse
  58785. */
  58786. private _checkForConnectedDevices;
  58787. /**
  58788. * Add a gamepad to the DeviceInputSystem
  58789. * @param gamepad A single DOM Gamepad object
  58790. */
  58791. private _addGamePad;
  58792. /**
  58793. * Add pointer device to DeviceInputSystem
  58794. * @param deviceType Type of Pointer to add
  58795. * @param deviceSlot Pointer ID (0 for mouse, pointerId for Touch)
  58796. * @param currentX Current X at point of adding
  58797. * @param currentY Current Y at point of adding
  58798. */
  58799. private _addPointerDevice;
  58800. /**
  58801. * Add device and inputs to device array
  58802. * @param deviceType Enum specifiying device type
  58803. * @param deviceSlot "Slot" or index that device is referenced in
  58804. * @param numberOfInputs Number of input entries to create for given device
  58805. */
  58806. private _registerDevice;
  58807. /**
  58808. * Given a specific device name, remove that device from the device map
  58809. * @param deviceType Enum specifiying device type
  58810. * @param deviceSlot "Slot" or index that device is referenced in
  58811. */
  58812. private _unregisterDevice;
  58813. /**
  58814. * Handle all actions that come from keyboard interaction
  58815. */
  58816. private _handleKeyActions;
  58817. /**
  58818. * Handle all actions that come from pointer interaction
  58819. */
  58820. private _handlePointerActions;
  58821. /**
  58822. * Handle all actions that come from gamepad interaction
  58823. */
  58824. private _handleGamepadActions;
  58825. /**
  58826. * Update all non-event based devices with each frame
  58827. * @param deviceType Enum specifiying device type
  58828. * @param deviceSlot "Slot" or index that device is referenced in
  58829. * @param inputIndex Id of input to be checked
  58830. */
  58831. private _updateDevice;
  58832. /**
  58833. * Gets DeviceType from the device name
  58834. * @param deviceName Name of Device from DeviceInputSystem
  58835. * @returns DeviceType enum value
  58836. */
  58837. private _getGamepadDeviceType;
  58838. }
  58839. }
  58840. declare module BABYLON {
  58841. /**
  58842. * Type to handle enforcement of inputs
  58843. */
  58844. 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;
  58845. }
  58846. declare module BABYLON {
  58847. /**
  58848. * Class that handles all input for a specific device
  58849. */
  58850. export class DeviceSource<T extends DeviceType> {
  58851. /** Type of device */
  58852. readonly deviceType: DeviceType;
  58853. /** "Slot" or index that device is referenced in */
  58854. readonly deviceSlot: number;
  58855. /**
  58856. * Observable to handle device input changes per device
  58857. */
  58858. readonly onInputChangedObservable: Observable<{
  58859. inputIndex: DeviceInput<T>;
  58860. previousState: Nullable<number>;
  58861. currentState: Nullable<number>;
  58862. }>;
  58863. private readonly _deviceInputSystem;
  58864. /**
  58865. * Default Constructor
  58866. * @param deviceInputSystem Reference to DeviceInputSystem
  58867. * @param deviceType Type of device
  58868. * @param deviceSlot "Slot" or index that device is referenced in
  58869. */
  58870. constructor(deviceInputSystem: DeviceInputSystem,
  58871. /** Type of device */
  58872. deviceType: DeviceType,
  58873. /** "Slot" or index that device is referenced in */
  58874. deviceSlot?: number);
  58875. /**
  58876. * Get input for specific input
  58877. * @param inputIndex index of specific input on device
  58878. * @returns Input value from DeviceInputSystem
  58879. */
  58880. getInput(inputIndex: DeviceInput<T>): number;
  58881. }
  58882. /**
  58883. * Class to keep track of devices
  58884. */
  58885. export class DeviceSourceManager implements IDisposable {
  58886. /**
  58887. * Observable to be triggered when after a device is connected, any new observers added will be triggered against already connected devices
  58888. */
  58889. readonly onDeviceConnectedObservable: Observable<DeviceSource<DeviceType>>;
  58890. /**
  58891. * Observable to be triggered when after a device is disconnected
  58892. */
  58893. readonly onDeviceDisconnectedObservable: Observable<DeviceSource<DeviceType>>;
  58894. private readonly _devices;
  58895. private readonly _firstDevice;
  58896. private readonly _deviceInputSystem;
  58897. /**
  58898. * Default Constructor
  58899. * @param engine engine to pull input element from
  58900. */
  58901. constructor(engine: Engine);
  58902. /**
  58903. * Gets a DeviceSource, given a type and slot
  58904. * @param deviceType Enum specifying device type
  58905. * @param deviceSlot "Slot" or index that device is referenced in
  58906. * @returns DeviceSource object
  58907. */
  58908. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  58909. /**
  58910. * Gets an array of DeviceSource objects for a given device type
  58911. * @param deviceType Enum specifying device type
  58912. * @returns Array of DeviceSource objects
  58913. */
  58914. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  58915. /**
  58916. * Returns a read-only list of all available devices
  58917. * @returns Read-only array with active devices
  58918. */
  58919. getDevices(): ReadonlyArray<DeviceSource<DeviceType>>;
  58920. /**
  58921. * Dispose of DeviceInputSystem and other parts
  58922. */
  58923. dispose(): void;
  58924. /**
  58925. * Function to add device name to device list
  58926. * @param deviceType Enum specifying device type
  58927. * @param deviceSlot "Slot" or index that device is referenced in
  58928. */
  58929. private _addDevice;
  58930. /**
  58931. * Function to remove device name to device list
  58932. * @param deviceType Enum specifying device type
  58933. * @param deviceSlot "Slot" or index that device is referenced in
  58934. */
  58935. private _removeDevice;
  58936. /**
  58937. * Updates array storing first connected device of each type
  58938. * @param type Type of Device
  58939. */
  58940. private _updateFirstDevices;
  58941. }
  58942. }
  58943. declare module BABYLON {
  58944. /**
  58945. * Options to create the null engine
  58946. */
  58947. export class NullEngineOptions {
  58948. /**
  58949. * Render width (Default: 512)
  58950. */
  58951. renderWidth: number;
  58952. /**
  58953. * Render height (Default: 256)
  58954. */
  58955. renderHeight: number;
  58956. /**
  58957. * Texture size (Default: 512)
  58958. */
  58959. textureSize: number;
  58960. /**
  58961. * If delta time between frames should be constant
  58962. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58963. */
  58964. deterministicLockstep: boolean;
  58965. /**
  58966. * Maximum about of steps between frames (Default: 4)
  58967. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58968. */
  58969. lockstepMaxSteps: number;
  58970. /**
  58971. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  58972. */
  58973. useHighPrecisionMatrix?: boolean;
  58974. }
  58975. /**
  58976. * The null engine class provides support for headless version of babylon.js.
  58977. * This can be used in server side scenario or for testing purposes
  58978. */
  58979. export class NullEngine extends Engine {
  58980. private _options;
  58981. /**
  58982. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  58983. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58984. * @returns true if engine is in deterministic lock step mode
  58985. */
  58986. isDeterministicLockStep(): boolean;
  58987. /**
  58988. * Gets the max steps when engine is running in deterministic lock step
  58989. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  58990. * @returns the max steps
  58991. */
  58992. getLockstepMaxSteps(): number;
  58993. /**
  58994. * Gets the current hardware scaling level.
  58995. * By default the hardware scaling level is computed from the window device ratio.
  58996. * 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.
  58997. * @returns a number indicating the current hardware scaling level
  58998. */
  58999. getHardwareScalingLevel(): number;
  59000. constructor(options?: NullEngineOptions);
  59001. /**
  59002. * Creates a vertex buffer
  59003. * @param vertices the data for the vertex buffer
  59004. * @returns the new WebGL static buffer
  59005. */
  59006. createVertexBuffer(vertices: FloatArray): DataBuffer;
  59007. /**
  59008. * Creates a new index buffer
  59009. * @param indices defines the content of the index buffer
  59010. * @param updatable defines if the index buffer must be updatable
  59011. * @returns a new webGL buffer
  59012. */
  59013. createIndexBuffer(indices: IndicesArray): DataBuffer;
  59014. /**
  59015. * Clear the current render buffer or the current render target (if any is set up)
  59016. * @param color defines the color to use
  59017. * @param backBuffer defines if the back buffer must be cleared
  59018. * @param depth defines if the depth buffer must be cleared
  59019. * @param stencil defines if the stencil buffer must be cleared
  59020. */
  59021. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59022. /**
  59023. * Gets the current render width
  59024. * @param useScreen defines if screen size must be used (or the current render target if any)
  59025. * @returns a number defining the current render width
  59026. */
  59027. getRenderWidth(useScreen?: boolean): number;
  59028. /**
  59029. * Gets the current render height
  59030. * @param useScreen defines if screen size must be used (or the current render target if any)
  59031. * @returns a number defining the current render height
  59032. */
  59033. getRenderHeight(useScreen?: boolean): number;
  59034. /**
  59035. * Set the WebGL's viewport
  59036. * @param viewport defines the viewport element to be used
  59037. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  59038. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  59039. */
  59040. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59041. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  59042. /**
  59043. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  59044. * @param pipelineContext defines the pipeline context to use
  59045. * @param uniformsNames defines the list of uniform names
  59046. * @returns an array of webGL uniform locations
  59047. */
  59048. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  59049. /**
  59050. * Gets the lsit of active attributes for a given webGL program
  59051. * @param pipelineContext defines the pipeline context to use
  59052. * @param attributesNames defines the list of attribute names to get
  59053. * @returns an array of indices indicating the offset of each attribute
  59054. */
  59055. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59056. /**
  59057. * Binds an effect to the webGL context
  59058. * @param effect defines the effect to bind
  59059. */
  59060. bindSamplers(effect: Effect): void;
  59061. /**
  59062. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  59063. * @param effect defines the effect to activate
  59064. */
  59065. enableEffect(effect: Effect): void;
  59066. /**
  59067. * Set various states to the webGL context
  59068. * @param culling defines backface culling state
  59069. * @param zOffset defines the value to apply to zOffset (0 by default)
  59070. * @param force defines if states must be applied even if cache is up to date
  59071. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  59072. */
  59073. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59074. /**
  59075. * Set the value of an uniform to an array of int32
  59076. * @param uniform defines the webGL uniform location where to store the value
  59077. * @param array defines the array of int32 to store
  59078. * @returns true if value was set
  59079. */
  59080. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59081. /**
  59082. * Set the value of an uniform to an array of int32 (stored as vec2)
  59083. * @param uniform defines the webGL uniform location where to store the value
  59084. * @param array defines the array of int32 to store
  59085. * @returns true if value was set
  59086. */
  59087. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59088. /**
  59089. * Set the value of an uniform to an array of int32 (stored as vec3)
  59090. * @param uniform defines the webGL uniform location where to store the value
  59091. * @param array defines the array of int32 to store
  59092. * @returns true if value was set
  59093. */
  59094. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59095. /**
  59096. * Set the value of an uniform to an array of int32 (stored as vec4)
  59097. * @param uniform defines the webGL uniform location where to store the value
  59098. * @param array defines the array of int32 to store
  59099. * @returns true if value was set
  59100. */
  59101. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59102. /**
  59103. * Set the value of an uniform to an array of float32
  59104. * @param uniform defines the webGL uniform location where to store the value
  59105. * @param array defines the array of float32 to store
  59106. * @returns true if value was set
  59107. */
  59108. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59109. /**
  59110. * Set the value of an uniform to an array of float32 (stored as vec2)
  59111. * @param uniform defines the webGL uniform location where to store the value
  59112. * @param array defines the array of float32 to store
  59113. * @returns true if value was set
  59114. */
  59115. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59116. /**
  59117. * Set the value of an uniform to an array of float32 (stored as vec3)
  59118. * @param uniform defines the webGL uniform location where to store the value
  59119. * @param array defines the array of float32 to store
  59120. * @returns true if value was set
  59121. */
  59122. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59123. /**
  59124. * Set the value of an uniform to an array of float32 (stored as vec4)
  59125. * @param uniform defines the webGL uniform location where to store the value
  59126. * @param array defines the array of float32 to store
  59127. * @returns true if value was set
  59128. */
  59129. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59130. /**
  59131. * Set the value of an uniform to an array of number
  59132. * @param uniform defines the webGL uniform location where to store the value
  59133. * @param array defines the array of number to store
  59134. * @returns true if value was set
  59135. */
  59136. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59137. /**
  59138. * Set the value of an uniform to an array of number (stored as vec2)
  59139. * @param uniform defines the webGL uniform location where to store the value
  59140. * @param array defines the array of number to store
  59141. * @returns true if value was set
  59142. */
  59143. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59144. /**
  59145. * Set the value of an uniform to an array of number (stored as vec3)
  59146. * @param uniform defines the webGL uniform location where to store the value
  59147. * @param array defines the array of number to store
  59148. * @returns true if value was set
  59149. */
  59150. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59151. /**
  59152. * Set the value of an uniform to an array of number (stored as vec4)
  59153. * @param uniform defines the webGL uniform location where to store the value
  59154. * @param array defines the array of number to store
  59155. * @returns true if value was set
  59156. */
  59157. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59158. /**
  59159. * Set the value of an uniform to an array of float32 (stored as matrices)
  59160. * @param uniform defines the webGL uniform location where to store the value
  59161. * @param matrices defines the array of float32 to store
  59162. * @returns true if value was set
  59163. */
  59164. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59165. /**
  59166. * Set the value of an uniform to a matrix (3x3)
  59167. * @param uniform defines the webGL uniform location where to store the value
  59168. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  59169. * @returns true if value was set
  59170. */
  59171. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59172. /**
  59173. * Set the value of an uniform to a matrix (2x2)
  59174. * @param uniform defines the webGL uniform location where to store the value
  59175. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  59176. * @returns true if value was set
  59177. */
  59178. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59179. /**
  59180. * Set the value of an uniform to a number (float)
  59181. * @param uniform defines the webGL uniform location where to store the value
  59182. * @param value defines the float number to store
  59183. * @returns true if value was set
  59184. */
  59185. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59186. /**
  59187. * Set the value of an uniform to a vec2
  59188. * @param uniform defines the webGL uniform location where to store the value
  59189. * @param x defines the 1st component of the value
  59190. * @param y defines the 2nd component of the value
  59191. * @returns true if value was set
  59192. */
  59193. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59194. /**
  59195. * Set the value of an uniform to a vec3
  59196. * @param uniform defines the webGL uniform location where to store the value
  59197. * @param x defines the 1st component of the value
  59198. * @param y defines the 2nd component of the value
  59199. * @param z defines the 3rd component of the value
  59200. * @returns true if value was set
  59201. */
  59202. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59203. /**
  59204. * Set the value of an uniform to a boolean
  59205. * @param uniform defines the webGL uniform location where to store the value
  59206. * @param bool defines the boolean to store
  59207. * @returns true if value was set
  59208. */
  59209. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  59210. /**
  59211. * Set the value of an uniform to a vec4
  59212. * @param uniform defines the webGL uniform location where to store the value
  59213. * @param x defines the 1st component of the value
  59214. * @param y defines the 2nd component of the value
  59215. * @param z defines the 3rd component of the value
  59216. * @param w defines the 4th component of the value
  59217. * @returns true if value was set
  59218. */
  59219. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59220. /**
  59221. * Sets the current alpha mode
  59222. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  59223. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59224. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59225. */
  59226. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59227. /**
  59228. * Bind webGl buffers directly to the webGL context
  59229. * @param vertexBuffers defines the vertex buffer to bind
  59230. * @param indexBuffer defines the index buffer to bind
  59231. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  59232. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  59233. * @param effect defines the effect associated with the vertex buffer
  59234. */
  59235. bindBuffers(vertexBuffers: {
  59236. [key: string]: VertexBuffer;
  59237. }, indexBuffer: DataBuffer, effect: Effect): void;
  59238. /**
  59239. * Force the entire cache to be cleared
  59240. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  59241. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  59242. */
  59243. wipeCaches(bruteForce?: boolean): void;
  59244. /**
  59245. * Send a draw order
  59246. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  59247. * @param indexStart defines the starting index
  59248. * @param indexCount defines the number of index to draw
  59249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59250. */
  59251. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  59252. /**
  59253. * Draw a list of indexed primitives
  59254. * @param fillMode defines the primitive to use
  59255. * @param indexStart defines the starting index
  59256. * @param indexCount defines the number of index to draw
  59257. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59258. */
  59259. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59260. /**
  59261. * Draw a list of unindexed primitives
  59262. * @param fillMode defines the primitive to use
  59263. * @param verticesStart defines the index of first vertex to draw
  59264. * @param verticesCount defines the count of vertices to draw
  59265. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59266. */
  59267. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59268. /** @hidden */
  59269. protected _createTexture(): WebGLTexture;
  59270. /** @hidden */
  59271. _releaseTexture(texture: InternalTexture): void;
  59272. /**
  59273. * Usually called from Texture.ts.
  59274. * Passed information to create a WebGLTexture
  59275. * @param urlArg defines a value which contains one of the following:
  59276. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59277. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59278. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59279. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59280. * @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)
  59281. * @param scene needed for loading to the correct scene
  59282. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59283. * @param onLoad optional callback to be called upon successful completion
  59284. * @param onError optional callback to be called upon failure
  59285. * @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
  59286. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59287. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59288. * @param forcedExtension defines the extension to use to pick the right loader
  59289. * @param mimeType defines an optional mime type
  59290. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59291. */
  59292. 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;
  59293. /**
  59294. * Creates a new render target texture
  59295. * @param size defines the size of the texture
  59296. * @param options defines the options used to create the texture
  59297. * @returns a new render target texture stored in an InternalTexture
  59298. */
  59299. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  59300. /**
  59301. * Update the sampling mode of a given texture
  59302. * @param samplingMode defines the required sampling mode
  59303. * @param texture defines the texture to update
  59304. */
  59305. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59306. /**
  59307. * Binds the frame buffer to the specified texture.
  59308. * @param texture The texture to render to or null for the default canvas
  59309. * @param faceIndex The face of the texture to render to in case of cube texture
  59310. * @param requiredWidth The width of the target to render to
  59311. * @param requiredHeight The height of the target to render to
  59312. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  59313. * @param lodLevel defines le lod level to bind to the frame buffer
  59314. */
  59315. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  59316. /**
  59317. * Unbind the current render target texture from the webGL context
  59318. * @param texture defines the render target texture to unbind
  59319. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  59320. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  59321. */
  59322. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  59323. /**
  59324. * Creates a dynamic vertex buffer
  59325. * @param vertices the data for the dynamic vertex buffer
  59326. * @returns the new WebGL dynamic buffer
  59327. */
  59328. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  59329. /**
  59330. * Update the content of a dynamic texture
  59331. * @param texture defines the texture to update
  59332. * @param canvas defines the canvas containing the source
  59333. * @param invertY defines if data must be stored with Y axis inverted
  59334. * @param premulAlpha defines if alpha is stored as premultiplied
  59335. * @param format defines the format of the data
  59336. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59337. */
  59338. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59339. /**
  59340. * Gets a boolean indicating if all created effects are ready
  59341. * @returns true if all effects are ready
  59342. */
  59343. areAllEffectsReady(): boolean;
  59344. /**
  59345. * @hidden
  59346. * Get the current error code of the webGL context
  59347. * @returns the error code
  59348. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  59349. */
  59350. getError(): number;
  59351. /** @hidden */
  59352. _getUnpackAlignement(): number;
  59353. /** @hidden */
  59354. _unpackFlipY(value: boolean): void;
  59355. /**
  59356. * Update a dynamic index buffer
  59357. * @param indexBuffer defines the target index buffer
  59358. * @param indices defines the data to update
  59359. * @param offset defines the offset in the target index buffer where update should start
  59360. */
  59361. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  59362. /**
  59363. * Updates a dynamic vertex buffer.
  59364. * @param vertexBuffer the vertex buffer to update
  59365. * @param vertices the data used to update the vertex buffer
  59366. * @param byteOffset the byte offset of the data (optional)
  59367. * @param byteLength the byte length of the data (optional)
  59368. */
  59369. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  59370. /** @hidden */
  59371. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  59372. /** @hidden */
  59373. _bindTexture(channel: number, texture: InternalTexture): void;
  59374. protected _deleteBuffer(buffer: WebGLBuffer): void;
  59375. /**
  59376. * 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
  59377. */
  59378. releaseEffects(): void;
  59379. displayLoadingUI(): void;
  59380. hideLoadingUI(): void;
  59381. /** @hidden */
  59382. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59383. /** @hidden */
  59384. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59385. /** @hidden */
  59386. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  59387. /** @hidden */
  59388. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  59389. }
  59390. }
  59391. declare module BABYLON {
  59392. /** @hidden */
  59393. export class _OcclusionDataStorage {
  59394. /** @hidden */
  59395. occlusionInternalRetryCounter: number;
  59396. /** @hidden */
  59397. isOcclusionQueryInProgress: boolean;
  59398. /** @hidden */
  59399. isOccluded: boolean;
  59400. /** @hidden */
  59401. occlusionRetryCount: number;
  59402. /** @hidden */
  59403. occlusionType: number;
  59404. /** @hidden */
  59405. occlusionQueryAlgorithmType: number;
  59406. }
  59407. interface Engine {
  59408. /**
  59409. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  59410. * @return the new query
  59411. */
  59412. createQuery(): WebGLQuery;
  59413. /**
  59414. * Delete and release a webGL query
  59415. * @param query defines the query to delete
  59416. * @return the current engine
  59417. */
  59418. deleteQuery(query: WebGLQuery): Engine;
  59419. /**
  59420. * Check if a given query has resolved and got its value
  59421. * @param query defines the query to check
  59422. * @returns true if the query got its value
  59423. */
  59424. isQueryResultAvailable(query: WebGLQuery): boolean;
  59425. /**
  59426. * Gets the value of a given query
  59427. * @param query defines the query to check
  59428. * @returns the value of the query
  59429. */
  59430. getQueryResult(query: WebGLQuery): number;
  59431. /**
  59432. * Initiates an occlusion query
  59433. * @param algorithmType defines the algorithm to use
  59434. * @param query defines the query to use
  59435. * @returns the current engine
  59436. * @see https://doc.babylonjs.com/features/occlusionquery
  59437. */
  59438. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  59439. /**
  59440. * Ends an occlusion query
  59441. * @see https://doc.babylonjs.com/features/occlusionquery
  59442. * @param algorithmType defines the algorithm to use
  59443. * @returns the current engine
  59444. */
  59445. endOcclusionQuery(algorithmType: number): Engine;
  59446. /**
  59447. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  59448. * Please note that only one query can be issued at a time
  59449. * @returns a time token used to track the time span
  59450. */
  59451. startTimeQuery(): Nullable<_TimeToken>;
  59452. /**
  59453. * Ends a time query
  59454. * @param token defines the token used to measure the time span
  59455. * @returns the time spent (in ns)
  59456. */
  59457. endTimeQuery(token: _TimeToken): int;
  59458. /** @hidden */
  59459. _currentNonTimestampToken: Nullable<_TimeToken>;
  59460. /** @hidden */
  59461. _createTimeQuery(): WebGLQuery;
  59462. /** @hidden */
  59463. _deleteTimeQuery(query: WebGLQuery): void;
  59464. /** @hidden */
  59465. _getGlAlgorithmType(algorithmType: number): number;
  59466. /** @hidden */
  59467. _getTimeQueryResult(query: WebGLQuery): any;
  59468. /** @hidden */
  59469. _getTimeQueryAvailability(query: WebGLQuery): any;
  59470. }
  59471. interface AbstractMesh {
  59472. /**
  59473. * Backing filed
  59474. * @hidden
  59475. */
  59476. __occlusionDataStorage: _OcclusionDataStorage;
  59477. /**
  59478. * Access property
  59479. * @hidden
  59480. */
  59481. _occlusionDataStorage: _OcclusionDataStorage;
  59482. /**
  59483. * 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 decideds to show or hide the object.
  59484. * The default value is -1 which means don't break the query and wait till the result
  59485. * @see https://doc.babylonjs.com/features/occlusionquery
  59486. */
  59487. occlusionRetryCount: number;
  59488. /**
  59489. * 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:
  59490. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  59491. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  59492. * * 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.
  59493. * @see https://doc.babylonjs.com/features/occlusionquery
  59494. */
  59495. occlusionType: number;
  59496. /**
  59497. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  59498. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  59499. * * 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.
  59500. * @see https://doc.babylonjs.com/features/occlusionquery
  59501. */
  59502. occlusionQueryAlgorithmType: number;
  59503. /**
  59504. * Gets or sets whether the mesh is occluded or not, it is used also to set the intial state of the mesh to be occluded or not
  59505. * @see https://doc.babylonjs.com/features/occlusionquery
  59506. */
  59507. isOccluded: boolean;
  59508. /**
  59509. * Flag to check the progress status of the query
  59510. * @see https://doc.babylonjs.com/features/occlusionquery
  59511. */
  59512. isOcclusionQueryInProgress: boolean;
  59513. }
  59514. }
  59515. declare module BABYLON {
  59516. /** @hidden */
  59517. export var _forceTransformFeedbackToBundle: boolean;
  59518. interface Engine {
  59519. /**
  59520. * Creates a webGL transform feedback object
  59521. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  59522. * @returns the webGL transform feedback object
  59523. */
  59524. createTransformFeedback(): WebGLTransformFeedback;
  59525. /**
  59526. * Delete a webGL transform feedback object
  59527. * @param value defines the webGL transform feedback object to delete
  59528. */
  59529. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  59530. /**
  59531. * Bind a webGL transform feedback object to the webgl context
  59532. * @param value defines the webGL transform feedback object to bind
  59533. */
  59534. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  59535. /**
  59536. * Begins a transform feedback operation
  59537. * @param usePoints defines if points or triangles must be used
  59538. */
  59539. beginTransformFeedback(usePoints: boolean): void;
  59540. /**
  59541. * Ends a transform feedback operation
  59542. */
  59543. endTransformFeedback(): void;
  59544. /**
  59545. * Specify the varyings to use with transform feedback
  59546. * @param program defines the associated webGL program
  59547. * @param value defines the list of strings representing the varying names
  59548. */
  59549. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  59550. /**
  59551. * Bind a webGL buffer for a transform feedback operation
  59552. * @param value defines the webGL buffer to bind
  59553. */
  59554. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  59555. }
  59556. }
  59557. declare module BABYLON {
  59558. /**
  59559. * Class used to define an additional view for the engine
  59560. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59561. */
  59562. export class EngineView {
  59563. /** Defines the canvas where to render the view */
  59564. target: HTMLCanvasElement;
  59565. /** Defines an optional camera used to render the view (will use active camera else) */
  59566. camera?: Camera;
  59567. }
  59568. interface Engine {
  59569. /**
  59570. * Gets or sets the HTML element to use for attaching events
  59571. */
  59572. inputElement: Nullable<HTMLElement>;
  59573. /**
  59574. * Gets the current engine view
  59575. * @see https://doc.babylonjs.com/how_to/multi_canvases
  59576. */
  59577. activeView: Nullable<EngineView>;
  59578. /** Gets or sets the list of views */
  59579. views: EngineView[];
  59580. /**
  59581. * Register a new child canvas
  59582. * @param canvas defines the canvas to register
  59583. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  59584. * @returns the associated view
  59585. */
  59586. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  59587. /**
  59588. * Remove a registered child canvas
  59589. * @param canvas defines the canvas to remove
  59590. * @returns the current engine
  59591. */
  59592. unRegisterView(canvas: HTMLCanvasElement): Engine;
  59593. }
  59594. }
  59595. declare module BABYLON {
  59596. interface Engine {
  59597. /** @hidden */
  59598. _excludedCompressedTextures: string[];
  59599. /** @hidden */
  59600. _textureFormatInUse: string;
  59601. /**
  59602. * Gets the list of texture formats supported
  59603. */
  59604. readonly texturesSupported: Array<string>;
  59605. /**
  59606. * Gets the texture format in use
  59607. */
  59608. readonly textureFormatInUse: Nullable<string>;
  59609. /**
  59610. * Set the compressed texture extensions or file names to skip.
  59611. *
  59612. * @param skippedFiles defines the list of those texture files you want to skip
  59613. * Example: [".dds", ".env", "myfile.png"]
  59614. */
  59615. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  59616. /**
  59617. * Set the compressed texture format to use, based on the formats you have, and the formats
  59618. * supported by the hardware / browser.
  59619. *
  59620. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  59621. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  59622. * to API arguments needed to compressed textures. This puts the burden on the container
  59623. * generator to house the arcane code for determining these for current & future formats.
  59624. *
  59625. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59626. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59627. *
  59628. * Note: The result of this call is not taken into account when a texture is base64.
  59629. *
  59630. * @param formatsAvailable defines the list of those format families you have created
  59631. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  59632. *
  59633. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  59634. * @returns The extension selected.
  59635. */
  59636. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  59637. }
  59638. }
  59639. declare module BABYLON {
  59640. /** @hidden */
  59641. export var rgbdEncodePixelShader: {
  59642. name: string;
  59643. shader: string;
  59644. };
  59645. }
  59646. declare module BABYLON {
  59647. /**
  59648. * Raw texture data and descriptor sufficient for WebGL texture upload
  59649. */
  59650. export interface EnvironmentTextureInfo {
  59651. /**
  59652. * Version of the environment map
  59653. */
  59654. version: number;
  59655. /**
  59656. * Width of image
  59657. */
  59658. width: number;
  59659. /**
  59660. * Irradiance information stored in the file.
  59661. */
  59662. irradiance: any;
  59663. /**
  59664. * Specular information stored in the file.
  59665. */
  59666. specular: any;
  59667. }
  59668. /**
  59669. * Defines One Image in the file. It requires only the position in the file
  59670. * as well as the length.
  59671. */
  59672. interface BufferImageData {
  59673. /**
  59674. * Length of the image data.
  59675. */
  59676. length: number;
  59677. /**
  59678. * Position of the data from the null terminator delimiting the end of the JSON.
  59679. */
  59680. position: number;
  59681. }
  59682. /**
  59683. * Defines the specular data enclosed in the file.
  59684. * This corresponds to the version 1 of the data.
  59685. */
  59686. export interface EnvironmentTextureSpecularInfoV1 {
  59687. /**
  59688. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  59689. */
  59690. specularDataPosition?: number;
  59691. /**
  59692. * This contains all the images data needed to reconstruct the cubemap.
  59693. */
  59694. mipmaps: Array<BufferImageData>;
  59695. /**
  59696. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  59697. */
  59698. lodGenerationScale: number;
  59699. }
  59700. /**
  59701. * Sets of helpers addressing the serialization and deserialization of environment texture
  59702. * stored in a BabylonJS env file.
  59703. * Those files are usually stored as .env files.
  59704. */
  59705. export class EnvironmentTextureTools {
  59706. /**
  59707. * Magic number identifying the env file.
  59708. */
  59709. private static _MagicBytes;
  59710. /**
  59711. * Gets the environment info from an env file.
  59712. * @param data The array buffer containing the .env bytes.
  59713. * @returns the environment file info (the json header) if successfully parsed.
  59714. */
  59715. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  59716. /**
  59717. * Creates an environment texture from a loaded cube texture.
  59718. * @param texture defines the cube texture to convert in env file
  59719. * @return a promise containing the environment data if succesfull.
  59720. */
  59721. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  59722. /**
  59723. * Creates a JSON representation of the spherical data.
  59724. * @param texture defines the texture containing the polynomials
  59725. * @return the JSON representation of the spherical info
  59726. */
  59727. private static _CreateEnvTextureIrradiance;
  59728. /**
  59729. * Creates the ArrayBufferViews used for initializing environment texture image data.
  59730. * @param data the image data
  59731. * @param info parameters that determine what views will be created for accessing the underlying buffer
  59732. * @return the views described by info providing access to the underlying buffer
  59733. */
  59734. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  59735. /**
  59736. * Uploads the texture info contained in the env file to the GPU.
  59737. * @param texture defines the internal texture to upload to
  59738. * @param data defines the data to load
  59739. * @param info defines the texture info retrieved through the GetEnvInfo method
  59740. * @returns a promise
  59741. */
  59742. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  59743. private static _OnImageReadyAsync;
  59744. /**
  59745. * Uploads the levels of image data to the GPU.
  59746. * @param texture defines the internal texture to upload to
  59747. * @param imageData defines the array buffer views of image data [mipmap][face]
  59748. * @returns a promise
  59749. */
  59750. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  59751. /**
  59752. * Uploads spherical polynomials information to the texture.
  59753. * @param texture defines the texture we are trying to upload the information to
  59754. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  59755. */
  59756. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  59757. /** @hidden */
  59758. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59759. }
  59760. }
  59761. declare module BABYLON {
  59762. /**
  59763. * Container for accessors for natively-stored mesh data buffers.
  59764. */
  59765. class NativeDataBuffer extends DataBuffer {
  59766. /**
  59767. * Accessor value used to identify/retrieve a natively-stored index buffer.
  59768. */
  59769. nativeIndexBuffer?: any;
  59770. /**
  59771. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  59772. */
  59773. nativeVertexBuffer?: any;
  59774. }
  59775. /** @hidden */
  59776. class NativeTexture extends InternalTexture {
  59777. getInternalTexture(): InternalTexture;
  59778. getViewCount(): number;
  59779. }
  59780. /** @hidden */
  59781. export class NativeEngine extends Engine {
  59782. private readonly _native;
  59783. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  59784. private readonly INVALID_HANDLE;
  59785. private _boundBuffersVertexArray;
  59786. private _currentDepthTest;
  59787. getHardwareScalingLevel(): number;
  59788. constructor();
  59789. dispose(): void;
  59790. /**
  59791. * Can be used to override the current requestAnimationFrame requester.
  59792. * @hidden
  59793. */
  59794. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  59795. /**
  59796. * Override default engine behavior.
  59797. * @param color
  59798. * @param backBuffer
  59799. * @param depth
  59800. * @param stencil
  59801. */
  59802. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  59803. /**
  59804. * Gets host document
  59805. * @returns the host document object
  59806. */
  59807. getHostDocument(): Nullable<Document>;
  59808. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  59809. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  59810. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  59811. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  59812. [key: string]: VertexBuffer;
  59813. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59814. bindBuffers(vertexBuffers: {
  59815. [key: string]: VertexBuffer;
  59816. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  59817. recordVertexArrayObject(vertexBuffers: {
  59818. [key: string]: VertexBuffer;
  59819. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  59820. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59821. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  59822. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  59823. /**
  59824. * Draw a list of indexed primitives
  59825. * @param fillMode defines the primitive to use
  59826. * @param indexStart defines the starting index
  59827. * @param indexCount defines the number of index to draw
  59828. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59829. */
  59830. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  59831. /**
  59832. * Draw a list of unindexed primitives
  59833. * @param fillMode defines the primitive to use
  59834. * @param verticesStart defines the index of first vertex to draw
  59835. * @param verticesCount defines the count of vertices to draw
  59836. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  59837. */
  59838. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  59839. createPipelineContext(): IPipelineContext;
  59840. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rawVertexSourceCode: string, rawFragmentSourceCode: string, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  59841. /** @hidden */
  59842. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  59843. /** @hidden */
  59844. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  59845. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59846. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  59847. protected _setProgram(program: WebGLProgram): void;
  59848. _releaseEffect(effect: Effect): void;
  59849. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  59850. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  59851. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  59852. bindSamplers(effect: Effect): void;
  59853. setMatrix(uniform: WebGLUniformLocation, matrix: IMatrixLike): void;
  59854. getRenderWidth(useScreen?: boolean): number;
  59855. getRenderHeight(useScreen?: boolean): number;
  59856. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  59857. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  59858. /**
  59859. * Set the z offset to apply to current rendering
  59860. * @param value defines the offset to apply
  59861. */
  59862. setZOffset(value: number): void;
  59863. /**
  59864. * Gets the current value of the zOffset
  59865. * @returns the current zOffset state
  59866. */
  59867. getZOffset(): number;
  59868. /**
  59869. * Enable or disable depth buffering
  59870. * @param enable defines the state to set
  59871. */
  59872. setDepthBuffer(enable: boolean): void;
  59873. /**
  59874. * Gets a boolean indicating if depth writing is enabled
  59875. * @returns the current depth writing state
  59876. */
  59877. getDepthWrite(): boolean;
  59878. setDepthFunctionToGreater(): void;
  59879. setDepthFunctionToGreaterOrEqual(): void;
  59880. setDepthFunctionToLess(): void;
  59881. setDepthFunctionToLessOrEqual(): void;
  59882. /**
  59883. * Enable or disable depth writing
  59884. * @param enable defines the state to set
  59885. */
  59886. setDepthWrite(enable: boolean): void;
  59887. /**
  59888. * Enable or disable color writing
  59889. * @param enable defines the state to set
  59890. */
  59891. setColorWrite(enable: boolean): void;
  59892. /**
  59893. * Gets a boolean indicating if color writing is enabled
  59894. * @returns the current color writing state
  59895. */
  59896. getColorWrite(): boolean;
  59897. /**
  59898. * Sets alpha constants used by some alpha blending modes
  59899. * @param r defines the red component
  59900. * @param g defines the green component
  59901. * @param b defines the blue component
  59902. * @param a defines the alpha component
  59903. */
  59904. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  59905. /**
  59906. * Sets the current alpha mode
  59907. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  59908. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  59909. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59910. */
  59911. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  59912. /**
  59913. * Gets the current alpha mode
  59914. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  59915. * @returns the current alpha mode
  59916. */
  59917. getAlphaMode(): number;
  59918. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  59919. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59920. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59921. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59922. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  59923. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59924. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59925. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59926. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  59927. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  59928. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  59929. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  59930. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  59931. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  59932. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59933. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  59934. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  59935. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  59936. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  59937. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  59938. setColor3(uniform: WebGLUniformLocation, color3: IColor3Like): boolean;
  59939. setColor4(uniform: WebGLUniformLocation, color3: IColor3Like, alpha: number): boolean;
  59940. wipeCaches(bruteForce?: boolean): void;
  59941. protected _createTexture(): WebGLTexture;
  59942. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  59943. /**
  59944. * Update the content of a dynamic texture
  59945. * @param texture defines the texture to update
  59946. * @param canvas defines the canvas containing the source
  59947. * @param invertY defines if data must be stored with Y axis inverted
  59948. * @param premulAlpha defines if alpha is stored as premultiplied
  59949. * @param format defines the format of the data
  59950. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  59951. */
  59952. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  59953. /**
  59954. * Usually called from Texture.ts.
  59955. * Passed information to create a WebGLTexture
  59956. * @param url defines a value which contains one of the following:
  59957. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  59958. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  59959. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  59960. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  59961. * @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)
  59962. * @param scene needed for loading to the correct scene
  59963. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  59964. * @param onLoad optional callback to be called upon successful completion
  59965. * @param onError optional callback to be called upon failure
  59966. * @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
  59967. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  59968. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  59969. * @param forcedExtension defines the extension to use to pick the right loader
  59970. * @param mimeType defines an optional mime type
  59971. * @param loaderOptions options to be passed to the loader
  59972. * @returns a InternalTexture for assignment back into BABYLON.Texture
  59973. */
  59974. 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;
  59975. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  59976. _releaseFramebufferObjects(texture: InternalTexture): void;
  59977. /**
  59978. * Creates a cube texture
  59979. * @param rootUrl defines the url where the files to load is located
  59980. * @param scene defines the current scene
  59981. * @param files defines the list of files to load (1 per face)
  59982. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  59983. * @param onLoad defines an optional callback raised when the texture is loaded
  59984. * @param onError defines an optional callback raised if there is an issue to load the texture
  59985. * @param format defines the format of the data
  59986. * @param forcedExtension defines the extension to use to pick the right loader
  59987. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  59988. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59989. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59990. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  59991. * @returns the cube texture as an InternalTexture
  59992. */
  59993. 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;
  59994. createRenderTargetTexture(size: number | {
  59995. width: number;
  59996. height: number;
  59997. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  59998. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  59999. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  60000. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  60001. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  60002. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  60003. /**
  60004. * Updates a dynamic vertex buffer.
  60005. * @param vertexBuffer the vertex buffer to update
  60006. * @param data the data used to update the vertex buffer
  60007. * @param byteOffset the byte offset of the data (optional)
  60008. * @param byteLength the byte length of the data (optional)
  60009. */
  60010. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  60011. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  60012. private _updateAnisotropicLevel;
  60013. private _getAddressMode;
  60014. /** @hidden */
  60015. _bindTexture(channel: number, texture: InternalTexture): void;
  60016. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  60017. releaseEffects(): void;
  60018. /** @hidden */
  60019. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60020. /** @hidden */
  60021. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60022. /** @hidden */
  60023. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  60024. /** @hidden */
  60025. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  60026. private _getNativeSamplingMode;
  60027. private _getNativeTextureFormat;
  60028. private _getNativeAlphaMode;
  60029. private _getNativeAttribType;
  60030. }
  60031. }
  60032. declare module BABYLON {
  60033. /**
  60034. * Helper class to create the best engine depending on the current hardware
  60035. */
  60036. export class EngineFactory {
  60037. /**
  60038. * Creates an engine based on the capabilities of the underlying hardware
  60039. * @param canvas Defines the canvas to use to display the result
  60040. * @param options Defines the options passed to the engine to create the context dependencies
  60041. * @returns a promise that resolves with the created engine
  60042. */
  60043. static CreateAsync(canvas: HTMLCanvasElement, options: any): Promise<ThinEngine>;
  60044. }
  60045. }
  60046. declare module BABYLON {
  60047. /**
  60048. * Gather the list of clipboard event types as constants.
  60049. */
  60050. export class ClipboardEventTypes {
  60051. /**
  60052. * The clipboard event is fired when a copy command is active (pressed).
  60053. */
  60054. static readonly COPY: number;
  60055. /**
  60056. * The clipboard event is fired when a cut command is active (pressed).
  60057. */
  60058. static readonly CUT: number;
  60059. /**
  60060. * The clipboard event is fired when a paste command is active (pressed).
  60061. */
  60062. static readonly PASTE: number;
  60063. }
  60064. /**
  60065. * This class is used to store clipboard related info for the onClipboardObservable event.
  60066. */
  60067. export class ClipboardInfo {
  60068. /**
  60069. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60070. */
  60071. type: number;
  60072. /**
  60073. * Defines the related dom event
  60074. */
  60075. event: ClipboardEvent;
  60076. /**
  60077. *Creates an instance of ClipboardInfo.
  60078. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  60079. * @param event Defines the related dom event
  60080. */
  60081. constructor(
  60082. /**
  60083. * Defines the type of event (BABYLON.ClipboardEventTypes)
  60084. */
  60085. type: number,
  60086. /**
  60087. * Defines the related dom event
  60088. */
  60089. event: ClipboardEvent);
  60090. /**
  60091. * Get the clipboard event's type from the keycode.
  60092. * @param keyCode Defines the keyCode for the current keyboard event.
  60093. * @return {number}
  60094. */
  60095. static GetTypeFromCharacter(keyCode: number): number;
  60096. }
  60097. }
  60098. declare module BABYLON {
  60099. /**
  60100. * Google Daydream controller
  60101. */
  60102. export class DaydreamController extends WebVRController {
  60103. /**
  60104. * Base Url for the controller model.
  60105. */
  60106. static MODEL_BASE_URL: string;
  60107. /**
  60108. * File name for the controller model.
  60109. */
  60110. static MODEL_FILENAME: string;
  60111. /**
  60112. * Gamepad Id prefix used to identify Daydream Controller.
  60113. */
  60114. static readonly GAMEPAD_ID_PREFIX: string;
  60115. /**
  60116. * Creates a new DaydreamController from a gamepad
  60117. * @param vrGamepad the gamepad that the controller should be created from
  60118. */
  60119. constructor(vrGamepad: any);
  60120. /**
  60121. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60122. * @param scene scene in which to add meshes
  60123. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60124. */
  60125. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60126. /**
  60127. * Called once for each button that changed state since the last frame
  60128. * @param buttonIdx Which button index changed
  60129. * @param state New state of the button
  60130. * @param changes Which properties on the state changed since last frame
  60131. */
  60132. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60133. }
  60134. }
  60135. declare module BABYLON {
  60136. /**
  60137. * Gear VR Controller
  60138. */
  60139. export class GearVRController extends WebVRController {
  60140. /**
  60141. * Base Url for the controller model.
  60142. */
  60143. static MODEL_BASE_URL: string;
  60144. /**
  60145. * File name for the controller model.
  60146. */
  60147. static MODEL_FILENAME: string;
  60148. /**
  60149. * Gamepad Id prefix used to identify this controller.
  60150. */
  60151. static readonly GAMEPAD_ID_PREFIX: string;
  60152. private readonly _buttonIndexToObservableNameMap;
  60153. /**
  60154. * Creates a new GearVRController from a gamepad
  60155. * @param vrGamepad the gamepad that the controller should be created from
  60156. */
  60157. constructor(vrGamepad: any);
  60158. /**
  60159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60160. * @param scene scene in which to add meshes
  60161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60162. */
  60163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60164. /**
  60165. * Called once for each button that changed state since the last frame
  60166. * @param buttonIdx Which button index changed
  60167. * @param state New state of the button
  60168. * @param changes Which properties on the state changed since last frame
  60169. */
  60170. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60171. }
  60172. }
  60173. declare module BABYLON {
  60174. /**
  60175. * Generic Controller
  60176. */
  60177. export class GenericController extends WebVRController {
  60178. /**
  60179. * Base Url for the controller model.
  60180. */
  60181. static readonly MODEL_BASE_URL: string;
  60182. /**
  60183. * File name for the controller model.
  60184. */
  60185. static readonly MODEL_FILENAME: string;
  60186. /**
  60187. * Creates a new GenericController from a gamepad
  60188. * @param vrGamepad the gamepad that the controller should be created from
  60189. */
  60190. constructor(vrGamepad: any);
  60191. /**
  60192. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60193. * @param scene scene in which to add meshes
  60194. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60195. */
  60196. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60197. /**
  60198. * Called once for each button that changed state since the last frame
  60199. * @param buttonIdx Which button index changed
  60200. * @param state New state of the button
  60201. * @param changes Which properties on the state changed since last frame
  60202. */
  60203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60204. }
  60205. }
  60206. declare module BABYLON {
  60207. /**
  60208. * Oculus Touch Controller
  60209. */
  60210. export class OculusTouchController extends WebVRController {
  60211. /**
  60212. * Base Url for the controller model.
  60213. */
  60214. static MODEL_BASE_URL: string;
  60215. /**
  60216. * File name for the left controller model.
  60217. */
  60218. static MODEL_LEFT_FILENAME: string;
  60219. /**
  60220. * File name for the right controller model.
  60221. */
  60222. static MODEL_RIGHT_FILENAME: string;
  60223. /**
  60224. * Base Url for the Quest controller model.
  60225. */
  60226. static QUEST_MODEL_BASE_URL: string;
  60227. /**
  60228. * @hidden
  60229. * If the controllers are running on a device that needs the updated Quest controller models
  60230. */
  60231. static _IsQuest: boolean;
  60232. /**
  60233. * Fired when the secondary trigger on this controller is modified
  60234. */
  60235. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  60236. /**
  60237. * Fired when the thumb rest on this controller is modified
  60238. */
  60239. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  60240. /**
  60241. * Creates a new OculusTouchController from a gamepad
  60242. * @param vrGamepad the gamepad that the controller should be created from
  60243. */
  60244. constructor(vrGamepad: any);
  60245. /**
  60246. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60247. * @param scene scene in which to add meshes
  60248. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60249. */
  60250. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60251. /**
  60252. * Fired when the A button on this controller is modified
  60253. */
  60254. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60255. /**
  60256. * Fired when the B button on this controller is modified
  60257. */
  60258. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60259. /**
  60260. * Fired when the X button on this controller is modified
  60261. */
  60262. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60263. /**
  60264. * Fired when the Y button on this controller is modified
  60265. */
  60266. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60267. /**
  60268. * Called once for each button that changed state since the last frame
  60269. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  60270. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  60271. * 2) secondary trigger (same)
  60272. * 3) A (right) X (left), touch, pressed = value
  60273. * 4) B / Y
  60274. * 5) thumb rest
  60275. * @param buttonIdx Which button index changed
  60276. * @param state New state of the button
  60277. * @param changes Which properties on the state changed since last frame
  60278. */
  60279. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60280. }
  60281. }
  60282. declare module BABYLON {
  60283. /**
  60284. * Vive Controller
  60285. */
  60286. export class ViveController extends WebVRController {
  60287. /**
  60288. * Base Url for the controller model.
  60289. */
  60290. static MODEL_BASE_URL: string;
  60291. /**
  60292. * File name for the controller model.
  60293. */
  60294. static MODEL_FILENAME: string;
  60295. /**
  60296. * Creates a new ViveController from a gamepad
  60297. * @param vrGamepad the gamepad that the controller should be created from
  60298. */
  60299. constructor(vrGamepad: any);
  60300. /**
  60301. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60302. * @param scene scene in which to add meshes
  60303. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60304. */
  60305. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  60306. /**
  60307. * Fired when the left button on this controller is modified
  60308. */
  60309. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60310. /**
  60311. * Fired when the right button on this controller is modified
  60312. */
  60313. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60314. /**
  60315. * Fired when the menu button on this controller is modified
  60316. */
  60317. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60318. /**
  60319. * Called once for each button that changed state since the last frame
  60320. * Vive mapping:
  60321. * 0: touchpad
  60322. * 1: trigger
  60323. * 2: left AND right buttons
  60324. * 3: menu button
  60325. * @param buttonIdx Which button index changed
  60326. * @param state New state of the button
  60327. * @param changes Which properties on the state changed since last frame
  60328. */
  60329. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60330. }
  60331. }
  60332. declare module BABYLON {
  60333. /**
  60334. * Defines the WindowsMotionController object that the state of the windows motion controller
  60335. */
  60336. export class WindowsMotionController extends WebVRController {
  60337. /**
  60338. * The base url used to load the left and right controller models
  60339. */
  60340. static MODEL_BASE_URL: string;
  60341. /**
  60342. * The name of the left controller model file
  60343. */
  60344. static MODEL_LEFT_FILENAME: string;
  60345. /**
  60346. * The name of the right controller model file
  60347. */
  60348. static MODEL_RIGHT_FILENAME: string;
  60349. /**
  60350. * The controller name prefix for this controller type
  60351. */
  60352. static readonly GAMEPAD_ID_PREFIX: string;
  60353. /**
  60354. * The controller id pattern for this controller type
  60355. */
  60356. private static readonly GAMEPAD_ID_PATTERN;
  60357. private _loadedMeshInfo;
  60358. protected readonly _mapping: {
  60359. buttons: string[];
  60360. buttonMeshNames: {
  60361. trigger: string;
  60362. menu: string;
  60363. grip: string;
  60364. thumbstick: string;
  60365. trackpad: string;
  60366. };
  60367. buttonObservableNames: {
  60368. trigger: string;
  60369. menu: string;
  60370. grip: string;
  60371. thumbstick: string;
  60372. trackpad: string;
  60373. };
  60374. axisMeshNames: string[];
  60375. pointingPoseMeshName: string;
  60376. };
  60377. /**
  60378. * Fired when the trackpad on this controller is clicked
  60379. */
  60380. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60381. /**
  60382. * Fired when the trackpad on this controller is modified
  60383. */
  60384. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60385. /**
  60386. * The current x and y values of this controller's trackpad
  60387. */
  60388. trackpad: StickValues;
  60389. /**
  60390. * Creates a new WindowsMotionController from a gamepad
  60391. * @param vrGamepad the gamepad that the controller should be created from
  60392. */
  60393. constructor(vrGamepad: any);
  60394. /**
  60395. * Fired when the trigger on this controller is modified
  60396. */
  60397. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60398. /**
  60399. * Fired when the menu button on this controller is modified
  60400. */
  60401. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60402. /**
  60403. * Fired when the grip button on this controller is modified
  60404. */
  60405. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60406. /**
  60407. * Fired when the thumbstick button on this controller is modified
  60408. */
  60409. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60410. /**
  60411. * Fired when the touchpad button on this controller is modified
  60412. */
  60413. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60414. /**
  60415. * Fired when the touchpad values on this controller are modified
  60416. */
  60417. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  60418. protected _updateTrackpad(): void;
  60419. /**
  60420. * Called once per frame by the engine.
  60421. */
  60422. update(): void;
  60423. /**
  60424. * Called once for each button that changed state since the last frame
  60425. * @param buttonIdx Which button index changed
  60426. * @param state New state of the button
  60427. * @param changes Which properties on the state changed since last frame
  60428. */
  60429. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  60430. /**
  60431. * Moves the buttons on the controller mesh based on their current state
  60432. * @param buttonName the name of the button to move
  60433. * @param buttonValue the value of the button which determines the buttons new position
  60434. */
  60435. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  60436. /**
  60437. * Moves the axis on the controller mesh based on its current state
  60438. * @param axis the index of the axis
  60439. * @param axisValue the value of the axis which determines the meshes new position
  60440. * @hidden
  60441. */
  60442. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  60443. /**
  60444. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  60445. * @param scene scene in which to add meshes
  60446. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  60447. */
  60448. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  60449. /**
  60450. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  60451. * can be transformed by button presses and axes values, based on this._mapping.
  60452. *
  60453. * @param scene scene in which the meshes exist
  60454. * @param meshes list of meshes that make up the controller model to process
  60455. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  60456. */
  60457. private processModel;
  60458. private createMeshInfo;
  60459. /**
  60460. * Gets the ray of the controller in the direction the controller is pointing
  60461. * @param length the length the resulting ray should be
  60462. * @returns a ray in the direction the controller is pointing
  60463. */
  60464. getForwardRay(length?: number): Ray;
  60465. /**
  60466. * Disposes of the controller
  60467. */
  60468. dispose(): void;
  60469. }
  60470. /**
  60471. * This class represents a new windows motion controller in XR.
  60472. */
  60473. export class XRWindowsMotionController extends WindowsMotionController {
  60474. /**
  60475. * Changing the original WIndowsMotionController mapping to fir the new mapping
  60476. */
  60477. protected readonly _mapping: {
  60478. buttons: string[];
  60479. buttonMeshNames: {
  60480. trigger: string;
  60481. menu: string;
  60482. grip: string;
  60483. thumbstick: string;
  60484. trackpad: string;
  60485. };
  60486. buttonObservableNames: {
  60487. trigger: string;
  60488. menu: string;
  60489. grip: string;
  60490. thumbstick: string;
  60491. trackpad: string;
  60492. };
  60493. axisMeshNames: string[];
  60494. pointingPoseMeshName: string;
  60495. };
  60496. /**
  60497. * Construct a new XR-Based windows motion controller
  60498. *
  60499. * @param gamepadInfo the gamepad object from the browser
  60500. */
  60501. constructor(gamepadInfo: any);
  60502. /**
  60503. * holds the thumbstick values (X,Y)
  60504. */
  60505. thumbstickValues: StickValues;
  60506. /**
  60507. * Fired when the thumbstick on this controller is clicked
  60508. */
  60509. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  60510. /**
  60511. * Fired when the thumbstick on this controller is modified
  60512. */
  60513. onThumbstickValuesChangedObservable: Observable<StickValues>;
  60514. /**
  60515. * Fired when the touchpad button on this controller is modified
  60516. */
  60517. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  60518. /**
  60519. * Fired when the touchpad values on this controller are modified
  60520. */
  60521. onTrackpadValuesChangedObservable: Observable<StickValues>;
  60522. /**
  60523. * Fired when the thumbstick button on this controller is modified
  60524. * here to prevent breaking changes
  60525. */
  60526. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  60527. /**
  60528. * updating the thumbstick(!) and not the trackpad.
  60529. * This is named this way due to the difference between WebVR and XR and to avoid
  60530. * changing the parent class.
  60531. */
  60532. protected _updateTrackpad(): void;
  60533. /**
  60534. * Disposes the class with joy
  60535. */
  60536. dispose(): void;
  60537. }
  60538. }
  60539. declare module BABYLON {
  60540. /**
  60541. * A directional light is defined by a direction (what a surprise!).
  60542. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  60543. * 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.
  60544. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60545. */
  60546. export class DirectionalLight extends ShadowLight {
  60547. private _shadowFrustumSize;
  60548. /**
  60549. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  60550. */
  60551. get shadowFrustumSize(): number;
  60552. /**
  60553. * Specifies a fix frustum size for the shadow generation.
  60554. */
  60555. set shadowFrustumSize(value: number);
  60556. private _shadowOrthoScale;
  60557. /**
  60558. * Gets the shadow projection scale against the optimal computed one.
  60559. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60560. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60561. */
  60562. get shadowOrthoScale(): number;
  60563. /**
  60564. * Sets the shadow projection scale against the optimal computed one.
  60565. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  60566. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  60567. */
  60568. set shadowOrthoScale(value: number);
  60569. /**
  60570. * Automatically compute the projection matrix to best fit (including all the casters)
  60571. * on each frame.
  60572. */
  60573. autoUpdateExtends: boolean;
  60574. /**
  60575. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  60576. * on each frame. autoUpdateExtends must be set to true for this to work
  60577. */
  60578. autoCalcShadowZBounds: boolean;
  60579. private _orthoLeft;
  60580. private _orthoRight;
  60581. private _orthoTop;
  60582. private _orthoBottom;
  60583. /**
  60584. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  60585. * The directional light is emitted from everywhere in the given direction.
  60586. * It can cast shadows.
  60587. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60588. * @param name The friendly name of the light
  60589. * @param direction The direction of the light
  60590. * @param scene The scene the light belongs to
  60591. */
  60592. constructor(name: string, direction: Vector3, scene: Scene);
  60593. /**
  60594. * Returns the string "DirectionalLight".
  60595. * @return The class name
  60596. */
  60597. getClassName(): string;
  60598. /**
  60599. * Returns the integer 1.
  60600. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60601. */
  60602. getTypeID(): number;
  60603. /**
  60604. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  60605. * Returns the DirectionalLight Shadow projection matrix.
  60606. */
  60607. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60608. /**
  60609. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  60610. * Returns the DirectionalLight Shadow projection matrix.
  60611. */
  60612. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  60613. /**
  60614. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  60615. * Returns the DirectionalLight Shadow projection matrix.
  60616. */
  60617. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60618. protected _buildUniformLayout(): void;
  60619. /**
  60620. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  60621. * @param effect The effect to update
  60622. * @param lightIndex The index of the light in the effect to update
  60623. * @returns The directional light
  60624. */
  60625. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  60626. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  60627. /**
  60628. * Gets the minZ used for shadow according to both the scene and the light.
  60629. *
  60630. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60631. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60632. * @param activeCamera The camera we are returning the min for
  60633. * @returns the depth min z
  60634. */
  60635. getDepthMinZ(activeCamera: Camera): number;
  60636. /**
  60637. * Gets the maxZ used for shadow according to both the scene and the light.
  60638. *
  60639. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  60640. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  60641. * @param activeCamera The camera we are returning the max for
  60642. * @returns the depth max z
  60643. */
  60644. getDepthMaxZ(activeCamera: Camera): number;
  60645. /**
  60646. * Prepares the list of defines specific to the light type.
  60647. * @param defines the list of defines
  60648. * @param lightIndex defines the index of the light for the effect
  60649. */
  60650. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60651. }
  60652. }
  60653. declare module BABYLON {
  60654. /**
  60655. * Class containing static functions to help procedurally build meshes
  60656. */
  60657. export class HemisphereBuilder {
  60658. /**
  60659. * Creates a hemisphere mesh
  60660. * @param name defines the name of the mesh
  60661. * @param options defines the options used to create the mesh
  60662. * @param scene defines the hosting scene
  60663. * @returns the hemisphere mesh
  60664. */
  60665. static CreateHemisphere(name: string, options: {
  60666. segments?: number;
  60667. diameter?: number;
  60668. sideOrientation?: number;
  60669. }, scene: any): Mesh;
  60670. }
  60671. }
  60672. declare module BABYLON {
  60673. /**
  60674. * A spot light is defined by a position, a direction, an angle, and an exponent.
  60675. * These values define a cone of light starting from the position, emitting toward the direction.
  60676. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  60677. * and the exponent defines the speed of the decay of the light with distance (reach).
  60678. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60679. */
  60680. export class SpotLight extends ShadowLight {
  60681. private _angle;
  60682. private _innerAngle;
  60683. private _cosHalfAngle;
  60684. private _lightAngleScale;
  60685. private _lightAngleOffset;
  60686. /**
  60687. * Gets the cone angle of the spot light in Radians.
  60688. */
  60689. get angle(): number;
  60690. /**
  60691. * Sets the cone angle of the spot light in Radians.
  60692. */
  60693. set angle(value: number);
  60694. /**
  60695. * Only used in gltf falloff mode, this defines the angle where
  60696. * the directional falloff will start before cutting at angle which could be seen
  60697. * as outer angle.
  60698. */
  60699. get innerAngle(): number;
  60700. /**
  60701. * Only used in gltf falloff mode, this defines the angle where
  60702. * the directional falloff will start before cutting at angle which could be seen
  60703. * as outer angle.
  60704. */
  60705. set innerAngle(value: number);
  60706. private _shadowAngleScale;
  60707. /**
  60708. * Allows scaling the angle of the light for shadow generation only.
  60709. */
  60710. get shadowAngleScale(): number;
  60711. /**
  60712. * Allows scaling the angle of the light for shadow generation only.
  60713. */
  60714. set shadowAngleScale(value: number);
  60715. /**
  60716. * The light decay speed with the distance from the emission spot.
  60717. */
  60718. exponent: number;
  60719. private _projectionTextureMatrix;
  60720. /**
  60721. * Allows reading the projecton texture
  60722. */
  60723. get projectionTextureMatrix(): Matrix;
  60724. protected _projectionTextureLightNear: number;
  60725. /**
  60726. * Gets the near clip of the Spotlight for texture projection.
  60727. */
  60728. get projectionTextureLightNear(): number;
  60729. /**
  60730. * Sets the near clip of the Spotlight for texture projection.
  60731. */
  60732. set projectionTextureLightNear(value: number);
  60733. protected _projectionTextureLightFar: number;
  60734. /**
  60735. * Gets the far clip of the Spotlight for texture projection.
  60736. */
  60737. get projectionTextureLightFar(): number;
  60738. /**
  60739. * Sets the far clip of the Spotlight for texture projection.
  60740. */
  60741. set projectionTextureLightFar(value: number);
  60742. protected _projectionTextureUpDirection: Vector3;
  60743. /**
  60744. * Gets the Up vector of the Spotlight for texture projection.
  60745. */
  60746. get projectionTextureUpDirection(): Vector3;
  60747. /**
  60748. * Sets the Up vector of the Spotlight for texture projection.
  60749. */
  60750. set projectionTextureUpDirection(value: Vector3);
  60751. private _projectionTexture;
  60752. /**
  60753. * Gets the projection texture of the light.
  60754. */
  60755. get projectionTexture(): Nullable<BaseTexture>;
  60756. /**
  60757. * Sets the projection texture of the light.
  60758. */
  60759. set projectionTexture(value: Nullable<BaseTexture>);
  60760. private static _IsProceduralTexture;
  60761. private static _IsTexture;
  60762. private _projectionTextureViewLightDirty;
  60763. private _projectionTextureProjectionLightDirty;
  60764. private _projectionTextureDirty;
  60765. private _projectionTextureViewTargetVector;
  60766. private _projectionTextureViewLightMatrix;
  60767. private _projectionTextureProjectionLightMatrix;
  60768. private _projectionTextureScalingMatrix;
  60769. /**
  60770. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60771. * It can cast shadows.
  60772. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60773. * @param name The light friendly name
  60774. * @param position The position of the spot light in the scene
  60775. * @param direction The direction of the light in the scene
  60776. * @param angle The cone angle of the light in Radians
  60777. * @param exponent The light decay speed with the distance from the emission spot
  60778. * @param scene The scene the lights belongs to
  60779. */
  60780. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60781. /**
  60782. * Returns the string "SpotLight".
  60783. * @returns the class name
  60784. */
  60785. getClassName(): string;
  60786. /**
  60787. * Returns the integer 2.
  60788. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60789. */
  60790. getTypeID(): number;
  60791. /**
  60792. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60793. */
  60794. protected _setDirection(value: Vector3): void;
  60795. /**
  60796. * Overrides the position setter to recompute the projection texture view light Matrix.
  60797. */
  60798. protected _setPosition(value: Vector3): void;
  60799. /**
  60800. * 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.
  60801. * Returns the SpotLight.
  60802. */
  60803. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60804. protected _computeProjectionTextureViewLightMatrix(): void;
  60805. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60806. /**
  60807. * Main function for light texture projection matrix computing.
  60808. */
  60809. protected _computeProjectionTextureMatrix(): void;
  60810. protected _buildUniformLayout(): void;
  60811. private _computeAngleValues;
  60812. /**
  60813. * Sets the passed Effect "effect" with the Light textures.
  60814. * @param effect The effect to update
  60815. * @param lightIndex The index of the light in the effect to update
  60816. * @returns The light
  60817. */
  60818. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60819. /**
  60820. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60821. * @param effect The effect to update
  60822. * @param lightIndex The index of the light in the effect to update
  60823. * @returns The spot light
  60824. */
  60825. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60826. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60827. /**
  60828. * Disposes the light and the associated resources.
  60829. */
  60830. dispose(): void;
  60831. /**
  60832. * Prepares the list of defines specific to the light type.
  60833. * @param defines the list of defines
  60834. * @param lightIndex defines the index of the light for the effect
  60835. */
  60836. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60837. }
  60838. }
  60839. declare module BABYLON {
  60840. /**
  60841. * Gizmo that enables viewing a light
  60842. */
  60843. export class LightGizmo extends Gizmo {
  60844. private _lightMesh;
  60845. private _material;
  60846. private _cachedPosition;
  60847. private _cachedForward;
  60848. private _attachedMeshParent;
  60849. private _pointerObserver;
  60850. /**
  60851. * Event that fires each time the gizmo is clicked
  60852. */
  60853. onClickedObservable: Observable<Light>;
  60854. /**
  60855. * Creates a LightGizmo
  60856. * @param gizmoLayer The utility layer the gizmo will be added to
  60857. */
  60858. constructor(gizmoLayer?: UtilityLayerRenderer);
  60859. private _light;
  60860. /**
  60861. * The light that the gizmo is attached to
  60862. */
  60863. set light(light: Nullable<Light>);
  60864. get light(): Nullable<Light>;
  60865. /**
  60866. * Gets the material used to render the light gizmo
  60867. */
  60868. get material(): StandardMaterial;
  60869. /**
  60870. * @hidden
  60871. * Updates the gizmo to match the attached mesh's position/rotation
  60872. */
  60873. protected _update(): void;
  60874. private static _Scale;
  60875. /**
  60876. * Creates the lines for a light mesh
  60877. */
  60878. private static _CreateLightLines;
  60879. /**
  60880. * Disposes of the light gizmo
  60881. */
  60882. dispose(): void;
  60883. private static _CreateHemisphericLightMesh;
  60884. private static _CreatePointLightMesh;
  60885. private static _CreateSpotLightMesh;
  60886. private static _CreateDirectionalLightMesh;
  60887. }
  60888. }
  60889. declare module BABYLON {
  60890. /**
  60891. * Gizmo that enables viewing a camera
  60892. */
  60893. export class CameraGizmo extends Gizmo {
  60894. private _cameraMesh;
  60895. private _cameraLinesMesh;
  60896. private _material;
  60897. private _pointerObserver;
  60898. /**
  60899. * Event that fires each time the gizmo is clicked
  60900. */
  60901. onClickedObservable: Observable<Camera>;
  60902. /**
  60903. * Creates a CameraGizmo
  60904. * @param gizmoLayer The utility layer the gizmo will be added to
  60905. */
  60906. constructor(gizmoLayer?: UtilityLayerRenderer);
  60907. private _camera;
  60908. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60909. get displayFrustum(): boolean;
  60910. set displayFrustum(value: boolean);
  60911. /**
  60912. * The camera that the gizmo is attached to
  60913. */
  60914. set camera(camera: Nullable<Camera>);
  60915. get camera(): Nullable<Camera>;
  60916. /**
  60917. * Gets the material used to render the camera gizmo
  60918. */
  60919. get material(): StandardMaterial;
  60920. /**
  60921. * @hidden
  60922. * Updates the gizmo to match the attached mesh's position/rotation
  60923. */
  60924. protected _update(): void;
  60925. private static _Scale;
  60926. private _invProjection;
  60927. /**
  60928. * Disposes of the camera gizmo
  60929. */
  60930. dispose(): void;
  60931. private static _CreateCameraMesh;
  60932. private static _CreateCameraFrustum;
  60933. }
  60934. }
  60935. declare module BABYLON {
  60936. /** @hidden */
  60937. export var backgroundFragmentDeclaration: {
  60938. name: string;
  60939. shader: string;
  60940. };
  60941. }
  60942. declare module BABYLON {
  60943. /** @hidden */
  60944. export var backgroundUboDeclaration: {
  60945. name: string;
  60946. shader: string;
  60947. };
  60948. }
  60949. declare module BABYLON {
  60950. /** @hidden */
  60951. export var backgroundPixelShader: {
  60952. name: string;
  60953. shader: string;
  60954. };
  60955. }
  60956. declare module BABYLON {
  60957. /** @hidden */
  60958. export var backgroundVertexDeclaration: {
  60959. name: string;
  60960. shader: string;
  60961. };
  60962. }
  60963. declare module BABYLON {
  60964. /** @hidden */
  60965. export var backgroundVertexShader: {
  60966. name: string;
  60967. shader: string;
  60968. };
  60969. }
  60970. declare module BABYLON {
  60971. /**
  60972. * Background material used to create an efficient environement around your scene.
  60973. */
  60974. export class BackgroundMaterial extends PushMaterial {
  60975. /**
  60976. * Standard reflectance value at parallel view angle.
  60977. */
  60978. static StandardReflectance0: number;
  60979. /**
  60980. * Standard reflectance value at grazing angle.
  60981. */
  60982. static StandardReflectance90: number;
  60983. protected _primaryColor: Color3;
  60984. /**
  60985. * Key light Color (multiply against the environement texture)
  60986. */
  60987. primaryColor: Color3;
  60988. protected __perceptualColor: Nullable<Color3>;
  60989. /**
  60990. * Experimental Internal Use Only.
  60991. *
  60992. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60993. * This acts as a helper to set the primary color to a more "human friendly" value.
  60994. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60995. * output color as close as possible from the chosen value.
  60996. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60997. * part of lighting setup.)
  60998. */
  60999. get _perceptualColor(): Nullable<Color3>;
  61000. set _perceptualColor(value: Nullable<Color3>);
  61001. protected _primaryColorShadowLevel: float;
  61002. /**
  61003. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  61004. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  61005. */
  61006. get primaryColorShadowLevel(): float;
  61007. set primaryColorShadowLevel(value: float);
  61008. protected _primaryColorHighlightLevel: float;
  61009. /**
  61010. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  61011. * The primary color is used at the level chosen to define what the white area would look.
  61012. */
  61013. get primaryColorHighlightLevel(): float;
  61014. set primaryColorHighlightLevel(value: float);
  61015. protected _reflectionTexture: Nullable<BaseTexture>;
  61016. /**
  61017. * Reflection Texture used in the material.
  61018. * Should be author in a specific way for the best result (refer to the documentation).
  61019. */
  61020. reflectionTexture: Nullable<BaseTexture>;
  61021. protected _reflectionBlur: float;
  61022. /**
  61023. * Reflection Texture level of blur.
  61024. *
  61025. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  61026. * texture twice.
  61027. */
  61028. reflectionBlur: float;
  61029. protected _diffuseTexture: Nullable<BaseTexture>;
  61030. /**
  61031. * Diffuse Texture used in the material.
  61032. * Should be author in a specific way for the best result (refer to the documentation).
  61033. */
  61034. diffuseTexture: Nullable<BaseTexture>;
  61035. protected _shadowLights: Nullable<IShadowLight[]>;
  61036. /**
  61037. * Specify the list of lights casting shadow on the material.
  61038. * All scene shadow lights will be included if null.
  61039. */
  61040. shadowLights: Nullable<IShadowLight[]>;
  61041. protected _shadowLevel: float;
  61042. /**
  61043. * Helps adjusting the shadow to a softer level if required.
  61044. * 0 means black shadows and 1 means no shadows.
  61045. */
  61046. shadowLevel: float;
  61047. protected _sceneCenter: Vector3;
  61048. /**
  61049. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  61050. * It is usually zero but might be interesting to modify according to your setup.
  61051. */
  61052. sceneCenter: Vector3;
  61053. protected _opacityFresnel: boolean;
  61054. /**
  61055. * This helps specifying that the material is falling off to the sky box at grazing angle.
  61056. * This helps ensuring a nice transition when the camera goes under the ground.
  61057. */
  61058. opacityFresnel: boolean;
  61059. protected _reflectionFresnel: boolean;
  61060. /**
  61061. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  61062. * This helps adding a mirror texture on the ground.
  61063. */
  61064. reflectionFresnel: boolean;
  61065. protected _reflectionFalloffDistance: number;
  61066. /**
  61067. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  61068. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  61069. */
  61070. reflectionFalloffDistance: number;
  61071. protected _reflectionAmount: number;
  61072. /**
  61073. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  61074. */
  61075. reflectionAmount: number;
  61076. protected _reflectionReflectance0: number;
  61077. /**
  61078. * This specifies the weight of the reflection at grazing angle.
  61079. */
  61080. reflectionReflectance0: number;
  61081. protected _reflectionReflectance90: number;
  61082. /**
  61083. * This specifies the weight of the reflection at a perpendicular point of view.
  61084. */
  61085. reflectionReflectance90: number;
  61086. /**
  61087. * Sets the reflection reflectance fresnel values according to the default standard
  61088. * empirically know to work well :-)
  61089. */
  61090. set reflectionStandardFresnelWeight(value: number);
  61091. protected _useRGBColor: boolean;
  61092. /**
  61093. * Helps to directly use the maps channels instead of their level.
  61094. */
  61095. useRGBColor: boolean;
  61096. protected _enableNoise: boolean;
  61097. /**
  61098. * This helps reducing the banding effect that could occur on the background.
  61099. */
  61100. enableNoise: boolean;
  61101. /**
  61102. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61103. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  61104. * Recommended to be keep at 1.0 except for special cases.
  61105. */
  61106. get fovMultiplier(): number;
  61107. set fovMultiplier(value: number);
  61108. private _fovMultiplier;
  61109. /**
  61110. * Enable the FOV adjustment feature controlled by fovMultiplier.
  61111. */
  61112. useEquirectangularFOV: boolean;
  61113. private _maxSimultaneousLights;
  61114. /**
  61115. * Number of Simultaneous lights allowed on the material.
  61116. */
  61117. maxSimultaneousLights: int;
  61118. private _shadowOnly;
  61119. /**
  61120. * Make the material only render shadows
  61121. */
  61122. shadowOnly: boolean;
  61123. /**
  61124. * Default configuration related to image processing available in the Background Material.
  61125. */
  61126. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  61127. /**
  61128. * Keep track of the image processing observer to allow dispose and replace.
  61129. */
  61130. private _imageProcessingObserver;
  61131. /**
  61132. * Attaches a new image processing configuration to the PBR Material.
  61133. * @param configuration (if null the scene configuration will be use)
  61134. */
  61135. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  61136. /**
  61137. * Gets the image processing configuration used either in this material.
  61138. */
  61139. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  61140. /**
  61141. * Sets the Default image processing configuration used either in the this material.
  61142. *
  61143. * If sets to null, the scene one is in use.
  61144. */
  61145. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  61146. /**
  61147. * Gets wether the color curves effect is enabled.
  61148. */
  61149. get cameraColorCurvesEnabled(): boolean;
  61150. /**
  61151. * Sets wether the color curves effect is enabled.
  61152. */
  61153. set cameraColorCurvesEnabled(value: boolean);
  61154. /**
  61155. * Gets wether the color grading effect is enabled.
  61156. */
  61157. get cameraColorGradingEnabled(): boolean;
  61158. /**
  61159. * Gets wether the color grading effect is enabled.
  61160. */
  61161. set cameraColorGradingEnabled(value: boolean);
  61162. /**
  61163. * Gets wether tonemapping is enabled or not.
  61164. */
  61165. get cameraToneMappingEnabled(): boolean;
  61166. /**
  61167. * Sets wether tonemapping is enabled or not
  61168. */
  61169. set cameraToneMappingEnabled(value: boolean);
  61170. /**
  61171. * The camera exposure used on this material.
  61172. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61173. * This corresponds to a photographic exposure.
  61174. */
  61175. get cameraExposure(): float;
  61176. /**
  61177. * The camera exposure used on this material.
  61178. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  61179. * This corresponds to a photographic exposure.
  61180. */
  61181. set cameraExposure(value: float);
  61182. /**
  61183. * Gets The camera contrast used on this material.
  61184. */
  61185. get cameraContrast(): float;
  61186. /**
  61187. * Sets The camera contrast used on this material.
  61188. */
  61189. set cameraContrast(value: float);
  61190. /**
  61191. * Gets the Color Grading 2D Lookup Texture.
  61192. */
  61193. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  61194. /**
  61195. * Sets the Color Grading 2D Lookup Texture.
  61196. */
  61197. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  61198. /**
  61199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61201. * 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;
  61202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61203. */
  61204. get cameraColorCurves(): Nullable<ColorCurves>;
  61205. /**
  61206. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  61207. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  61208. * 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;
  61209. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  61210. */
  61211. set cameraColorCurves(value: Nullable<ColorCurves>);
  61212. /**
  61213. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  61214. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  61215. */
  61216. switchToBGR: boolean;
  61217. private _renderTargets;
  61218. private _reflectionControls;
  61219. private _white;
  61220. private _primaryShadowColor;
  61221. private _primaryHighlightColor;
  61222. /**
  61223. * Instantiates a Background Material in the given scene
  61224. * @param name The friendly name of the material
  61225. * @param scene The scene to add the material to
  61226. */
  61227. constructor(name: string, scene: Scene);
  61228. /**
  61229. * Gets a boolean indicating that current material needs to register RTT
  61230. */
  61231. get hasRenderTargetTextures(): boolean;
  61232. /**
  61233. * The entire material has been created in order to prevent overdraw.
  61234. * @returns false
  61235. */
  61236. needAlphaTesting(): boolean;
  61237. /**
  61238. * The entire material has been created in order to prevent overdraw.
  61239. * @returns true if blending is enable
  61240. */
  61241. needAlphaBlending(): boolean;
  61242. /**
  61243. * Checks wether the material is ready to be rendered for a given mesh.
  61244. * @param mesh The mesh to render
  61245. * @param subMesh The submesh to check against
  61246. * @param useInstances Specify wether or not the material is used with instances
  61247. * @returns true if all the dependencies are ready (Textures, Effects...)
  61248. */
  61249. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  61250. /**
  61251. * Compute the primary color according to the chosen perceptual color.
  61252. */
  61253. private _computePrimaryColorFromPerceptualColor;
  61254. /**
  61255. * Compute the highlights and shadow colors according to their chosen levels.
  61256. */
  61257. private _computePrimaryColors;
  61258. /**
  61259. * Build the uniform buffer used in the material.
  61260. */
  61261. buildUniformLayout(): void;
  61262. /**
  61263. * Unbind the material.
  61264. */
  61265. unbind(): void;
  61266. /**
  61267. * Bind only the world matrix to the material.
  61268. * @param world The world matrix to bind.
  61269. */
  61270. bindOnlyWorldMatrix(world: Matrix): void;
  61271. /**
  61272. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  61273. * @param world The world matrix to bind.
  61274. * @param subMesh The submesh to bind for.
  61275. */
  61276. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  61277. /**
  61278. * Checks to see if a texture is used in the material.
  61279. * @param texture - Base texture to use.
  61280. * @returns - Boolean specifying if a texture is used in the material.
  61281. */
  61282. hasTexture(texture: BaseTexture): boolean;
  61283. /**
  61284. * Dispose the material.
  61285. * @param forceDisposeEffect Force disposal of the associated effect.
  61286. * @param forceDisposeTextures Force disposal of the associated textures.
  61287. */
  61288. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  61289. /**
  61290. * Clones the material.
  61291. * @param name The cloned name.
  61292. * @returns The cloned material.
  61293. */
  61294. clone(name: string): BackgroundMaterial;
  61295. /**
  61296. * Serializes the current material to its JSON representation.
  61297. * @returns The JSON representation.
  61298. */
  61299. serialize(): any;
  61300. /**
  61301. * Gets the class name of the material
  61302. * @returns "BackgroundMaterial"
  61303. */
  61304. getClassName(): string;
  61305. /**
  61306. * Parse a JSON input to create back a background material.
  61307. * @param source The JSON data to parse
  61308. * @param scene The scene to create the parsed material in
  61309. * @param rootUrl The root url of the assets the material depends upon
  61310. * @returns the instantiated BackgroundMaterial.
  61311. */
  61312. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  61313. }
  61314. }
  61315. declare module BABYLON {
  61316. /**
  61317. * Represents the different options available during the creation of
  61318. * a Environment helper.
  61319. *
  61320. * This can control the default ground, skybox and image processing setup of your scene.
  61321. */
  61322. export interface IEnvironmentHelperOptions {
  61323. /**
  61324. * Specifies whether or not to create a ground.
  61325. * True by default.
  61326. */
  61327. createGround: boolean;
  61328. /**
  61329. * Specifies the ground size.
  61330. * 15 by default.
  61331. */
  61332. groundSize: number;
  61333. /**
  61334. * The texture used on the ground for the main color.
  61335. * Comes from the BabylonJS CDN by default.
  61336. *
  61337. * Remarks: Can be either a texture or a url.
  61338. */
  61339. groundTexture: string | BaseTexture;
  61340. /**
  61341. * The color mixed in the ground texture by default.
  61342. * BabylonJS clearColor by default.
  61343. */
  61344. groundColor: Color3;
  61345. /**
  61346. * Specifies the ground opacity.
  61347. * 1 by default.
  61348. */
  61349. groundOpacity: number;
  61350. /**
  61351. * Enables the ground to receive shadows.
  61352. * True by default.
  61353. */
  61354. enableGroundShadow: boolean;
  61355. /**
  61356. * Helps preventing the shadow to be fully black on the ground.
  61357. * 0.5 by default.
  61358. */
  61359. groundShadowLevel: number;
  61360. /**
  61361. * Creates a mirror texture attach to the ground.
  61362. * false by default.
  61363. */
  61364. enableGroundMirror: boolean;
  61365. /**
  61366. * Specifies the ground mirror size ratio.
  61367. * 0.3 by default as the default kernel is 64.
  61368. */
  61369. groundMirrorSizeRatio: number;
  61370. /**
  61371. * Specifies the ground mirror blur kernel size.
  61372. * 64 by default.
  61373. */
  61374. groundMirrorBlurKernel: number;
  61375. /**
  61376. * Specifies the ground mirror visibility amount.
  61377. * 1 by default
  61378. */
  61379. groundMirrorAmount: number;
  61380. /**
  61381. * Specifies the ground mirror reflectance weight.
  61382. * This uses the standard weight of the background material to setup the fresnel effect
  61383. * of the mirror.
  61384. * 1 by default.
  61385. */
  61386. groundMirrorFresnelWeight: number;
  61387. /**
  61388. * Specifies the ground mirror Falloff distance.
  61389. * This can helps reducing the size of the reflection.
  61390. * 0 by Default.
  61391. */
  61392. groundMirrorFallOffDistance: number;
  61393. /**
  61394. * Specifies the ground mirror texture type.
  61395. * Unsigned Int by Default.
  61396. */
  61397. groundMirrorTextureType: number;
  61398. /**
  61399. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  61400. * the shown objects.
  61401. */
  61402. groundYBias: number;
  61403. /**
  61404. * Specifies whether or not to create a skybox.
  61405. * True by default.
  61406. */
  61407. createSkybox: boolean;
  61408. /**
  61409. * Specifies the skybox size.
  61410. * 20 by default.
  61411. */
  61412. skyboxSize: number;
  61413. /**
  61414. * The texture used on the skybox for the main color.
  61415. * Comes from the BabylonJS CDN by default.
  61416. *
  61417. * Remarks: Can be either a texture or a url.
  61418. */
  61419. skyboxTexture: string | BaseTexture;
  61420. /**
  61421. * The color mixed in the skybox texture by default.
  61422. * BabylonJS clearColor by default.
  61423. */
  61424. skyboxColor: Color3;
  61425. /**
  61426. * The background rotation around the Y axis of the scene.
  61427. * This helps aligning the key lights of your scene with the background.
  61428. * 0 by default.
  61429. */
  61430. backgroundYRotation: number;
  61431. /**
  61432. * Compute automatically the size of the elements to best fit with the scene.
  61433. */
  61434. sizeAuto: boolean;
  61435. /**
  61436. * Default position of the rootMesh if autoSize is not true.
  61437. */
  61438. rootPosition: Vector3;
  61439. /**
  61440. * Sets up the image processing in the scene.
  61441. * true by default.
  61442. */
  61443. setupImageProcessing: boolean;
  61444. /**
  61445. * The texture used as your environment texture in the scene.
  61446. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  61447. *
  61448. * Remarks: Can be either a texture or a url.
  61449. */
  61450. environmentTexture: string | BaseTexture;
  61451. /**
  61452. * The value of the exposure to apply to the scene.
  61453. * 0.6 by default if setupImageProcessing is true.
  61454. */
  61455. cameraExposure: number;
  61456. /**
  61457. * The value of the contrast to apply to the scene.
  61458. * 1.6 by default if setupImageProcessing is true.
  61459. */
  61460. cameraContrast: number;
  61461. /**
  61462. * Specifies whether or not tonemapping should be enabled in the scene.
  61463. * true by default if setupImageProcessing is true.
  61464. */
  61465. toneMappingEnabled: boolean;
  61466. }
  61467. /**
  61468. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  61469. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  61470. * It also helps with the default setup of your imageProcessing configuration.
  61471. */
  61472. export class EnvironmentHelper {
  61473. /**
  61474. * Default ground texture URL.
  61475. */
  61476. private static _groundTextureCDNUrl;
  61477. /**
  61478. * Default skybox texture URL.
  61479. */
  61480. private static _skyboxTextureCDNUrl;
  61481. /**
  61482. * Default environment texture URL.
  61483. */
  61484. private static _environmentTextureCDNUrl;
  61485. /**
  61486. * Creates the default options for the helper.
  61487. */
  61488. private static _getDefaultOptions;
  61489. private _rootMesh;
  61490. /**
  61491. * Gets the root mesh created by the helper.
  61492. */
  61493. get rootMesh(): Mesh;
  61494. private _skybox;
  61495. /**
  61496. * Gets the skybox created by the helper.
  61497. */
  61498. get skybox(): Nullable<Mesh>;
  61499. private _skyboxTexture;
  61500. /**
  61501. * Gets the skybox texture created by the helper.
  61502. */
  61503. get skyboxTexture(): Nullable<BaseTexture>;
  61504. private _skyboxMaterial;
  61505. /**
  61506. * Gets the skybox material created by the helper.
  61507. */
  61508. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  61509. private _ground;
  61510. /**
  61511. * Gets the ground mesh created by the helper.
  61512. */
  61513. get ground(): Nullable<Mesh>;
  61514. private _groundTexture;
  61515. /**
  61516. * Gets the ground texture created by the helper.
  61517. */
  61518. get groundTexture(): Nullable<BaseTexture>;
  61519. private _groundMirror;
  61520. /**
  61521. * Gets the ground mirror created by the helper.
  61522. */
  61523. get groundMirror(): Nullable<MirrorTexture>;
  61524. /**
  61525. * Gets the ground mirror render list to helps pushing the meshes
  61526. * you wish in the ground reflection.
  61527. */
  61528. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  61529. private _groundMaterial;
  61530. /**
  61531. * Gets the ground material created by the helper.
  61532. */
  61533. get groundMaterial(): Nullable<BackgroundMaterial>;
  61534. /**
  61535. * Stores the creation options.
  61536. */
  61537. private readonly _scene;
  61538. private _options;
  61539. /**
  61540. * This observable will be notified with any error during the creation of the environment,
  61541. * mainly texture creation errors.
  61542. */
  61543. onErrorObservable: Observable<{
  61544. message?: string;
  61545. exception?: any;
  61546. }>;
  61547. /**
  61548. * constructor
  61549. * @param options Defines the options we want to customize the helper
  61550. * @param scene The scene to add the material to
  61551. */
  61552. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  61553. /**
  61554. * Updates the background according to the new options
  61555. * @param options
  61556. */
  61557. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  61558. /**
  61559. * Sets the primary color of all the available elements.
  61560. * @param color the main color to affect to the ground and the background
  61561. */
  61562. setMainColor(color: Color3): void;
  61563. /**
  61564. * Setup the image processing according to the specified options.
  61565. */
  61566. private _setupImageProcessing;
  61567. /**
  61568. * Setup the environment texture according to the specified options.
  61569. */
  61570. private _setupEnvironmentTexture;
  61571. /**
  61572. * Setup the background according to the specified options.
  61573. */
  61574. private _setupBackground;
  61575. /**
  61576. * Get the scene sizes according to the setup.
  61577. */
  61578. private _getSceneSize;
  61579. /**
  61580. * Setup the ground according to the specified options.
  61581. */
  61582. private _setupGround;
  61583. /**
  61584. * Setup the ground material according to the specified options.
  61585. */
  61586. private _setupGroundMaterial;
  61587. /**
  61588. * Setup the ground diffuse texture according to the specified options.
  61589. */
  61590. private _setupGroundDiffuseTexture;
  61591. /**
  61592. * Setup the ground mirror texture according to the specified options.
  61593. */
  61594. private _setupGroundMirrorTexture;
  61595. /**
  61596. * Setup the ground to receive the mirror texture.
  61597. */
  61598. private _setupMirrorInGroundMaterial;
  61599. /**
  61600. * Setup the skybox according to the specified options.
  61601. */
  61602. private _setupSkybox;
  61603. /**
  61604. * Setup the skybox material according to the specified options.
  61605. */
  61606. private _setupSkyboxMaterial;
  61607. /**
  61608. * Setup the skybox reflection texture according to the specified options.
  61609. */
  61610. private _setupSkyboxReflectionTexture;
  61611. private _errorHandler;
  61612. /**
  61613. * Dispose all the elements created by the Helper.
  61614. */
  61615. dispose(): void;
  61616. }
  61617. }
  61618. declare module BABYLON {
  61619. /**
  61620. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61621. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61622. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61623. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61624. */
  61625. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61626. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61627. /**
  61628. * Define the source as a Monoscopic panoramic 360/180.
  61629. */
  61630. static readonly MODE_MONOSCOPIC: number;
  61631. /**
  61632. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61633. */
  61634. static readonly MODE_TOPBOTTOM: number;
  61635. /**
  61636. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61637. */
  61638. static readonly MODE_SIDEBYSIDE: number;
  61639. private _halfDome;
  61640. private _crossEye;
  61641. protected _useDirectMapping: boolean;
  61642. /**
  61643. * The texture being displayed on the sphere
  61644. */
  61645. protected _texture: T;
  61646. /**
  61647. * Gets the texture being displayed on the sphere
  61648. */
  61649. get texture(): T;
  61650. /**
  61651. * Sets the texture being displayed on the sphere
  61652. */
  61653. set texture(newTexture: T);
  61654. /**
  61655. * The skybox material
  61656. */
  61657. protected _material: BackgroundMaterial;
  61658. /**
  61659. * The surface used for the dome
  61660. */
  61661. protected _mesh: Mesh;
  61662. /**
  61663. * Gets the mesh used for the dome.
  61664. */
  61665. get mesh(): Mesh;
  61666. /**
  61667. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61668. */
  61669. private _halfDomeMask;
  61670. /**
  61671. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61672. * Also see the options.resolution property.
  61673. */
  61674. get fovMultiplier(): number;
  61675. set fovMultiplier(value: number);
  61676. protected _textureMode: number;
  61677. /**
  61678. * Gets or set the current texture mode for the texture. It can be:
  61679. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61680. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61681. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61682. */
  61683. get textureMode(): number;
  61684. /**
  61685. * Sets the current texture mode for the texture. It can be:
  61686. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61687. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61688. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61689. */
  61690. set textureMode(value: number);
  61691. /**
  61692. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61693. */
  61694. get halfDome(): boolean;
  61695. /**
  61696. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61697. */
  61698. set halfDome(enabled: boolean);
  61699. /**
  61700. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61701. */
  61702. set crossEye(enabled: boolean);
  61703. /**
  61704. * Is it a cross-eye texture?
  61705. */
  61706. get crossEye(): boolean;
  61707. /**
  61708. * The background material of this dome.
  61709. */
  61710. get material(): BackgroundMaterial;
  61711. /**
  61712. * Oberserver used in Stereoscopic VR Mode.
  61713. */
  61714. private _onBeforeCameraRenderObserver;
  61715. /**
  61716. * Observable raised when an error occured while loading the 360 image
  61717. */
  61718. onLoadErrorObservable: Observable<string>;
  61719. /**
  61720. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61721. * @param name Element's name, child elements will append suffixes for their own names.
  61722. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61723. * @param options An object containing optional or exposed sub element properties
  61724. */
  61725. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61726. resolution?: number;
  61727. clickToPlay?: boolean;
  61728. autoPlay?: boolean;
  61729. loop?: boolean;
  61730. size?: number;
  61731. poster?: string;
  61732. faceForward?: boolean;
  61733. useDirectMapping?: boolean;
  61734. halfDomeMode?: boolean;
  61735. crossEyeMode?: boolean;
  61736. generateMipMaps?: boolean;
  61737. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61738. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61739. protected _changeTextureMode(value: number): void;
  61740. /**
  61741. * Releases resources associated with this node.
  61742. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61743. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61744. */
  61745. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61746. }
  61747. }
  61748. declare module BABYLON {
  61749. /**
  61750. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61751. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61752. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61753. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61754. */
  61755. export class PhotoDome extends TextureDome<Texture> {
  61756. /**
  61757. * Define the image as a Monoscopic panoramic 360 image.
  61758. */
  61759. static readonly MODE_MONOSCOPIC: number;
  61760. /**
  61761. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61762. */
  61763. static readonly MODE_TOPBOTTOM: number;
  61764. /**
  61765. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61766. */
  61767. static readonly MODE_SIDEBYSIDE: number;
  61768. /**
  61769. * Gets or sets the texture being displayed on the sphere
  61770. */
  61771. get photoTexture(): Texture;
  61772. /**
  61773. * sets the texture being displayed on the sphere
  61774. */
  61775. set photoTexture(value: Texture);
  61776. /**
  61777. * Gets the current video mode for the video. It can be:
  61778. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61779. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61780. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61781. */
  61782. get imageMode(): number;
  61783. /**
  61784. * Sets the current video mode for the video. It can be:
  61785. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61786. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61787. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61788. */
  61789. set imageMode(value: number);
  61790. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61791. }
  61792. }
  61793. declare module BABYLON {
  61794. /**
  61795. * Direct draw surface info
  61796. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61797. */
  61798. export interface DDSInfo {
  61799. /**
  61800. * Width of the texture
  61801. */
  61802. width: number;
  61803. /**
  61804. * Width of the texture
  61805. */
  61806. height: number;
  61807. /**
  61808. * Number of Mipmaps for the texture
  61809. * @see https://en.wikipedia.org/wiki/Mipmap
  61810. */
  61811. mipmapCount: number;
  61812. /**
  61813. * If the textures format is a known fourCC format
  61814. * @see https://www.fourcc.org/
  61815. */
  61816. isFourCC: boolean;
  61817. /**
  61818. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61819. */
  61820. isRGB: boolean;
  61821. /**
  61822. * If the texture is a lumincance format
  61823. */
  61824. isLuminance: boolean;
  61825. /**
  61826. * If this is a cube texture
  61827. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61828. */
  61829. isCube: boolean;
  61830. /**
  61831. * If the texture is a compressed format eg. FOURCC_DXT1
  61832. */
  61833. isCompressed: boolean;
  61834. /**
  61835. * The dxgiFormat of the texture
  61836. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61837. */
  61838. dxgiFormat: number;
  61839. /**
  61840. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61841. */
  61842. textureType: number;
  61843. /**
  61844. * Sphericle polynomial created for the dds texture
  61845. */
  61846. sphericalPolynomial?: SphericalPolynomial;
  61847. }
  61848. /**
  61849. * Class used to provide DDS decompression tools
  61850. */
  61851. export class DDSTools {
  61852. /**
  61853. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61854. */
  61855. static StoreLODInAlphaChannel: boolean;
  61856. /**
  61857. * Gets DDS information from an array buffer
  61858. * @param data defines the array buffer view to read data from
  61859. * @returns the DDS information
  61860. */
  61861. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61862. private static _FloatView;
  61863. private static _Int32View;
  61864. private static _ToHalfFloat;
  61865. private static _FromHalfFloat;
  61866. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61867. private static _GetHalfFloatRGBAArrayBuffer;
  61868. private static _GetFloatRGBAArrayBuffer;
  61869. private static _GetFloatAsUIntRGBAArrayBuffer;
  61870. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61871. private static _GetRGBAArrayBuffer;
  61872. private static _ExtractLongWordOrder;
  61873. private static _GetRGBArrayBuffer;
  61874. private static _GetLuminanceArrayBuffer;
  61875. /**
  61876. * Uploads DDS Levels to a Babylon Texture
  61877. * @hidden
  61878. */
  61879. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61880. }
  61881. interface ThinEngine {
  61882. /**
  61883. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61884. * @param rootUrl defines the url where the file to load is located
  61885. * @param scene defines the current scene
  61886. * @param lodScale defines scale to apply to the mip map selection
  61887. * @param lodOffset defines offset to apply to the mip map selection
  61888. * @param onLoad defines an optional callback raised when the texture is loaded
  61889. * @param onError defines an optional callback raised if there is an issue to load the texture
  61890. * @param format defines the format of the data
  61891. * @param forcedExtension defines the extension to use to pick the right loader
  61892. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61893. * @returns the cube texture as an InternalTexture
  61894. */
  61895. 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;
  61896. }
  61897. }
  61898. declare module BABYLON {
  61899. /**
  61900. * Implementation of the DDS Texture Loader.
  61901. * @hidden
  61902. */
  61903. export class _DDSTextureLoader implements IInternalTextureLoader {
  61904. /**
  61905. * Defines wether the loader supports cascade loading the different faces.
  61906. */
  61907. readonly supportCascades: boolean;
  61908. /**
  61909. * This returns if the loader support the current file information.
  61910. * @param extension defines the file extension of the file being loaded
  61911. * @returns true if the loader can load the specified file
  61912. */
  61913. canLoad(extension: string): boolean;
  61914. /**
  61915. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61916. * @param data contains the texture data
  61917. * @param texture defines the BabylonJS internal texture
  61918. * @param createPolynomials will be true if polynomials have been requested
  61919. * @param onLoad defines the callback to trigger once the texture is ready
  61920. * @param onError defines the callback to trigger in case of error
  61921. */
  61922. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61923. /**
  61924. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61925. * @param data contains the texture data
  61926. * @param texture defines the BabylonJS internal texture
  61927. * @param callback defines the method to call once ready to upload
  61928. */
  61929. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61930. }
  61931. }
  61932. declare module BABYLON {
  61933. /**
  61934. * Implementation of the ENV Texture Loader.
  61935. * @hidden
  61936. */
  61937. export class _ENVTextureLoader implements IInternalTextureLoader {
  61938. /**
  61939. * Defines wether the loader supports cascade loading the different faces.
  61940. */
  61941. readonly supportCascades: boolean;
  61942. /**
  61943. * This returns if the loader support the current file information.
  61944. * @param extension defines the file extension of the file being loaded
  61945. * @returns true if the loader can load the specified file
  61946. */
  61947. canLoad(extension: string): boolean;
  61948. /**
  61949. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61950. * @param data contains the texture data
  61951. * @param texture defines the BabylonJS internal texture
  61952. * @param createPolynomials will be true if polynomials have been requested
  61953. * @param onLoad defines the callback to trigger once the texture is ready
  61954. * @param onError defines the callback to trigger in case of error
  61955. */
  61956. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61957. /**
  61958. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61959. * @param data contains the texture data
  61960. * @param texture defines the BabylonJS internal texture
  61961. * @param callback defines the method to call once ready to upload
  61962. */
  61963. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61964. }
  61965. }
  61966. declare module BABYLON {
  61967. /**
  61968. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61969. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61970. */
  61971. export class KhronosTextureContainer {
  61972. /** contents of the KTX container file */
  61973. data: ArrayBufferView;
  61974. private static HEADER_LEN;
  61975. private static COMPRESSED_2D;
  61976. private static COMPRESSED_3D;
  61977. private static TEX_2D;
  61978. private static TEX_3D;
  61979. /**
  61980. * Gets the openGL type
  61981. */
  61982. glType: number;
  61983. /**
  61984. * Gets the openGL type size
  61985. */
  61986. glTypeSize: number;
  61987. /**
  61988. * Gets the openGL format
  61989. */
  61990. glFormat: number;
  61991. /**
  61992. * Gets the openGL internal format
  61993. */
  61994. glInternalFormat: number;
  61995. /**
  61996. * Gets the base internal format
  61997. */
  61998. glBaseInternalFormat: number;
  61999. /**
  62000. * Gets image width in pixel
  62001. */
  62002. pixelWidth: number;
  62003. /**
  62004. * Gets image height in pixel
  62005. */
  62006. pixelHeight: number;
  62007. /**
  62008. * Gets image depth in pixels
  62009. */
  62010. pixelDepth: number;
  62011. /**
  62012. * Gets the number of array elements
  62013. */
  62014. numberOfArrayElements: number;
  62015. /**
  62016. * Gets the number of faces
  62017. */
  62018. numberOfFaces: number;
  62019. /**
  62020. * Gets the number of mipmap levels
  62021. */
  62022. numberOfMipmapLevels: number;
  62023. /**
  62024. * Gets the bytes of key value data
  62025. */
  62026. bytesOfKeyValueData: number;
  62027. /**
  62028. * Gets the load type
  62029. */
  62030. loadType: number;
  62031. /**
  62032. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  62033. */
  62034. isInvalid: boolean;
  62035. /**
  62036. * Creates a new KhronosTextureContainer
  62037. * @param data contents of the KTX container file
  62038. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  62039. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  62040. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  62041. */
  62042. constructor(
  62043. /** contents of the KTX container file */
  62044. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  62045. /**
  62046. * Uploads KTX content to a Babylon Texture.
  62047. * It is assumed that the texture has already been created & is currently bound
  62048. * @hidden
  62049. */
  62050. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  62051. private _upload2DCompressedLevels;
  62052. /**
  62053. * Checks if the given data starts with a KTX file identifier.
  62054. * @param data the data to check
  62055. * @returns true if the data is a KTX file or false otherwise
  62056. */
  62057. static IsValid(data: ArrayBufferView): boolean;
  62058. }
  62059. }
  62060. declare module BABYLON {
  62061. /**
  62062. * Helper class to push actions to a pool of workers.
  62063. */
  62064. export class WorkerPool implements IDisposable {
  62065. private _workerInfos;
  62066. private _pendingActions;
  62067. /**
  62068. * Constructor
  62069. * @param workers Array of workers to use for actions
  62070. */
  62071. constructor(workers: Array<Worker>);
  62072. /**
  62073. * Terminates all workers and clears any pending actions.
  62074. */
  62075. dispose(): void;
  62076. /**
  62077. * Pushes an action to the worker pool. If all the workers are active, the action will be
  62078. * pended until a worker has completed its action.
  62079. * @param action The action to perform. Call onComplete when the action is complete.
  62080. */
  62081. push(action: (worker: Worker, onComplete: () => void) => void): void;
  62082. private _execute;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * Class for loading KTX2 files
  62088. */
  62089. export class KhronosTextureContainer2 {
  62090. private static _WorkerPoolPromise?;
  62091. private static _Initialized;
  62092. private static _Ktx2Decoder;
  62093. /**
  62094. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  62095. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  62096. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  62097. * Urls you can change:
  62098. * URLConfig.jsDecoderModule
  62099. * URLConfig.wasmUASTCToASTC
  62100. * URLConfig.wasmUASTCToBC7
  62101. * URLConfig.wasmUASTCToRGBA_UNORM
  62102. * URLConfig.wasmUASTCToRGBA_SRGB
  62103. * URLConfig.jsMSCTranscoder
  62104. * URLConfig.wasmMSCTranscoder
  62105. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#22
  62106. */
  62107. static URLConfig: {
  62108. jsDecoderModule: string;
  62109. wasmUASTCToASTC: null;
  62110. wasmUASTCToBC7: null;
  62111. wasmUASTCToRGBA_UNORM: null;
  62112. wasmUASTCToRGBA_SRGB: null;
  62113. jsMSCTranscoder: null;
  62114. wasmMSCTranscoder: null;
  62115. };
  62116. /**
  62117. * Default number of workers used to handle data decoding
  62118. */
  62119. static DefaultNumWorkers: number;
  62120. private static GetDefaultNumWorkers;
  62121. private _engine;
  62122. private static _CreateWorkerPool;
  62123. /**
  62124. * Constructor
  62125. * @param engine The engine to use
  62126. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  62127. */
  62128. constructor(engine: ThinEngine, numWorkers?: number);
  62129. /** @hidden */
  62130. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  62131. /**
  62132. * Stop all async operations and release resources.
  62133. */
  62134. dispose(): void;
  62135. protected _createTexture(data: any, internalTexture: InternalTexture, options?: any): void;
  62136. /**
  62137. * Checks if the given data starts with a KTX2 file identifier.
  62138. * @param data the data to check
  62139. * @returns true if the data is a KTX2 file or false otherwise
  62140. */
  62141. static IsValid(data: ArrayBufferView): boolean;
  62142. }
  62143. }
  62144. declare module BABYLON {
  62145. /**
  62146. * Implementation of the KTX Texture Loader.
  62147. * @hidden
  62148. */
  62149. export class _KTXTextureLoader implements IInternalTextureLoader {
  62150. /**
  62151. * Defines wether the loader supports cascade loading the different faces.
  62152. */
  62153. readonly supportCascades: boolean;
  62154. /**
  62155. * This returns if the loader support the current file information.
  62156. * @param extension defines the file extension of the file being loaded
  62157. * @param mimeType defines the optional mime type of the file being loaded
  62158. * @returns true if the loader can load the specified file
  62159. */
  62160. canLoad(extension: string, mimeType?: string): boolean;
  62161. /**
  62162. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62163. * @param data contains the texture data
  62164. * @param texture defines the BabylonJS internal texture
  62165. * @param createPolynomials will be true if polynomials have been requested
  62166. * @param onLoad defines the callback to trigger once the texture is ready
  62167. * @param onError defines the callback to trigger in case of error
  62168. */
  62169. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62170. /**
  62171. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62172. * @param data contains the texture data
  62173. * @param texture defines the BabylonJS internal texture
  62174. * @param callback defines the method to call once ready to upload
  62175. */
  62176. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  62177. }
  62178. }
  62179. declare module BABYLON {
  62180. /** @hidden */
  62181. export var _forceSceneHelpersToBundle: boolean;
  62182. interface Scene {
  62183. /**
  62184. * Creates a default light for the scene.
  62185. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  62186. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  62187. */
  62188. createDefaultLight(replace?: boolean): void;
  62189. /**
  62190. * Creates a default camera for the scene.
  62191. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  62192. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62193. * @param replace has default false, when true replaces the active camera in the scene
  62194. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  62195. */
  62196. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62197. /**
  62198. * Creates a default camera and a default light.
  62199. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  62200. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  62201. * @param replace has the default false, when true replaces the active camera/light in the scene
  62202. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  62203. */
  62204. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  62205. /**
  62206. * Creates a new sky box
  62207. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  62208. * @param environmentTexture defines the texture to use as environment texture
  62209. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  62210. * @param scale defines the overall scale of the skybox
  62211. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  62212. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  62213. * @returns a new mesh holding the sky box
  62214. */
  62215. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  62216. /**
  62217. * Creates a new environment
  62218. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  62219. * @param options defines the options you can use to configure the environment
  62220. * @returns the new EnvironmentHelper
  62221. */
  62222. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  62223. /**
  62224. * Creates a new VREXperienceHelper
  62225. * @see https://doc.babylonjs.com/how_to/webvr_helper
  62226. * @param webVROptions defines the options used to create the new VREXperienceHelper
  62227. * @returns a new VREXperienceHelper
  62228. */
  62229. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  62230. /**
  62231. * Creates a new WebXRDefaultExperience
  62232. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  62233. * @param options experience options
  62234. * @returns a promise for a new WebXRDefaultExperience
  62235. */
  62236. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  62237. }
  62238. }
  62239. declare module BABYLON {
  62240. /**
  62241. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  62242. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  62243. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  62244. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  62245. */
  62246. export class VideoDome extends TextureDome<VideoTexture> {
  62247. /**
  62248. * Define the video source as a Monoscopic panoramic 360 video.
  62249. */
  62250. static readonly MODE_MONOSCOPIC: number;
  62251. /**
  62252. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  62253. */
  62254. static readonly MODE_TOPBOTTOM: number;
  62255. /**
  62256. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  62257. */
  62258. static readonly MODE_SIDEBYSIDE: number;
  62259. /**
  62260. * Get the video texture associated with this video dome
  62261. */
  62262. get videoTexture(): VideoTexture;
  62263. /**
  62264. * Get the video mode of this dome
  62265. */
  62266. get videoMode(): number;
  62267. /**
  62268. * Set the video mode of this dome.
  62269. * @see textureMode
  62270. */
  62271. set videoMode(value: number);
  62272. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  62273. }
  62274. }
  62275. declare module BABYLON {
  62276. /**
  62277. * This class can be used to get instrumentation data from a Babylon engine
  62278. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62279. */
  62280. export class EngineInstrumentation implements IDisposable {
  62281. /**
  62282. * Define the instrumented engine.
  62283. */
  62284. engine: Engine;
  62285. private _captureGPUFrameTime;
  62286. private _gpuFrameTimeToken;
  62287. private _gpuFrameTime;
  62288. private _captureShaderCompilationTime;
  62289. private _shaderCompilationTime;
  62290. private _onBeginFrameObserver;
  62291. private _onEndFrameObserver;
  62292. private _onBeforeShaderCompilationObserver;
  62293. private _onAfterShaderCompilationObserver;
  62294. /**
  62295. * Gets the perf counter used for GPU frame time
  62296. */
  62297. get gpuFrameTimeCounter(): PerfCounter;
  62298. /**
  62299. * Gets the GPU frame time capture status
  62300. */
  62301. get captureGPUFrameTime(): boolean;
  62302. /**
  62303. * Enable or disable the GPU frame time capture
  62304. */
  62305. set captureGPUFrameTime(value: boolean);
  62306. /**
  62307. * Gets the perf counter used for shader compilation time
  62308. */
  62309. get shaderCompilationTimeCounter(): PerfCounter;
  62310. /**
  62311. * Gets the shader compilation time capture status
  62312. */
  62313. get captureShaderCompilationTime(): boolean;
  62314. /**
  62315. * Enable or disable the shader compilation time capture
  62316. */
  62317. set captureShaderCompilationTime(value: boolean);
  62318. /**
  62319. * Instantiates a new engine instrumentation.
  62320. * This class can be used to get instrumentation data from a Babylon engine
  62321. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  62322. * @param engine Defines the engine to instrument
  62323. */
  62324. constructor(
  62325. /**
  62326. * Define the instrumented engine.
  62327. */
  62328. engine: Engine);
  62329. /**
  62330. * Dispose and release associated resources.
  62331. */
  62332. dispose(): void;
  62333. }
  62334. }
  62335. declare module BABYLON {
  62336. /**
  62337. * This class can be used to get instrumentation data from a Babylon engine
  62338. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62339. */
  62340. export class SceneInstrumentation implements IDisposable {
  62341. /**
  62342. * Defines the scene to instrument
  62343. */
  62344. scene: Scene;
  62345. private _captureActiveMeshesEvaluationTime;
  62346. private _activeMeshesEvaluationTime;
  62347. private _captureRenderTargetsRenderTime;
  62348. private _renderTargetsRenderTime;
  62349. private _captureFrameTime;
  62350. private _frameTime;
  62351. private _captureRenderTime;
  62352. private _renderTime;
  62353. private _captureInterFrameTime;
  62354. private _interFrameTime;
  62355. private _captureParticlesRenderTime;
  62356. private _particlesRenderTime;
  62357. private _captureSpritesRenderTime;
  62358. private _spritesRenderTime;
  62359. private _capturePhysicsTime;
  62360. private _physicsTime;
  62361. private _captureAnimationsTime;
  62362. private _animationsTime;
  62363. private _captureCameraRenderTime;
  62364. private _cameraRenderTime;
  62365. private _onBeforeActiveMeshesEvaluationObserver;
  62366. private _onAfterActiveMeshesEvaluationObserver;
  62367. private _onBeforeRenderTargetsRenderObserver;
  62368. private _onAfterRenderTargetsRenderObserver;
  62369. private _onAfterRenderObserver;
  62370. private _onBeforeDrawPhaseObserver;
  62371. private _onAfterDrawPhaseObserver;
  62372. private _onBeforeAnimationsObserver;
  62373. private _onBeforeParticlesRenderingObserver;
  62374. private _onAfterParticlesRenderingObserver;
  62375. private _onBeforeSpritesRenderingObserver;
  62376. private _onAfterSpritesRenderingObserver;
  62377. private _onBeforePhysicsObserver;
  62378. private _onAfterPhysicsObserver;
  62379. private _onAfterAnimationsObserver;
  62380. private _onBeforeCameraRenderObserver;
  62381. private _onAfterCameraRenderObserver;
  62382. /**
  62383. * Gets the perf counter used for active meshes evaluation time
  62384. */
  62385. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  62386. /**
  62387. * Gets the active meshes evaluation time capture status
  62388. */
  62389. get captureActiveMeshesEvaluationTime(): boolean;
  62390. /**
  62391. * Enable or disable the active meshes evaluation time capture
  62392. */
  62393. set captureActiveMeshesEvaluationTime(value: boolean);
  62394. /**
  62395. * Gets the perf counter used for render targets render time
  62396. */
  62397. get renderTargetsRenderTimeCounter(): PerfCounter;
  62398. /**
  62399. * Gets the render targets render time capture status
  62400. */
  62401. get captureRenderTargetsRenderTime(): boolean;
  62402. /**
  62403. * Enable or disable the render targets render time capture
  62404. */
  62405. set captureRenderTargetsRenderTime(value: boolean);
  62406. /**
  62407. * Gets the perf counter used for particles render time
  62408. */
  62409. get particlesRenderTimeCounter(): PerfCounter;
  62410. /**
  62411. * Gets the particles render time capture status
  62412. */
  62413. get captureParticlesRenderTime(): boolean;
  62414. /**
  62415. * Enable or disable the particles render time capture
  62416. */
  62417. set captureParticlesRenderTime(value: boolean);
  62418. /**
  62419. * Gets the perf counter used for sprites render time
  62420. */
  62421. get spritesRenderTimeCounter(): PerfCounter;
  62422. /**
  62423. * Gets the sprites render time capture status
  62424. */
  62425. get captureSpritesRenderTime(): boolean;
  62426. /**
  62427. * Enable or disable the sprites render time capture
  62428. */
  62429. set captureSpritesRenderTime(value: boolean);
  62430. /**
  62431. * Gets the perf counter used for physics time
  62432. */
  62433. get physicsTimeCounter(): PerfCounter;
  62434. /**
  62435. * Gets the physics time capture status
  62436. */
  62437. get capturePhysicsTime(): boolean;
  62438. /**
  62439. * Enable or disable the physics time capture
  62440. */
  62441. set capturePhysicsTime(value: boolean);
  62442. /**
  62443. * Gets the perf counter used for animations time
  62444. */
  62445. get animationsTimeCounter(): PerfCounter;
  62446. /**
  62447. * Gets the animations time capture status
  62448. */
  62449. get captureAnimationsTime(): boolean;
  62450. /**
  62451. * Enable or disable the animations time capture
  62452. */
  62453. set captureAnimationsTime(value: boolean);
  62454. /**
  62455. * Gets the perf counter used for frame time capture
  62456. */
  62457. get frameTimeCounter(): PerfCounter;
  62458. /**
  62459. * Gets the frame time capture status
  62460. */
  62461. get captureFrameTime(): boolean;
  62462. /**
  62463. * Enable or disable the frame time capture
  62464. */
  62465. set captureFrameTime(value: boolean);
  62466. /**
  62467. * Gets the perf counter used for inter-frames time capture
  62468. */
  62469. get interFrameTimeCounter(): PerfCounter;
  62470. /**
  62471. * Gets the inter-frames time capture status
  62472. */
  62473. get captureInterFrameTime(): boolean;
  62474. /**
  62475. * Enable or disable the inter-frames time capture
  62476. */
  62477. set captureInterFrameTime(value: boolean);
  62478. /**
  62479. * Gets the perf counter used for render time capture
  62480. */
  62481. get renderTimeCounter(): PerfCounter;
  62482. /**
  62483. * Gets the render time capture status
  62484. */
  62485. get captureRenderTime(): boolean;
  62486. /**
  62487. * Enable or disable the render time capture
  62488. */
  62489. set captureRenderTime(value: boolean);
  62490. /**
  62491. * Gets the perf counter used for camera render time capture
  62492. */
  62493. get cameraRenderTimeCounter(): PerfCounter;
  62494. /**
  62495. * Gets the camera render time capture status
  62496. */
  62497. get captureCameraRenderTime(): boolean;
  62498. /**
  62499. * Enable or disable the camera render time capture
  62500. */
  62501. set captureCameraRenderTime(value: boolean);
  62502. /**
  62503. * Gets the perf counter used for draw calls
  62504. */
  62505. get drawCallsCounter(): PerfCounter;
  62506. /**
  62507. * Instantiates a new scene instrumentation.
  62508. * This class can be used to get instrumentation data from a Babylon engine
  62509. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  62510. * @param scene Defines the scene to instrument
  62511. */
  62512. constructor(
  62513. /**
  62514. * Defines the scene to instrument
  62515. */
  62516. scene: Scene);
  62517. /**
  62518. * Dispose and release associated resources.
  62519. */
  62520. dispose(): void;
  62521. }
  62522. }
  62523. declare module BABYLON {
  62524. /** @hidden */
  62525. export var glowMapGenerationPixelShader: {
  62526. name: string;
  62527. shader: string;
  62528. };
  62529. }
  62530. declare module BABYLON {
  62531. /** @hidden */
  62532. export var glowMapGenerationVertexShader: {
  62533. name: string;
  62534. shader: string;
  62535. };
  62536. }
  62537. declare module BABYLON {
  62538. /**
  62539. * Effect layer options. This helps customizing the behaviour
  62540. * of the effect layer.
  62541. */
  62542. export interface IEffectLayerOptions {
  62543. /**
  62544. * Multiplication factor apply to the canvas size to compute the render target size
  62545. * used to generated the objects (the smaller the faster).
  62546. */
  62547. mainTextureRatio: number;
  62548. /**
  62549. * Enforces a fixed size texture to ensure effect stability across devices.
  62550. */
  62551. mainTextureFixedSize?: number;
  62552. /**
  62553. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62554. */
  62555. alphaBlendingMode: number;
  62556. /**
  62557. * The camera attached to the layer.
  62558. */
  62559. camera: Nullable<Camera>;
  62560. /**
  62561. * The rendering group to draw the layer in.
  62562. */
  62563. renderingGroupId: number;
  62564. }
  62565. /**
  62566. * The effect layer Helps adding post process effect blended with the main pass.
  62567. *
  62568. * This can be for instance use to generate glow or higlight effects on the scene.
  62569. *
  62570. * The effect layer class can not be used directly and is intented to inherited from to be
  62571. * customized per effects.
  62572. */
  62573. export abstract class EffectLayer {
  62574. private _vertexBuffers;
  62575. private _indexBuffer;
  62576. private _cachedDefines;
  62577. private _effectLayerMapGenerationEffect;
  62578. private _effectLayerOptions;
  62579. private _mergeEffect;
  62580. protected _scene: Scene;
  62581. protected _engine: Engine;
  62582. protected _maxSize: number;
  62583. protected _mainTextureDesiredSize: ISize;
  62584. protected _mainTexture: RenderTargetTexture;
  62585. protected _shouldRender: boolean;
  62586. protected _postProcesses: PostProcess[];
  62587. protected _textures: BaseTexture[];
  62588. protected _emissiveTextureAndColor: {
  62589. texture: Nullable<BaseTexture>;
  62590. color: Color4;
  62591. };
  62592. /**
  62593. * The name of the layer
  62594. */
  62595. name: string;
  62596. /**
  62597. * The clear color of the texture used to generate the glow map.
  62598. */
  62599. neutralColor: Color4;
  62600. /**
  62601. * Specifies whether the highlight layer is enabled or not.
  62602. */
  62603. isEnabled: boolean;
  62604. /**
  62605. * Gets the camera attached to the layer.
  62606. */
  62607. get camera(): Nullable<Camera>;
  62608. /**
  62609. * Gets the rendering group id the layer should render in.
  62610. */
  62611. get renderingGroupId(): number;
  62612. set renderingGroupId(renderingGroupId: number);
  62613. /**
  62614. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62615. */
  62616. disableBoundingBoxesFromEffectLayer: boolean;
  62617. /**
  62618. * An event triggered when the effect layer has been disposed.
  62619. */
  62620. onDisposeObservable: Observable<EffectLayer>;
  62621. /**
  62622. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62623. */
  62624. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62625. /**
  62626. * An event triggered when the generated texture is being merged in the scene.
  62627. */
  62628. onBeforeComposeObservable: Observable<EffectLayer>;
  62629. /**
  62630. * An event triggered when the mesh is rendered into the effect render target.
  62631. */
  62632. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62633. /**
  62634. * An event triggered after the mesh has been rendered into the effect render target.
  62635. */
  62636. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62637. /**
  62638. * An event triggered when the generated texture has been merged in the scene.
  62639. */
  62640. onAfterComposeObservable: Observable<EffectLayer>;
  62641. /**
  62642. * An event triggered when the efffect layer changes its size.
  62643. */
  62644. onSizeChangedObservable: Observable<EffectLayer>;
  62645. /** @hidden */
  62646. static _SceneComponentInitialization: (scene: Scene) => void;
  62647. /**
  62648. * Instantiates a new effect Layer and references it in the scene.
  62649. * @param name The name of the layer
  62650. * @param scene The scene to use the layer in
  62651. */
  62652. constructor(
  62653. /** The Friendly of the effect in the scene */
  62654. name: string, scene: Scene);
  62655. /**
  62656. * Get the effect name of the layer.
  62657. * @return The effect name
  62658. */
  62659. abstract getEffectName(): string;
  62660. /**
  62661. * Checks for the readiness of the element composing the layer.
  62662. * @param subMesh the mesh to check for
  62663. * @param useInstances specify whether or not to use instances to render the mesh
  62664. * @return true if ready otherwise, false
  62665. */
  62666. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62667. /**
  62668. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62669. * @returns true if the effect requires stencil during the main canvas render pass.
  62670. */
  62671. abstract needStencil(): boolean;
  62672. /**
  62673. * Create the merge effect. This is the shader use to blit the information back
  62674. * to the main canvas at the end of the scene rendering.
  62675. * @returns The effect containing the shader used to merge the effect on the main canvas
  62676. */
  62677. protected abstract _createMergeEffect(): Effect;
  62678. /**
  62679. * Creates the render target textures and post processes used in the effect layer.
  62680. */
  62681. protected abstract _createTextureAndPostProcesses(): void;
  62682. /**
  62683. * Implementation specific of rendering the generating effect on the main canvas.
  62684. * @param effect The effect used to render through
  62685. */
  62686. protected abstract _internalRender(effect: Effect): void;
  62687. /**
  62688. * Sets the required values for both the emissive texture and and the main color.
  62689. */
  62690. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62691. /**
  62692. * Free any resources and references associated to a mesh.
  62693. * Internal use
  62694. * @param mesh The mesh to free.
  62695. */
  62696. abstract _disposeMesh(mesh: Mesh): void;
  62697. /**
  62698. * Serializes this layer (Glow or Highlight for example)
  62699. * @returns a serialized layer object
  62700. */
  62701. abstract serialize?(): any;
  62702. /**
  62703. * Initializes the effect layer with the required options.
  62704. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62705. */
  62706. protected _init(options: Partial<IEffectLayerOptions>): void;
  62707. /**
  62708. * Generates the index buffer of the full screen quad blending to the main canvas.
  62709. */
  62710. private _generateIndexBuffer;
  62711. /**
  62712. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62713. */
  62714. private _generateVertexBuffer;
  62715. /**
  62716. * Sets the main texture desired size which is the closest power of two
  62717. * of the engine canvas size.
  62718. */
  62719. private _setMainTextureSize;
  62720. /**
  62721. * Creates the main texture for the effect layer.
  62722. */
  62723. protected _createMainTexture(): void;
  62724. /**
  62725. * Adds specific effects defines.
  62726. * @param defines The defines to add specifics to.
  62727. */
  62728. protected _addCustomEffectDefines(defines: string[]): void;
  62729. /**
  62730. * Checks for the readiness of the element composing the layer.
  62731. * @param subMesh the mesh to check for
  62732. * @param useInstances specify whether or not to use instances to render the mesh
  62733. * @param emissiveTexture the associated emissive texture used to generate the glow
  62734. * @return true if ready otherwise, false
  62735. */
  62736. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62737. /**
  62738. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62739. */
  62740. render(): void;
  62741. /**
  62742. * Determine if a given mesh will be used in the current effect.
  62743. * @param mesh mesh to test
  62744. * @returns true if the mesh will be used
  62745. */
  62746. hasMesh(mesh: AbstractMesh): boolean;
  62747. /**
  62748. * Returns true if the layer contains information to display, otherwise false.
  62749. * @returns true if the glow layer should be rendered
  62750. */
  62751. shouldRender(): boolean;
  62752. /**
  62753. * Returns true if the mesh should render, otherwise false.
  62754. * @param mesh The mesh to render
  62755. * @returns true if it should render otherwise false
  62756. */
  62757. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62758. /**
  62759. * Returns true if the mesh can be rendered, otherwise false.
  62760. * @param mesh The mesh to render
  62761. * @param material The material used on the mesh
  62762. * @returns true if it can be rendered otherwise false
  62763. */
  62764. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62765. /**
  62766. * Returns true if the mesh should render, otherwise false.
  62767. * @param mesh The mesh to render
  62768. * @returns true if it should render otherwise false
  62769. */
  62770. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62771. /**
  62772. * Renders the submesh passed in parameter to the generation map.
  62773. */
  62774. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62775. /**
  62776. * Defines whether the current material of the mesh should be use to render the effect.
  62777. * @param mesh defines the current mesh to render
  62778. */
  62779. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62780. /**
  62781. * Rebuild the required buffers.
  62782. * @hidden Internal use only.
  62783. */
  62784. _rebuild(): void;
  62785. /**
  62786. * Dispose only the render target textures and post process.
  62787. */
  62788. private _disposeTextureAndPostProcesses;
  62789. /**
  62790. * Dispose the highlight layer and free resources.
  62791. */
  62792. dispose(): void;
  62793. /**
  62794. * Gets the class name of the effect layer
  62795. * @returns the string with the class name of the effect layer
  62796. */
  62797. getClassName(): string;
  62798. /**
  62799. * Creates an effect layer from parsed effect layer data
  62800. * @param parsedEffectLayer defines effect layer data
  62801. * @param scene defines the current scene
  62802. * @param rootUrl defines the root URL containing the effect layer information
  62803. * @returns a parsed effect Layer
  62804. */
  62805. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62806. }
  62807. }
  62808. declare module BABYLON {
  62809. interface AbstractScene {
  62810. /**
  62811. * The list of effect layers (highlights/glow) added to the scene
  62812. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62813. * @see https://doc.babylonjs.com/how_to/glow_layer
  62814. */
  62815. effectLayers: Array<EffectLayer>;
  62816. /**
  62817. * Removes the given effect layer from this scene.
  62818. * @param toRemove defines the effect layer to remove
  62819. * @returns the index of the removed effect layer
  62820. */
  62821. removeEffectLayer(toRemove: EffectLayer): number;
  62822. /**
  62823. * Adds the given effect layer to this scene
  62824. * @param newEffectLayer defines the effect layer to add
  62825. */
  62826. addEffectLayer(newEffectLayer: EffectLayer): void;
  62827. }
  62828. /**
  62829. * Defines the layer scene component responsible to manage any effect layers
  62830. * in a given scene.
  62831. */
  62832. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62833. /**
  62834. * The component name helpfull to identify the component in the list of scene components.
  62835. */
  62836. readonly name: string;
  62837. /**
  62838. * The scene the component belongs to.
  62839. */
  62840. scene: Scene;
  62841. private _engine;
  62842. private _renderEffects;
  62843. private _needStencil;
  62844. private _previousStencilState;
  62845. /**
  62846. * Creates a new instance of the component for the given scene
  62847. * @param scene Defines the scene to register the component in
  62848. */
  62849. constructor(scene: Scene);
  62850. /**
  62851. * Registers the component in a given scene
  62852. */
  62853. register(): void;
  62854. /**
  62855. * Rebuilds the elements related to this component in case of
  62856. * context lost for instance.
  62857. */
  62858. rebuild(): void;
  62859. /**
  62860. * Serializes the component data to the specified json object
  62861. * @param serializationObject The object to serialize to
  62862. */
  62863. serialize(serializationObject: any): void;
  62864. /**
  62865. * Adds all the elements from the container to the scene
  62866. * @param container the container holding the elements
  62867. */
  62868. addFromContainer(container: AbstractScene): void;
  62869. /**
  62870. * Removes all the elements in the container from the scene
  62871. * @param container contains the elements to remove
  62872. * @param dispose if the removed element should be disposed (default: false)
  62873. */
  62874. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62875. /**
  62876. * Disposes the component and the associated ressources.
  62877. */
  62878. dispose(): void;
  62879. private _isReadyForMesh;
  62880. private _renderMainTexture;
  62881. private _setStencil;
  62882. private _setStencilBack;
  62883. private _draw;
  62884. private _drawCamera;
  62885. private _drawRenderingGroup;
  62886. }
  62887. }
  62888. declare module BABYLON {
  62889. /** @hidden */
  62890. export var glowMapMergePixelShader: {
  62891. name: string;
  62892. shader: string;
  62893. };
  62894. }
  62895. declare module BABYLON {
  62896. /** @hidden */
  62897. export var glowMapMergeVertexShader: {
  62898. name: string;
  62899. shader: string;
  62900. };
  62901. }
  62902. declare module BABYLON {
  62903. interface AbstractScene {
  62904. /**
  62905. * Return a the first highlight layer of the scene with a given name.
  62906. * @param name The name of the highlight layer to look for.
  62907. * @return The highlight layer if found otherwise null.
  62908. */
  62909. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62910. }
  62911. /**
  62912. * Glow layer options. This helps customizing the behaviour
  62913. * of the glow layer.
  62914. */
  62915. export interface IGlowLayerOptions {
  62916. /**
  62917. * Multiplication factor apply to the canvas size to compute the render target size
  62918. * used to generated the glowing objects (the smaller the faster).
  62919. */
  62920. mainTextureRatio: number;
  62921. /**
  62922. * Enforces a fixed size texture to ensure resize independant blur.
  62923. */
  62924. mainTextureFixedSize?: number;
  62925. /**
  62926. * How big is the kernel of the blur texture.
  62927. */
  62928. blurKernelSize: number;
  62929. /**
  62930. * The camera attached to the layer.
  62931. */
  62932. camera: Nullable<Camera>;
  62933. /**
  62934. * Enable MSAA by chosing the number of samples.
  62935. */
  62936. mainTextureSamples?: number;
  62937. /**
  62938. * The rendering group to draw the layer in.
  62939. */
  62940. renderingGroupId: number;
  62941. }
  62942. /**
  62943. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62944. *
  62945. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62946. *
  62947. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62948. */
  62949. export class GlowLayer extends EffectLayer {
  62950. /**
  62951. * Effect Name of the layer.
  62952. */
  62953. static readonly EffectName: string;
  62954. /**
  62955. * The default blur kernel size used for the glow.
  62956. */
  62957. static DefaultBlurKernelSize: number;
  62958. /**
  62959. * The default texture size ratio used for the glow.
  62960. */
  62961. static DefaultTextureRatio: number;
  62962. /**
  62963. * Sets the kernel size of the blur.
  62964. */
  62965. set blurKernelSize(value: number);
  62966. /**
  62967. * Gets the kernel size of the blur.
  62968. */
  62969. get blurKernelSize(): number;
  62970. /**
  62971. * Sets the glow intensity.
  62972. */
  62973. set intensity(value: number);
  62974. /**
  62975. * Gets the glow intensity.
  62976. */
  62977. get intensity(): number;
  62978. private _options;
  62979. private _intensity;
  62980. private _horizontalBlurPostprocess1;
  62981. private _verticalBlurPostprocess1;
  62982. private _horizontalBlurPostprocess2;
  62983. private _verticalBlurPostprocess2;
  62984. private _blurTexture1;
  62985. private _blurTexture2;
  62986. private _postProcesses1;
  62987. private _postProcesses2;
  62988. private _includedOnlyMeshes;
  62989. private _excludedMeshes;
  62990. private _meshesUsingTheirOwnMaterials;
  62991. /**
  62992. * Callback used to let the user override the color selection on a per mesh basis
  62993. */
  62994. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62995. /**
  62996. * Callback used to let the user override the texture selection on a per mesh basis
  62997. */
  62998. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62999. /**
  63000. * Instantiates a new glow Layer and references it to the scene.
  63001. * @param name The name of the layer
  63002. * @param scene The scene to use the layer in
  63003. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  63004. */
  63005. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  63006. /**
  63007. * Get the effect name of the layer.
  63008. * @return The effect name
  63009. */
  63010. getEffectName(): string;
  63011. /**
  63012. * Create the merge effect. This is the shader use to blit the information back
  63013. * to the main canvas at the end of the scene rendering.
  63014. */
  63015. protected _createMergeEffect(): Effect;
  63016. /**
  63017. * Creates the render target textures and post processes used in the glow layer.
  63018. */
  63019. protected _createTextureAndPostProcesses(): void;
  63020. /**
  63021. * Checks for the readiness of the element composing the layer.
  63022. * @param subMesh the mesh to check for
  63023. * @param useInstances specify wether or not to use instances to render the mesh
  63024. * @param emissiveTexture the associated emissive texture used to generate the glow
  63025. * @return true if ready otherwise, false
  63026. */
  63027. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63028. /**
  63029. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  63030. */
  63031. needStencil(): boolean;
  63032. /**
  63033. * Returns true if the mesh can be rendered, otherwise false.
  63034. * @param mesh The mesh to render
  63035. * @param material The material used on the mesh
  63036. * @returns true if it can be rendered otherwise false
  63037. */
  63038. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63039. /**
  63040. * Implementation specific of rendering the generating effect on the main canvas.
  63041. * @param effect The effect used to render through
  63042. */
  63043. protected _internalRender(effect: Effect): void;
  63044. /**
  63045. * Sets the required values for both the emissive texture and and the main color.
  63046. */
  63047. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63048. /**
  63049. * Returns true if the mesh should render, otherwise false.
  63050. * @param mesh The mesh to render
  63051. * @returns true if it should render otherwise false
  63052. */
  63053. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63054. /**
  63055. * Adds specific effects defines.
  63056. * @param defines The defines to add specifics to.
  63057. */
  63058. protected _addCustomEffectDefines(defines: string[]): void;
  63059. /**
  63060. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  63061. * @param mesh The mesh to exclude from the glow layer
  63062. */
  63063. addExcludedMesh(mesh: Mesh): void;
  63064. /**
  63065. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  63066. * @param mesh The mesh to remove
  63067. */
  63068. removeExcludedMesh(mesh: Mesh): void;
  63069. /**
  63070. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  63071. * @param mesh The mesh to include in the glow layer
  63072. */
  63073. addIncludedOnlyMesh(mesh: Mesh): void;
  63074. /**
  63075. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  63076. * @param mesh The mesh to remove
  63077. */
  63078. removeIncludedOnlyMesh(mesh: Mesh): void;
  63079. /**
  63080. * Determine if a given mesh will be used in the glow layer
  63081. * @param mesh The mesh to test
  63082. * @returns true if the mesh will be highlighted by the current glow layer
  63083. */
  63084. hasMesh(mesh: AbstractMesh): boolean;
  63085. /**
  63086. * Defines whether the current material of the mesh should be use to render the effect.
  63087. * @param mesh defines the current mesh to render
  63088. */
  63089. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  63090. /**
  63091. * Add a mesh to be rendered through its own material and not with emissive only.
  63092. * @param mesh The mesh for which we need to use its material
  63093. */
  63094. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  63095. /**
  63096. * Remove a mesh from being rendered through its own material and not with emissive only.
  63097. * @param mesh The mesh for which we need to not use its material
  63098. */
  63099. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  63100. /**
  63101. * Free any resources and references associated to a mesh.
  63102. * Internal use
  63103. * @param mesh The mesh to free.
  63104. * @hidden
  63105. */
  63106. _disposeMesh(mesh: Mesh): void;
  63107. /**
  63108. * Gets the class name of the effect layer
  63109. * @returns the string with the class name of the effect layer
  63110. */
  63111. getClassName(): string;
  63112. /**
  63113. * Serializes this glow layer
  63114. * @returns a serialized glow layer object
  63115. */
  63116. serialize(): any;
  63117. /**
  63118. * Creates a Glow Layer from parsed glow layer data
  63119. * @param parsedGlowLayer defines glow layer data
  63120. * @param scene defines the current scene
  63121. * @param rootUrl defines the root URL containing the glow layer information
  63122. * @returns a parsed Glow Layer
  63123. */
  63124. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  63125. }
  63126. }
  63127. declare module BABYLON {
  63128. /** @hidden */
  63129. export var glowBlurPostProcessPixelShader: {
  63130. name: string;
  63131. shader: string;
  63132. };
  63133. }
  63134. declare module BABYLON {
  63135. interface AbstractScene {
  63136. /**
  63137. * Return a the first highlight layer of the scene with a given name.
  63138. * @param name The name of the highlight layer to look for.
  63139. * @return The highlight layer if found otherwise null.
  63140. */
  63141. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  63142. }
  63143. /**
  63144. * Highlight layer options. This helps customizing the behaviour
  63145. * of the highlight layer.
  63146. */
  63147. export interface IHighlightLayerOptions {
  63148. /**
  63149. * Multiplication factor apply to the canvas size to compute the render target size
  63150. * used to generated the glowing objects (the smaller the faster).
  63151. */
  63152. mainTextureRatio: number;
  63153. /**
  63154. * Enforces a fixed size texture to ensure resize independant blur.
  63155. */
  63156. mainTextureFixedSize?: number;
  63157. /**
  63158. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  63159. * of the picture to blur (the smaller the faster).
  63160. */
  63161. blurTextureSizeRatio: number;
  63162. /**
  63163. * How big in texel of the blur texture is the vertical blur.
  63164. */
  63165. blurVerticalSize: number;
  63166. /**
  63167. * How big in texel of the blur texture is the horizontal blur.
  63168. */
  63169. blurHorizontalSize: number;
  63170. /**
  63171. * Alpha blending mode used to apply the blur. Default is combine.
  63172. */
  63173. alphaBlendingMode: number;
  63174. /**
  63175. * The camera attached to the layer.
  63176. */
  63177. camera: Nullable<Camera>;
  63178. /**
  63179. * Should we display highlight as a solid stroke?
  63180. */
  63181. isStroke?: boolean;
  63182. /**
  63183. * The rendering group to draw the layer in.
  63184. */
  63185. renderingGroupId: number;
  63186. }
  63187. /**
  63188. * The highlight layer Helps adding a glow effect around a mesh.
  63189. *
  63190. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  63191. * glowy meshes to your scene.
  63192. *
  63193. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  63194. */
  63195. export class HighlightLayer extends EffectLayer {
  63196. name: string;
  63197. /**
  63198. * Effect Name of the highlight layer.
  63199. */
  63200. static readonly EffectName: string;
  63201. /**
  63202. * The neutral color used during the preparation of the glow effect.
  63203. * This is black by default as the blend operation is a blend operation.
  63204. */
  63205. static NeutralColor: Color4;
  63206. /**
  63207. * Stencil value used for glowing meshes.
  63208. */
  63209. static GlowingMeshStencilReference: number;
  63210. /**
  63211. * Stencil value used for the other meshes in the scene.
  63212. */
  63213. static NormalMeshStencilReference: number;
  63214. /**
  63215. * Specifies whether or not the inner glow is ACTIVE in the layer.
  63216. */
  63217. innerGlow: boolean;
  63218. /**
  63219. * Specifies whether or not the outer glow is ACTIVE in the layer.
  63220. */
  63221. outerGlow: boolean;
  63222. /**
  63223. * Specifies the horizontal size of the blur.
  63224. */
  63225. set blurHorizontalSize(value: number);
  63226. /**
  63227. * Specifies the vertical size of the blur.
  63228. */
  63229. set blurVerticalSize(value: number);
  63230. /**
  63231. * Gets the horizontal size of the blur.
  63232. */
  63233. get blurHorizontalSize(): number;
  63234. /**
  63235. * Gets the vertical size of the blur.
  63236. */
  63237. get blurVerticalSize(): number;
  63238. /**
  63239. * An event triggered when the highlight layer is being blurred.
  63240. */
  63241. onBeforeBlurObservable: Observable<HighlightLayer>;
  63242. /**
  63243. * An event triggered when the highlight layer has been blurred.
  63244. */
  63245. onAfterBlurObservable: Observable<HighlightLayer>;
  63246. private _instanceGlowingMeshStencilReference;
  63247. private _options;
  63248. private _downSamplePostprocess;
  63249. private _horizontalBlurPostprocess;
  63250. private _verticalBlurPostprocess;
  63251. private _blurTexture;
  63252. private _meshes;
  63253. private _excludedMeshes;
  63254. /**
  63255. * Instantiates a new highlight Layer and references it to the scene..
  63256. * @param name The name of the layer
  63257. * @param scene The scene to use the layer in
  63258. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  63259. */
  63260. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  63261. /**
  63262. * Get the effect name of the layer.
  63263. * @return The effect name
  63264. */
  63265. getEffectName(): string;
  63266. /**
  63267. * Create the merge effect. This is the shader use to blit the information back
  63268. * to the main canvas at the end of the scene rendering.
  63269. */
  63270. protected _createMergeEffect(): Effect;
  63271. /**
  63272. * Creates the render target textures and post processes used in the highlight layer.
  63273. */
  63274. protected _createTextureAndPostProcesses(): void;
  63275. /**
  63276. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  63277. */
  63278. needStencil(): boolean;
  63279. /**
  63280. * Checks for the readiness of the element composing the layer.
  63281. * @param subMesh the mesh to check for
  63282. * @param useInstances specify wether or not to use instances to render the mesh
  63283. * @param emissiveTexture the associated emissive texture used to generate the glow
  63284. * @return true if ready otherwise, false
  63285. */
  63286. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63287. /**
  63288. * Implementation specific of rendering the generating effect on the main canvas.
  63289. * @param effect The effect used to render through
  63290. */
  63291. protected _internalRender(effect: Effect): void;
  63292. /**
  63293. * Returns true if the layer contains information to display, otherwise false.
  63294. */
  63295. shouldRender(): boolean;
  63296. /**
  63297. * Returns true if the mesh should render, otherwise false.
  63298. * @param mesh The mesh to render
  63299. * @returns true if it should render otherwise false
  63300. */
  63301. protected _shouldRenderMesh(mesh: Mesh): boolean;
  63302. /**
  63303. * Returns true if the mesh can be rendered, otherwise false.
  63304. * @param mesh The mesh to render
  63305. * @param material The material used on the mesh
  63306. * @returns true if it can be rendered otherwise false
  63307. */
  63308. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  63309. /**
  63310. * Adds specific effects defines.
  63311. * @param defines The defines to add specifics to.
  63312. */
  63313. protected _addCustomEffectDefines(defines: string[]): void;
  63314. /**
  63315. * Sets the required values for both the emissive texture and and the main color.
  63316. */
  63317. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  63318. /**
  63319. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  63320. * @param mesh The mesh to exclude from the highlight layer
  63321. */
  63322. addExcludedMesh(mesh: Mesh): void;
  63323. /**
  63324. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  63325. * @param mesh The mesh to highlight
  63326. */
  63327. removeExcludedMesh(mesh: Mesh): void;
  63328. /**
  63329. * Determine if a given mesh will be highlighted by the current HighlightLayer
  63330. * @param mesh mesh to test
  63331. * @returns true if the mesh will be highlighted by the current HighlightLayer
  63332. */
  63333. hasMesh(mesh: AbstractMesh): boolean;
  63334. /**
  63335. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  63336. * @param mesh The mesh to highlight
  63337. * @param color The color of the highlight
  63338. * @param glowEmissiveOnly Extract the glow from the emissive texture
  63339. */
  63340. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  63341. /**
  63342. * Remove a mesh from the highlight layer in order to make it stop glowing.
  63343. * @param mesh The mesh to highlight
  63344. */
  63345. removeMesh(mesh: Mesh): void;
  63346. /**
  63347. * Remove all the meshes currently referenced in the highlight layer
  63348. */
  63349. removeAllMeshes(): void;
  63350. /**
  63351. * Force the stencil to the normal expected value for none glowing parts
  63352. */
  63353. private _defaultStencilReference;
  63354. /**
  63355. * Free any resources and references associated to a mesh.
  63356. * Internal use
  63357. * @param mesh The mesh to free.
  63358. * @hidden
  63359. */
  63360. _disposeMesh(mesh: Mesh): void;
  63361. /**
  63362. * Dispose the highlight layer and free resources.
  63363. */
  63364. dispose(): void;
  63365. /**
  63366. * Gets the class name of the effect layer
  63367. * @returns the string with the class name of the effect layer
  63368. */
  63369. getClassName(): string;
  63370. /**
  63371. * Serializes this Highlight layer
  63372. * @returns a serialized Highlight layer object
  63373. */
  63374. serialize(): any;
  63375. /**
  63376. * Creates a Highlight layer from parsed Highlight layer data
  63377. * @param parsedHightlightLayer defines the Highlight layer data
  63378. * @param scene defines the current scene
  63379. * @param rootUrl defines the root URL containing the Highlight layer information
  63380. * @returns a parsed Highlight layer
  63381. */
  63382. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  63383. }
  63384. }
  63385. declare module BABYLON {
  63386. interface AbstractScene {
  63387. /**
  63388. * The list of layers (background and foreground) of the scene
  63389. */
  63390. layers: Array<Layer>;
  63391. }
  63392. /**
  63393. * Defines the layer scene component responsible to manage any layers
  63394. * in a given scene.
  63395. */
  63396. export class LayerSceneComponent implements ISceneComponent {
  63397. /**
  63398. * The component name helpfull to identify the component in the list of scene components.
  63399. */
  63400. readonly name: string;
  63401. /**
  63402. * The scene the component belongs to.
  63403. */
  63404. scene: Scene;
  63405. private _engine;
  63406. /**
  63407. * Creates a new instance of the component for the given scene
  63408. * @param scene Defines the scene to register the component in
  63409. */
  63410. constructor(scene: Scene);
  63411. /**
  63412. * Registers the component in a given scene
  63413. */
  63414. register(): void;
  63415. /**
  63416. * Rebuilds the elements related to this component in case of
  63417. * context lost for instance.
  63418. */
  63419. rebuild(): void;
  63420. /**
  63421. * Disposes the component and the associated ressources.
  63422. */
  63423. dispose(): void;
  63424. private _draw;
  63425. private _drawCameraPredicate;
  63426. private _drawCameraBackground;
  63427. private _drawCameraForeground;
  63428. private _drawRenderTargetPredicate;
  63429. private _drawRenderTargetBackground;
  63430. private _drawRenderTargetForeground;
  63431. /**
  63432. * Adds all the elements from the container to the scene
  63433. * @param container the container holding the elements
  63434. */
  63435. addFromContainer(container: AbstractScene): void;
  63436. /**
  63437. * Removes all the elements in the container from the scene
  63438. * @param container contains the elements to remove
  63439. * @param dispose if the removed element should be disposed (default: false)
  63440. */
  63441. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63442. }
  63443. }
  63444. declare module BABYLON {
  63445. /** @hidden */
  63446. export var layerPixelShader: {
  63447. name: string;
  63448. shader: string;
  63449. };
  63450. }
  63451. declare module BABYLON {
  63452. /** @hidden */
  63453. export var layerVertexShader: {
  63454. name: string;
  63455. shader: string;
  63456. };
  63457. }
  63458. declare module BABYLON {
  63459. /**
  63460. * This represents a full screen 2d layer.
  63461. * This can be useful to display a picture in the background of your scene for instance.
  63462. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63463. */
  63464. export class Layer {
  63465. /**
  63466. * Define the name of the layer.
  63467. */
  63468. name: string;
  63469. /**
  63470. * Define the texture the layer should display.
  63471. */
  63472. texture: Nullable<Texture>;
  63473. /**
  63474. * Is the layer in background or foreground.
  63475. */
  63476. isBackground: boolean;
  63477. /**
  63478. * Define the color of the layer (instead of texture).
  63479. */
  63480. color: Color4;
  63481. /**
  63482. * Define the scale of the layer in order to zoom in out of the texture.
  63483. */
  63484. scale: Vector2;
  63485. /**
  63486. * Define an offset for the layer in order to shift the texture.
  63487. */
  63488. offset: Vector2;
  63489. /**
  63490. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  63491. */
  63492. alphaBlendingMode: number;
  63493. /**
  63494. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63495. * Alpha test will not mix with the background color in case of transparency.
  63496. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63497. */
  63498. alphaTest: boolean;
  63499. /**
  63500. * Define a mask to restrict the layer to only some of the scene cameras.
  63501. */
  63502. layerMask: number;
  63503. /**
  63504. * Define the list of render target the layer is visible into.
  63505. */
  63506. renderTargetTextures: RenderTargetTexture[];
  63507. /**
  63508. * Define if the layer is only used in renderTarget or if it also
  63509. * renders in the main frame buffer of the canvas.
  63510. */
  63511. renderOnlyInRenderTargetTextures: boolean;
  63512. private _scene;
  63513. private _vertexBuffers;
  63514. private _indexBuffer;
  63515. private _effect;
  63516. private _previousDefines;
  63517. /**
  63518. * An event triggered when the layer is disposed.
  63519. */
  63520. onDisposeObservable: Observable<Layer>;
  63521. private _onDisposeObserver;
  63522. /**
  63523. * Back compatibility with callback before the onDisposeObservable existed.
  63524. * The set callback will be triggered when the layer has been disposed.
  63525. */
  63526. set onDispose(callback: () => void);
  63527. /**
  63528. * An event triggered before rendering the scene
  63529. */
  63530. onBeforeRenderObservable: Observable<Layer>;
  63531. private _onBeforeRenderObserver;
  63532. /**
  63533. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63534. * The set callback will be triggered just before rendering the layer.
  63535. */
  63536. set onBeforeRender(callback: () => void);
  63537. /**
  63538. * An event triggered after rendering the scene
  63539. */
  63540. onAfterRenderObservable: Observable<Layer>;
  63541. private _onAfterRenderObserver;
  63542. /**
  63543. * Back compatibility with callback before the onAfterRenderObservable existed.
  63544. * The set callback will be triggered just after rendering the layer.
  63545. */
  63546. set onAfterRender(callback: () => void);
  63547. /**
  63548. * Instantiates a new layer.
  63549. * This represents a full screen 2d layer.
  63550. * This can be useful to display a picture in the background of your scene for instance.
  63551. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63552. * @param name Define the name of the layer in the scene
  63553. * @param imgUrl Define the url of the texture to display in the layer
  63554. * @param scene Define the scene the layer belongs to
  63555. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63556. * @param color Defines a color for the layer
  63557. */
  63558. constructor(
  63559. /**
  63560. * Define the name of the layer.
  63561. */
  63562. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63563. private _createIndexBuffer;
  63564. /** @hidden */
  63565. _rebuild(): void;
  63566. /**
  63567. * Renders the layer in the scene.
  63568. */
  63569. render(): void;
  63570. /**
  63571. * Disposes and releases the associated ressources.
  63572. */
  63573. dispose(): void;
  63574. }
  63575. }
  63576. declare module BABYLON {
  63577. /** @hidden */
  63578. export var lensFlarePixelShader: {
  63579. name: string;
  63580. shader: string;
  63581. };
  63582. }
  63583. declare module BABYLON {
  63584. /** @hidden */
  63585. export var lensFlareVertexShader: {
  63586. name: string;
  63587. shader: string;
  63588. };
  63589. }
  63590. declare module BABYLON {
  63591. /**
  63592. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63593. * It is usually composed of several `lensFlare`.
  63594. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63595. */
  63596. export class LensFlareSystem {
  63597. /**
  63598. * Define the name of the lens flare system
  63599. */
  63600. name: string;
  63601. /**
  63602. * List of lens flares used in this system.
  63603. */
  63604. lensFlares: LensFlare[];
  63605. /**
  63606. * Define a limit from the border the lens flare can be visible.
  63607. */
  63608. borderLimit: number;
  63609. /**
  63610. * Define a viewport border we do not want to see the lens flare in.
  63611. */
  63612. viewportBorder: number;
  63613. /**
  63614. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63615. */
  63616. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63617. /**
  63618. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63619. */
  63620. layerMask: number;
  63621. /**
  63622. * Define the id of the lens flare system in the scene.
  63623. * (equal to name by default)
  63624. */
  63625. id: string;
  63626. private _scene;
  63627. private _emitter;
  63628. private _vertexBuffers;
  63629. private _indexBuffer;
  63630. private _effect;
  63631. private _positionX;
  63632. private _positionY;
  63633. private _isEnabled;
  63634. /** @hidden */
  63635. static _SceneComponentInitialization: (scene: Scene) => void;
  63636. /**
  63637. * Instantiates a lens flare system.
  63638. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63639. * It is usually composed of several `lensFlare`.
  63640. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63641. * @param name Define the name of the lens flare system in the scene
  63642. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63643. * @param scene Define the scene the lens flare system belongs to
  63644. */
  63645. constructor(
  63646. /**
  63647. * Define the name of the lens flare system
  63648. */
  63649. name: string, emitter: any, scene: Scene);
  63650. /**
  63651. * Define if the lens flare system is enabled.
  63652. */
  63653. get isEnabled(): boolean;
  63654. set isEnabled(value: boolean);
  63655. /**
  63656. * Get the scene the effects belongs to.
  63657. * @returns the scene holding the lens flare system
  63658. */
  63659. getScene(): Scene;
  63660. /**
  63661. * Get the emitter of the lens flare system.
  63662. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63663. * @returns the emitter of the lens flare system
  63664. */
  63665. getEmitter(): any;
  63666. /**
  63667. * Set the emitter of the lens flare system.
  63668. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63669. * @param newEmitter Define the new emitter of the system
  63670. */
  63671. setEmitter(newEmitter: any): void;
  63672. /**
  63673. * Get the lens flare system emitter position.
  63674. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63675. * @returns the position
  63676. */
  63677. getEmitterPosition(): Vector3;
  63678. /**
  63679. * @hidden
  63680. */
  63681. computeEffectivePosition(globalViewport: Viewport): boolean;
  63682. /** @hidden */
  63683. _isVisible(): boolean;
  63684. /**
  63685. * @hidden
  63686. */
  63687. render(): boolean;
  63688. /**
  63689. * Dispose and release the lens flare with its associated resources.
  63690. */
  63691. dispose(): void;
  63692. /**
  63693. * Parse a lens flare system from a JSON repressentation
  63694. * @param parsedLensFlareSystem Define the JSON to parse
  63695. * @param scene Define the scene the parsed system should be instantiated in
  63696. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63697. * @returns the parsed system
  63698. */
  63699. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63700. /**
  63701. * Serialize the current Lens Flare System into a JSON representation.
  63702. * @returns the serialized JSON
  63703. */
  63704. serialize(): any;
  63705. }
  63706. }
  63707. declare module BABYLON {
  63708. /**
  63709. * This represents one of the lens effect in a `lensFlareSystem`.
  63710. * It controls one of the indiviual texture used in the effect.
  63711. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63712. */
  63713. export class LensFlare {
  63714. /**
  63715. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63716. */
  63717. size: number;
  63718. /**
  63719. * 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.
  63720. */
  63721. position: number;
  63722. /**
  63723. * Define the lens color.
  63724. */
  63725. color: Color3;
  63726. /**
  63727. * Define the lens texture.
  63728. */
  63729. texture: Nullable<Texture>;
  63730. /**
  63731. * Define the alpha mode to render this particular lens.
  63732. */
  63733. alphaMode: number;
  63734. private _system;
  63735. /**
  63736. * Creates a new Lens Flare.
  63737. * This represents one of the lens effect in a `lensFlareSystem`.
  63738. * It controls one of the indiviual texture used in the effect.
  63739. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63740. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63741. * @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.
  63742. * @param color Define the lens color
  63743. * @param imgUrl Define the lens texture url
  63744. * @param system Define the `lensFlareSystem` this flare is part of
  63745. * @returns The newly created Lens Flare
  63746. */
  63747. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63748. /**
  63749. * Instantiates a new Lens Flare.
  63750. * This represents one of the lens effect in a `lensFlareSystem`.
  63751. * It controls one of the indiviual texture used in the effect.
  63752. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63753. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63754. * @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.
  63755. * @param color Define the lens color
  63756. * @param imgUrl Define the lens texture url
  63757. * @param system Define the `lensFlareSystem` this flare is part of
  63758. */
  63759. constructor(
  63760. /**
  63761. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63762. */
  63763. size: number,
  63764. /**
  63765. * 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.
  63766. */
  63767. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63768. /**
  63769. * Dispose and release the lens flare with its associated resources.
  63770. */
  63771. dispose(): void;
  63772. }
  63773. }
  63774. declare module BABYLON {
  63775. interface AbstractScene {
  63776. /**
  63777. * The list of lens flare system added to the scene
  63778. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63779. */
  63780. lensFlareSystems: Array<LensFlareSystem>;
  63781. /**
  63782. * Removes the given lens flare system from this scene.
  63783. * @param toRemove The lens flare system to remove
  63784. * @returns The index of the removed lens flare system
  63785. */
  63786. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63787. /**
  63788. * Adds the given lens flare system to this scene
  63789. * @param newLensFlareSystem The lens flare system to add
  63790. */
  63791. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63792. /**
  63793. * Gets a lens flare system using its name
  63794. * @param name defines the name to look for
  63795. * @returns the lens flare system or null if not found
  63796. */
  63797. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63798. /**
  63799. * Gets a lens flare system using its id
  63800. * @param id defines the id to look for
  63801. * @returns the lens flare system or null if not found
  63802. */
  63803. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63804. }
  63805. /**
  63806. * Defines the lens flare scene component responsible to manage any lens flares
  63807. * in a given scene.
  63808. */
  63809. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63810. /**
  63811. * The component name helpfull to identify the component in the list of scene components.
  63812. */
  63813. readonly name: string;
  63814. /**
  63815. * The scene the component belongs to.
  63816. */
  63817. scene: Scene;
  63818. /**
  63819. * Creates a new instance of the component for the given scene
  63820. * @param scene Defines the scene to register the component in
  63821. */
  63822. constructor(scene: Scene);
  63823. /**
  63824. * Registers the component in a given scene
  63825. */
  63826. register(): void;
  63827. /**
  63828. * Rebuilds the elements related to this component in case of
  63829. * context lost for instance.
  63830. */
  63831. rebuild(): void;
  63832. /**
  63833. * Adds all the elements from the container to the scene
  63834. * @param container the container holding the elements
  63835. */
  63836. addFromContainer(container: AbstractScene): void;
  63837. /**
  63838. * Removes all the elements in the container from the scene
  63839. * @param container contains the elements to remove
  63840. * @param dispose if the removed element should be disposed (default: false)
  63841. */
  63842. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63843. /**
  63844. * Serializes the component data to the specified json object
  63845. * @param serializationObject The object to serialize to
  63846. */
  63847. serialize(serializationObject: any): void;
  63848. /**
  63849. * Disposes the component and the associated ressources.
  63850. */
  63851. dispose(): void;
  63852. private _draw;
  63853. }
  63854. }
  63855. declare module BABYLON {
  63856. /** @hidden */
  63857. export var depthPixelShader: {
  63858. name: string;
  63859. shader: string;
  63860. };
  63861. }
  63862. declare module BABYLON {
  63863. /** @hidden */
  63864. export var depthVertexShader: {
  63865. name: string;
  63866. shader: string;
  63867. };
  63868. }
  63869. declare module BABYLON {
  63870. /**
  63871. * This represents a depth renderer in Babylon.
  63872. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63873. */
  63874. export class DepthRenderer {
  63875. private _scene;
  63876. private _depthMap;
  63877. private _effect;
  63878. private readonly _storeNonLinearDepth;
  63879. private readonly _clearColor;
  63880. /** Get if the depth renderer is using packed depth or not */
  63881. readonly isPacked: boolean;
  63882. private _cachedDefines;
  63883. private _camera;
  63884. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63885. enabled: boolean;
  63886. /**
  63887. * Specifiess that the depth renderer will only be used within
  63888. * the camera it is created for.
  63889. * This can help forcing its rendering during the camera processing.
  63890. */
  63891. useOnlyInActiveCamera: boolean;
  63892. /** @hidden */
  63893. static _SceneComponentInitialization: (scene: Scene) => void;
  63894. /**
  63895. * Instantiates a depth renderer
  63896. * @param scene The scene the renderer belongs to
  63897. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63898. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63899. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63900. */
  63901. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63902. /**
  63903. * Creates the depth rendering effect and checks if the effect is ready.
  63904. * @param subMesh The submesh to be used to render the depth map of
  63905. * @param useInstances If multiple world instances should be used
  63906. * @returns if the depth renderer is ready to render the depth map
  63907. */
  63908. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63909. /**
  63910. * Gets the texture which the depth map will be written to.
  63911. * @returns The depth map texture
  63912. */
  63913. getDepthMap(): RenderTargetTexture;
  63914. /**
  63915. * Disposes of the depth renderer.
  63916. */
  63917. dispose(): void;
  63918. }
  63919. }
  63920. declare module BABYLON {
  63921. /** @hidden */
  63922. export var minmaxReduxPixelShader: {
  63923. name: string;
  63924. shader: string;
  63925. };
  63926. }
  63927. declare module BABYLON {
  63928. /**
  63929. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63930. * and maximum values from all values of the texture.
  63931. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63932. * The source values are read from the red channel of the texture.
  63933. */
  63934. export class MinMaxReducer {
  63935. /**
  63936. * Observable triggered when the computation has been performed
  63937. */
  63938. onAfterReductionPerformed: Observable<{
  63939. min: number;
  63940. max: number;
  63941. }>;
  63942. protected _camera: Camera;
  63943. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63944. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63945. protected _postProcessManager: PostProcessManager;
  63946. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63947. protected _forceFullscreenViewport: boolean;
  63948. /**
  63949. * Creates a min/max reducer
  63950. * @param camera The camera to use for the post processes
  63951. */
  63952. constructor(camera: Camera);
  63953. /**
  63954. * Gets the texture used to read the values from.
  63955. */
  63956. get sourceTexture(): Nullable<RenderTargetTexture>;
  63957. /**
  63958. * Sets the source texture to read the values from.
  63959. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63960. * because in such textures '1' value must not be taken into account to compute the maximum
  63961. * as this value is used to clear the texture.
  63962. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63963. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63964. * @param depthRedux Indicates if the texture is a depth texture or not
  63965. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63966. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63967. */
  63968. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63969. /**
  63970. * Defines the refresh rate of the computation.
  63971. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63972. */
  63973. get refreshRate(): number;
  63974. set refreshRate(value: number);
  63975. protected _activated: boolean;
  63976. /**
  63977. * Gets the activation status of the reducer
  63978. */
  63979. get activated(): boolean;
  63980. /**
  63981. * Activates the reduction computation.
  63982. * When activated, the observers registered in onAfterReductionPerformed are
  63983. * called after the compuation is performed
  63984. */
  63985. activate(): void;
  63986. /**
  63987. * Deactivates the reduction computation.
  63988. */
  63989. deactivate(): void;
  63990. /**
  63991. * Disposes the min/max reducer
  63992. * @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.
  63993. */
  63994. dispose(disposeAll?: boolean): void;
  63995. }
  63996. }
  63997. declare module BABYLON {
  63998. /**
  63999. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  64000. */
  64001. export class DepthReducer extends MinMaxReducer {
  64002. private _depthRenderer;
  64003. private _depthRendererId;
  64004. /**
  64005. * Gets the depth renderer used for the computation.
  64006. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  64007. */
  64008. get depthRenderer(): Nullable<DepthRenderer>;
  64009. /**
  64010. * Creates a depth reducer
  64011. * @param camera The camera used to render the depth texture
  64012. */
  64013. constructor(camera: Camera);
  64014. /**
  64015. * Sets the depth renderer to use to generate the depth map
  64016. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  64017. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  64018. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  64019. */
  64020. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  64021. /** @hidden */
  64022. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  64023. /**
  64024. * Activates the reduction computation.
  64025. * When activated, the observers registered in onAfterReductionPerformed are
  64026. * called after the compuation is performed
  64027. */
  64028. activate(): void;
  64029. /**
  64030. * Deactivates the reduction computation.
  64031. */
  64032. deactivate(): void;
  64033. /**
  64034. * Disposes the depth reducer
  64035. * @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.
  64036. */
  64037. dispose(disposeAll?: boolean): void;
  64038. }
  64039. }
  64040. declare module BABYLON {
  64041. /**
  64042. * A CSM implementation allowing casting shadows on large scenes.
  64043. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64044. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  64045. */
  64046. export class CascadedShadowGenerator extends ShadowGenerator {
  64047. private static readonly frustumCornersNDCSpace;
  64048. /**
  64049. * Name of the CSM class
  64050. */
  64051. static CLASSNAME: string;
  64052. /**
  64053. * Defines the default number of cascades used by the CSM.
  64054. */
  64055. static readonly DEFAULT_CASCADES_COUNT: number;
  64056. /**
  64057. * Defines the minimum number of cascades used by the CSM.
  64058. */
  64059. static readonly MIN_CASCADES_COUNT: number;
  64060. /**
  64061. * Defines the maximum number of cascades used by the CSM.
  64062. */
  64063. static readonly MAX_CASCADES_COUNT: number;
  64064. protected _validateFilter(filter: number): number;
  64065. /**
  64066. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  64067. */
  64068. penumbraDarkness: number;
  64069. private _numCascades;
  64070. /**
  64071. * Gets or set the number of cascades used by the CSM.
  64072. */
  64073. get numCascades(): number;
  64074. set numCascades(value: number);
  64075. /**
  64076. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  64077. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  64078. */
  64079. stabilizeCascades: boolean;
  64080. private _freezeShadowCastersBoundingInfo;
  64081. private _freezeShadowCastersBoundingInfoObservable;
  64082. /**
  64083. * Enables or disables the shadow casters bounding info computation.
  64084. * If your shadow casters don't move, you can disable this feature.
  64085. * If it is enabled, the bounding box computation is done every frame.
  64086. */
  64087. get freezeShadowCastersBoundingInfo(): boolean;
  64088. set freezeShadowCastersBoundingInfo(freeze: boolean);
  64089. private _scbiMin;
  64090. private _scbiMax;
  64091. protected _computeShadowCastersBoundingInfo(): void;
  64092. protected _shadowCastersBoundingInfo: BoundingInfo;
  64093. /**
  64094. * Gets or sets the shadow casters bounding info.
  64095. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  64096. * so that the system won't overwrite the bounds you provide
  64097. */
  64098. get shadowCastersBoundingInfo(): BoundingInfo;
  64099. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  64100. protected _breaksAreDirty: boolean;
  64101. protected _minDistance: number;
  64102. protected _maxDistance: number;
  64103. /**
  64104. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  64105. *
  64106. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  64107. * If you don't know these values, simply leave them to their defaults and don't call this function.
  64108. * @param min minimal distance for the breaks (default to 0.)
  64109. * @param max maximal distance for the breaks (default to 1.)
  64110. */
  64111. setMinMaxDistance(min: number, max: number): void;
  64112. /** Gets the minimal distance used in the cascade break computation */
  64113. get minDistance(): number;
  64114. /** Gets the maximal distance used in the cascade break computation */
  64115. get maxDistance(): number;
  64116. /**
  64117. * Gets the class name of that object
  64118. * @returns "CascadedShadowGenerator"
  64119. */
  64120. getClassName(): string;
  64121. private _cascadeMinExtents;
  64122. private _cascadeMaxExtents;
  64123. /**
  64124. * Gets a cascade minimum extents
  64125. * @param cascadeIndex index of the cascade
  64126. * @returns the minimum cascade extents
  64127. */
  64128. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  64129. /**
  64130. * Gets a cascade maximum extents
  64131. * @param cascadeIndex index of the cascade
  64132. * @returns the maximum cascade extents
  64133. */
  64134. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  64135. private _cascades;
  64136. private _currentLayer;
  64137. private _viewSpaceFrustumsZ;
  64138. private _viewMatrices;
  64139. private _projectionMatrices;
  64140. private _transformMatrices;
  64141. private _transformMatricesAsArray;
  64142. private _frustumLengths;
  64143. private _lightSizeUVCorrection;
  64144. private _depthCorrection;
  64145. private _frustumCornersWorldSpace;
  64146. private _frustumCenter;
  64147. private _shadowCameraPos;
  64148. private _shadowMaxZ;
  64149. /**
  64150. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  64151. * It defaults to camera.maxZ
  64152. */
  64153. get shadowMaxZ(): number;
  64154. /**
  64155. * Sets the shadow max z distance.
  64156. */
  64157. set shadowMaxZ(value: number);
  64158. protected _debug: boolean;
  64159. /**
  64160. * Gets or sets the debug flag.
  64161. * When enabled, the cascades are materialized by different colors on the screen.
  64162. */
  64163. get debug(): boolean;
  64164. set debug(dbg: boolean);
  64165. private _depthClamp;
  64166. /**
  64167. * Gets or sets the depth clamping value.
  64168. *
  64169. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  64170. * to account for the shadow casters far away.
  64171. *
  64172. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  64173. */
  64174. get depthClamp(): boolean;
  64175. set depthClamp(value: boolean);
  64176. private _cascadeBlendPercentage;
  64177. /**
  64178. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  64179. * It defaults to 0.1 (10% blending).
  64180. */
  64181. get cascadeBlendPercentage(): number;
  64182. set cascadeBlendPercentage(value: number);
  64183. private _lambda;
  64184. /**
  64185. * Gets or set the lambda parameter.
  64186. * This parameter is used to split the camera frustum and create the cascades.
  64187. * 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.
  64188. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  64189. */
  64190. get lambda(): number;
  64191. set lambda(value: number);
  64192. /**
  64193. * Gets the view matrix corresponding to a given cascade
  64194. * @param cascadeNum cascade to retrieve the view matrix from
  64195. * @returns the cascade view matrix
  64196. */
  64197. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  64198. /**
  64199. * Gets the projection matrix corresponding to a given cascade
  64200. * @param cascadeNum cascade to retrieve the projection matrix from
  64201. * @returns the cascade projection matrix
  64202. */
  64203. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  64204. /**
  64205. * Gets the transformation matrix corresponding to a given cascade
  64206. * @param cascadeNum cascade to retrieve the transformation matrix from
  64207. * @returns the cascade transformation matrix
  64208. */
  64209. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  64210. private _depthRenderer;
  64211. /**
  64212. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  64213. *
  64214. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  64215. *
  64216. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  64217. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  64218. * @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
  64219. */
  64220. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  64221. private _depthReducer;
  64222. private _autoCalcDepthBounds;
  64223. /**
  64224. * Gets or sets the autoCalcDepthBounds property.
  64225. *
  64226. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  64227. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  64228. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  64229. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  64230. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  64231. */
  64232. get autoCalcDepthBounds(): boolean;
  64233. set autoCalcDepthBounds(value: boolean);
  64234. /**
  64235. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  64236. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  64237. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  64238. * for setting the refresh rate on the renderer yourself!
  64239. */
  64240. get autoCalcDepthBoundsRefreshRate(): number;
  64241. set autoCalcDepthBoundsRefreshRate(value: number);
  64242. /**
  64243. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  64244. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  64245. * you change the camera near/far planes!
  64246. */
  64247. splitFrustum(): void;
  64248. private _splitFrustum;
  64249. private _computeMatrices;
  64250. private _computeFrustumInWorldSpace;
  64251. private _computeCascadeFrustum;
  64252. /**
  64253. * Support test.
  64254. */
  64255. static get IsSupported(): boolean;
  64256. /** @hidden */
  64257. static _SceneComponentInitialization: (scene: Scene) => void;
  64258. /**
  64259. * Creates a Cascaded Shadow Generator object.
  64260. * A ShadowGenerator is the required tool to use the shadows.
  64261. * Each directional light casting shadows needs to use its own ShadowGenerator.
  64262. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  64263. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  64264. * @param light The directional light object generating the shadows.
  64265. * @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.
  64266. */
  64267. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  64268. protected _initializeGenerator(): void;
  64269. protected _createTargetRenderTexture(): void;
  64270. protected _initializeShadowMap(): void;
  64271. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  64272. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  64273. /**
  64274. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  64275. * @param defines Defines of the material we want to update
  64276. * @param lightIndex Index of the light in the enabled light list of the material
  64277. */
  64278. prepareDefines(defines: any, lightIndex: number): void;
  64279. /**
  64280. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  64281. * defined in the generator but impacting the effect).
  64282. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  64283. * @param effect The effect we are binfing the information for
  64284. */
  64285. bindShadowLight(lightIndex: string, effect: Effect): void;
  64286. /**
  64287. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  64288. * (eq to view projection * shadow projection matrices)
  64289. * @returns The transform matrix used to create the shadow map
  64290. */
  64291. getTransformMatrix(): Matrix;
  64292. /**
  64293. * Disposes the ShadowGenerator.
  64294. * Returns nothing.
  64295. */
  64296. dispose(): void;
  64297. /**
  64298. * Serializes the shadow generator setup to a json object.
  64299. * @returns The serialized JSON object
  64300. */
  64301. serialize(): any;
  64302. /**
  64303. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  64304. * @param parsedShadowGenerator The JSON object to parse
  64305. * @param scene The scene to create the shadow map for
  64306. * @returns The parsed shadow generator
  64307. */
  64308. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  64309. }
  64310. }
  64311. declare module BABYLON {
  64312. /**
  64313. * Defines the shadow generator component responsible to manage any shadow generators
  64314. * in a given scene.
  64315. */
  64316. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  64317. /**
  64318. * The component name helpfull to identify the component in the list of scene components.
  64319. */
  64320. readonly name: string;
  64321. /**
  64322. * The scene the component belongs to.
  64323. */
  64324. scene: Scene;
  64325. /**
  64326. * Creates a new instance of the component for the given scene
  64327. * @param scene Defines the scene to register the component in
  64328. */
  64329. constructor(scene: Scene);
  64330. /**
  64331. * Registers the component in a given scene
  64332. */
  64333. register(): void;
  64334. /**
  64335. * Rebuilds the elements related to this component in case of
  64336. * context lost for instance.
  64337. */
  64338. rebuild(): void;
  64339. /**
  64340. * Serializes the component data to the specified json object
  64341. * @param serializationObject The object to serialize to
  64342. */
  64343. serialize(serializationObject: any): void;
  64344. /**
  64345. * Adds all the elements from the container to the scene
  64346. * @param container the container holding the elements
  64347. */
  64348. addFromContainer(container: AbstractScene): void;
  64349. /**
  64350. * Removes all the elements in the container from the scene
  64351. * @param container contains the elements to remove
  64352. * @param dispose if the removed element should be disposed (default: false)
  64353. */
  64354. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  64355. /**
  64356. * Rebuilds the elements related to this component in case of
  64357. * context lost for instance.
  64358. */
  64359. dispose(): void;
  64360. private _gatherRenderTargets;
  64361. }
  64362. }
  64363. declare module BABYLON {
  64364. /**
  64365. * A point light is a light defined by an unique point in world space.
  64366. * The light is emitted in every direction from this point.
  64367. * A good example of a point light is a standard light bulb.
  64368. * Documentation: https://doc.babylonjs.com/babylon101/lights
  64369. */
  64370. export class PointLight extends ShadowLight {
  64371. private _shadowAngle;
  64372. /**
  64373. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64374. * This specifies what angle the shadow will use to be created.
  64375. *
  64376. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64377. */
  64378. get shadowAngle(): number;
  64379. /**
  64380. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64381. * This specifies what angle the shadow will use to be created.
  64382. *
  64383. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  64384. */
  64385. set shadowAngle(value: number);
  64386. /**
  64387. * Gets the direction if it has been set.
  64388. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64389. */
  64390. get direction(): Vector3;
  64391. /**
  64392. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  64393. */
  64394. set direction(value: Vector3);
  64395. /**
  64396. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  64397. * A PointLight emits the light in every direction.
  64398. * It can cast shadows.
  64399. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  64400. * ```javascript
  64401. * var pointLight = new PointLight("pl", camera.position, scene);
  64402. * ```
  64403. * Documentation : https://doc.babylonjs.com/babylon101/lights
  64404. * @param name The light friendly name
  64405. * @param position The position of the point light in the scene
  64406. * @param scene The scene the lights belongs to
  64407. */
  64408. constructor(name: string, position: Vector3, scene: Scene);
  64409. /**
  64410. * Returns the string "PointLight"
  64411. * @returns the class name
  64412. */
  64413. getClassName(): string;
  64414. /**
  64415. * Returns the integer 0.
  64416. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64417. */
  64418. getTypeID(): number;
  64419. /**
  64420. * Specifies wether or not the shadowmap should be a cube texture.
  64421. * @returns true if the shadowmap needs to be a cube texture.
  64422. */
  64423. needCube(): boolean;
  64424. /**
  64425. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64426. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64427. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64428. */
  64429. getShadowDirection(faceIndex?: number): Vector3;
  64430. /**
  64431. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64432. * - fov = PI / 2
  64433. * - aspect ratio : 1.0
  64434. * - z-near and far equal to the active camera minZ and maxZ.
  64435. * Returns the PointLight.
  64436. */
  64437. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64438. protected _buildUniformLayout(): void;
  64439. /**
  64440. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64441. * @param effect The effect to update
  64442. * @param lightIndex The index of the light in the effect to update
  64443. * @returns The point light
  64444. */
  64445. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64446. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64447. /**
  64448. * Prepares the list of defines specific to the light type.
  64449. * @param defines the list of defines
  64450. * @param lightIndex defines the index of the light for the effect
  64451. */
  64452. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64453. }
  64454. }
  64455. declare module BABYLON {
  64456. /**
  64457. * Header information of HDR texture files.
  64458. */
  64459. export interface HDRInfo {
  64460. /**
  64461. * The height of the texture in pixels.
  64462. */
  64463. height: number;
  64464. /**
  64465. * The width of the texture in pixels.
  64466. */
  64467. width: number;
  64468. /**
  64469. * The index of the beginning of the data in the binary file.
  64470. */
  64471. dataPosition: number;
  64472. }
  64473. /**
  64474. * This groups tools to convert HDR texture to native colors array.
  64475. */
  64476. export class HDRTools {
  64477. private static Ldexp;
  64478. private static Rgbe2float;
  64479. private static readStringLine;
  64480. /**
  64481. * Reads header information from an RGBE texture stored in a native array.
  64482. * More information on this format are available here:
  64483. * https://en.wikipedia.org/wiki/RGBE_image_format
  64484. *
  64485. * @param uint8array The binary file stored in native array.
  64486. * @return The header information.
  64487. */
  64488. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64489. /**
  64490. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64491. * This RGBE texture needs to store the information as a panorama.
  64492. *
  64493. * More information on this format are available here:
  64494. * https://en.wikipedia.org/wiki/RGBE_image_format
  64495. *
  64496. * @param buffer The binary file stored in an array buffer.
  64497. * @param size The expected size of the extracted cubemap.
  64498. * @return The Cube Map information.
  64499. */
  64500. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64501. /**
  64502. * Returns the pixels data extracted from an RGBE texture.
  64503. * This pixels will be stored left to right up to down in the R G B order in one array.
  64504. *
  64505. * More information on this format are available here:
  64506. * https://en.wikipedia.org/wiki/RGBE_image_format
  64507. *
  64508. * @param uint8array The binary file stored in an array buffer.
  64509. * @param hdrInfo The header information of the file.
  64510. * @return The pixels data in RGB right to left up to down order.
  64511. */
  64512. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64513. private static RGBE_ReadPixels_RLE;
  64514. private static RGBE_ReadPixels_NOT_RLE;
  64515. }
  64516. }
  64517. declare module BABYLON {
  64518. /**
  64519. * Effect Render Options
  64520. */
  64521. export interface IEffectRendererOptions {
  64522. /**
  64523. * Defines the vertices positions.
  64524. */
  64525. positions?: number[];
  64526. /**
  64527. * Defines the indices.
  64528. */
  64529. indices?: number[];
  64530. }
  64531. /**
  64532. * Helper class to render one or more effects.
  64533. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64534. */
  64535. export class EffectRenderer {
  64536. private engine;
  64537. private static _DefaultOptions;
  64538. private _vertexBuffers;
  64539. private _indexBuffer;
  64540. private _fullscreenViewport;
  64541. /**
  64542. * Creates an effect renderer
  64543. * @param engine the engine to use for rendering
  64544. * @param options defines the options of the effect renderer
  64545. */
  64546. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64547. /**
  64548. * Sets the current viewport in normalized coordinates 0-1
  64549. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64550. */
  64551. setViewport(viewport?: Viewport): void;
  64552. /**
  64553. * Binds the embedded attributes buffer to the effect.
  64554. * @param effect Defines the effect to bind the attributes for
  64555. */
  64556. bindBuffers(effect: Effect): void;
  64557. /**
  64558. * Sets the current effect wrapper to use during draw.
  64559. * The effect needs to be ready before calling this api.
  64560. * This also sets the default full screen position attribute.
  64561. * @param effectWrapper Defines the effect to draw with
  64562. */
  64563. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64564. /**
  64565. * Restores engine states
  64566. */
  64567. restoreStates(): void;
  64568. /**
  64569. * Draws a full screen quad.
  64570. */
  64571. draw(): void;
  64572. private isRenderTargetTexture;
  64573. /**
  64574. * renders one or more effects to a specified texture
  64575. * @param effectWrapper the effect to renderer
  64576. * @param outputTexture texture to draw to, if null it will render to the screen.
  64577. */
  64578. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64579. /**
  64580. * Disposes of the effect renderer
  64581. */
  64582. dispose(): void;
  64583. }
  64584. /**
  64585. * Options to create an EffectWrapper
  64586. */
  64587. interface EffectWrapperCreationOptions {
  64588. /**
  64589. * Engine to use to create the effect
  64590. */
  64591. engine: ThinEngine;
  64592. /**
  64593. * Fragment shader for the effect
  64594. */
  64595. fragmentShader: string;
  64596. /**
  64597. * Use the shader store instead of direct source code
  64598. */
  64599. useShaderStore?: boolean;
  64600. /**
  64601. * Vertex shader for the effect
  64602. */
  64603. vertexShader?: string;
  64604. /**
  64605. * Attributes to use in the shader
  64606. */
  64607. attributeNames?: Array<string>;
  64608. /**
  64609. * Uniforms to use in the shader
  64610. */
  64611. uniformNames?: Array<string>;
  64612. /**
  64613. * Texture sampler names to use in the shader
  64614. */
  64615. samplerNames?: Array<string>;
  64616. /**
  64617. * Defines to use in the shader
  64618. */
  64619. defines?: Array<string>;
  64620. /**
  64621. * Callback when effect is compiled
  64622. */
  64623. onCompiled?: Nullable<(effect: Effect) => void>;
  64624. /**
  64625. * The friendly name of the effect displayed in Spector.
  64626. */
  64627. name?: string;
  64628. }
  64629. /**
  64630. * Wraps an effect to be used for rendering
  64631. */
  64632. export class EffectWrapper {
  64633. /**
  64634. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64635. */
  64636. onApplyObservable: Observable<{}>;
  64637. /**
  64638. * The underlying effect
  64639. */
  64640. effect: Effect;
  64641. /**
  64642. * Creates an effect to be renderer
  64643. * @param creationOptions options to create the effect
  64644. */
  64645. constructor(creationOptions: EffectWrapperCreationOptions);
  64646. /**
  64647. * Disposes of the effect wrapper
  64648. */
  64649. dispose(): void;
  64650. }
  64651. }
  64652. declare module BABYLON {
  64653. /** @hidden */
  64654. export var hdrFilteringVertexShader: {
  64655. name: string;
  64656. shader: string;
  64657. };
  64658. }
  64659. declare module BABYLON {
  64660. /** @hidden */
  64661. export var hdrFilteringPixelShader: {
  64662. name: string;
  64663. shader: string;
  64664. };
  64665. }
  64666. declare module BABYLON {
  64667. /**
  64668. * Options for texture filtering
  64669. */
  64670. interface IHDRFilteringOptions {
  64671. /**
  64672. * Scales pixel intensity for the input HDR map.
  64673. */
  64674. hdrScale?: number;
  64675. /**
  64676. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64677. */
  64678. quality?: number;
  64679. }
  64680. /**
  64681. * Filters HDR maps to get correct renderings of PBR reflections
  64682. */
  64683. export class HDRFiltering {
  64684. private _engine;
  64685. private _effectRenderer;
  64686. private _effectWrapper;
  64687. private _lodGenerationOffset;
  64688. private _lodGenerationScale;
  64689. /**
  64690. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64691. * you care about baking speed.
  64692. */
  64693. quality: number;
  64694. /**
  64695. * Scales pixel intensity for the input HDR map.
  64696. */
  64697. hdrScale: number;
  64698. /**
  64699. * Instantiates HDR filter for reflection maps
  64700. *
  64701. * @param engine Thin engine
  64702. * @param options Options
  64703. */
  64704. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64705. private _createRenderTarget;
  64706. private _prefilterInternal;
  64707. private _createEffect;
  64708. /**
  64709. * Get a value indicating if the filter is ready to be used
  64710. * @param texture Texture to filter
  64711. * @returns true if the filter is ready
  64712. */
  64713. isReady(texture: BaseTexture): boolean;
  64714. /**
  64715. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64716. * Prefiltering will be invoked at the end of next rendering pass.
  64717. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64718. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64719. * @param texture Texture to filter
  64720. * @param onFinished Callback when filtering is done
  64721. * @return Promise called when prefiltering is done
  64722. */
  64723. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<void>;
  64724. }
  64725. }
  64726. declare module BABYLON {
  64727. /**
  64728. * This represents a texture coming from an HDR input.
  64729. *
  64730. * The only supported format is currently panorama picture stored in RGBE format.
  64731. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64732. */
  64733. export class HDRCubeTexture extends BaseTexture {
  64734. private static _facesMapping;
  64735. private _generateHarmonics;
  64736. private _noMipmap;
  64737. private _prefilterOnLoad;
  64738. private _textureMatrix;
  64739. private _size;
  64740. private _onLoad;
  64741. private _onError;
  64742. /**
  64743. * The texture URL.
  64744. */
  64745. url: string;
  64746. protected _isBlocking: boolean;
  64747. /**
  64748. * Sets wether or not the texture is blocking during loading.
  64749. */
  64750. set isBlocking(value: boolean);
  64751. /**
  64752. * Gets wether or not the texture is blocking during loading.
  64753. */
  64754. get isBlocking(): boolean;
  64755. protected _rotationY: number;
  64756. /**
  64757. * Sets texture matrix rotation angle around Y axis in radians.
  64758. */
  64759. set rotationY(value: number);
  64760. /**
  64761. * Gets texture matrix rotation angle around Y axis radians.
  64762. */
  64763. get rotationY(): number;
  64764. /**
  64765. * Gets or sets the center of the bounding box associated with the cube texture
  64766. * It must define where the camera used to render the texture was set
  64767. */
  64768. boundingBoxPosition: Vector3;
  64769. private _boundingBoxSize;
  64770. /**
  64771. * Gets or sets the size of the bounding box associated with the cube texture
  64772. * When defined, the cubemap will switch to local mode
  64773. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64774. * @example https://www.babylonjs-playground.com/#RNASML
  64775. */
  64776. set boundingBoxSize(value: Vector3);
  64777. get boundingBoxSize(): Vector3;
  64778. /**
  64779. * Instantiates an HDRTexture from the following parameters.
  64780. *
  64781. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64782. * @param sceneOrEngine The scene or engine the texture will be used in
  64783. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64784. * @param noMipmap Forces to not generate the mipmap if true
  64785. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64786. * @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)
  64787. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64788. */
  64789. 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>);
  64790. /**
  64791. * Get the current class name of the texture useful for serialization or dynamic coding.
  64792. * @returns "HDRCubeTexture"
  64793. */
  64794. getClassName(): string;
  64795. /**
  64796. * Occurs when the file is raw .hdr file.
  64797. */
  64798. private loadTexture;
  64799. clone(): HDRCubeTexture;
  64800. delayLoad(): void;
  64801. /**
  64802. * Get the texture reflection matrix used to rotate/transform the reflection.
  64803. * @returns the reflection matrix
  64804. */
  64805. getReflectionTextureMatrix(): Matrix;
  64806. /**
  64807. * Set the texture reflection matrix used to rotate/transform the reflection.
  64808. * @param value Define the reflection matrix to set
  64809. */
  64810. setReflectionTextureMatrix(value: Matrix): void;
  64811. /**
  64812. * Parses a JSON representation of an HDR Texture in order to create the texture
  64813. * @param parsedTexture Define the JSON representation
  64814. * @param scene Define the scene the texture should be created in
  64815. * @param rootUrl Define the root url in case we need to load relative dependencies
  64816. * @returns the newly created texture after parsing
  64817. */
  64818. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64819. serialize(): any;
  64820. }
  64821. }
  64822. declare module BABYLON {
  64823. /**
  64824. * Class used to control physics engine
  64825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64826. */
  64827. export class PhysicsEngine implements IPhysicsEngine {
  64828. private _physicsPlugin;
  64829. /**
  64830. * Global value used to control the smallest number supported by the simulation
  64831. */
  64832. static Epsilon: number;
  64833. private _impostors;
  64834. private _joints;
  64835. private _subTimeStep;
  64836. /**
  64837. * Gets the gravity vector used by the simulation
  64838. */
  64839. gravity: Vector3;
  64840. /**
  64841. * Factory used to create the default physics plugin.
  64842. * @returns The default physics plugin
  64843. */
  64844. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64845. /**
  64846. * Creates a new Physics Engine
  64847. * @param gravity defines the gravity vector used by the simulation
  64848. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64849. */
  64850. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64851. /**
  64852. * Sets the gravity vector used by the simulation
  64853. * @param gravity defines the gravity vector to use
  64854. */
  64855. setGravity(gravity: Vector3): void;
  64856. /**
  64857. * Set the time step of the physics engine.
  64858. * Default is 1/60.
  64859. * To slow it down, enter 1/600 for example.
  64860. * To speed it up, 1/30
  64861. * @param newTimeStep defines the new timestep to apply to this world.
  64862. */
  64863. setTimeStep(newTimeStep?: number): void;
  64864. /**
  64865. * Get the time step of the physics engine.
  64866. * @returns the current time step
  64867. */
  64868. getTimeStep(): number;
  64869. /**
  64870. * Set the sub time step of the physics engine.
  64871. * Default is 0 meaning there is no sub steps
  64872. * To increase physics resolution precision, set a small value (like 1 ms)
  64873. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64874. */
  64875. setSubTimeStep(subTimeStep?: number): void;
  64876. /**
  64877. * Get the sub time step of the physics engine.
  64878. * @returns the current sub time step
  64879. */
  64880. getSubTimeStep(): number;
  64881. /**
  64882. * Release all resources
  64883. */
  64884. dispose(): void;
  64885. /**
  64886. * Gets the name of the current physics plugin
  64887. * @returns the name of the plugin
  64888. */
  64889. getPhysicsPluginName(): string;
  64890. /**
  64891. * Adding a new impostor for the impostor tracking.
  64892. * This will be done by the impostor itself.
  64893. * @param impostor the impostor to add
  64894. */
  64895. addImpostor(impostor: PhysicsImpostor): void;
  64896. /**
  64897. * Remove an impostor from the engine.
  64898. * This impostor and its mesh will not longer be updated by the physics engine.
  64899. * @param impostor the impostor to remove
  64900. */
  64901. removeImpostor(impostor: PhysicsImpostor): void;
  64902. /**
  64903. * Add a joint to the physics engine
  64904. * @param mainImpostor defines the main impostor to which the joint is added.
  64905. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64906. * @param joint defines the joint that will connect both impostors.
  64907. */
  64908. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64909. /**
  64910. * Removes a joint from the simulation
  64911. * @param mainImpostor defines the impostor used with the joint
  64912. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64913. * @param joint defines the joint to remove
  64914. */
  64915. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64916. /**
  64917. * Called by the scene. No need to call it.
  64918. * @param delta defines the timespam between frames
  64919. */
  64920. _step(delta: number): void;
  64921. /**
  64922. * Gets the current plugin used to run the simulation
  64923. * @returns current plugin
  64924. */
  64925. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64926. /**
  64927. * Gets the list of physic impostors
  64928. * @returns an array of PhysicsImpostor
  64929. */
  64930. getImpostors(): Array<PhysicsImpostor>;
  64931. /**
  64932. * Gets the impostor for a physics enabled object
  64933. * @param object defines the object impersonated by the impostor
  64934. * @returns the PhysicsImpostor or null if not found
  64935. */
  64936. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64937. /**
  64938. * Gets the impostor for a physics body object
  64939. * @param body defines physics body used by the impostor
  64940. * @returns the PhysicsImpostor or null if not found
  64941. */
  64942. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64943. /**
  64944. * Does a raycast in the physics world
  64945. * @param from when should the ray start?
  64946. * @param to when should the ray end?
  64947. * @returns PhysicsRaycastResult
  64948. */
  64949. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64950. }
  64951. }
  64952. declare module BABYLON {
  64953. /** @hidden */
  64954. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64955. private _useDeltaForWorldStep;
  64956. world: any;
  64957. name: string;
  64958. private _physicsMaterials;
  64959. private _fixedTimeStep;
  64960. private _cannonRaycastResult;
  64961. private _raycastResult;
  64962. private _physicsBodysToRemoveAfterStep;
  64963. private _firstFrame;
  64964. BJSCANNON: any;
  64965. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64966. setGravity(gravity: Vector3): void;
  64967. setTimeStep(timeStep: number): void;
  64968. getTimeStep(): number;
  64969. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64970. private _removeMarkedPhysicsBodiesFromWorld;
  64971. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64972. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64973. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64974. private _processChildMeshes;
  64975. removePhysicsBody(impostor: PhysicsImpostor): void;
  64976. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64977. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64978. private _addMaterial;
  64979. private _checkWithEpsilon;
  64980. private _createShape;
  64981. private _createHeightmap;
  64982. private _minus90X;
  64983. private _plus90X;
  64984. private _tmpPosition;
  64985. private _tmpDeltaPosition;
  64986. private _tmpUnityRotation;
  64987. private _updatePhysicsBodyTransformation;
  64988. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64989. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64990. isSupported(): boolean;
  64991. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64992. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64993. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64994. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64995. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64996. getBodyMass(impostor: PhysicsImpostor): number;
  64997. getBodyFriction(impostor: PhysicsImpostor): number;
  64998. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64999. getBodyRestitution(impostor: PhysicsImpostor): number;
  65000. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65001. sleepBody(impostor: PhysicsImpostor): void;
  65002. wakeUpBody(impostor: PhysicsImpostor): void;
  65003. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  65004. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65005. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65006. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65007. getRadius(impostor: PhysicsImpostor): number;
  65008. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65009. dispose(): void;
  65010. private _extendNamespace;
  65011. /**
  65012. * Does a raycast in the physics world
  65013. * @param from when should the ray start?
  65014. * @param to when should the ray end?
  65015. * @returns PhysicsRaycastResult
  65016. */
  65017. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65018. }
  65019. }
  65020. declare module BABYLON {
  65021. /** @hidden */
  65022. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  65023. private _useDeltaForWorldStep;
  65024. world: any;
  65025. name: string;
  65026. BJSOIMO: any;
  65027. private _raycastResult;
  65028. private _fixedTimeStep;
  65029. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  65030. setGravity(gravity: Vector3): void;
  65031. setTimeStep(timeStep: number): void;
  65032. getTimeStep(): number;
  65033. private _tmpImpostorsArray;
  65034. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65035. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65036. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65037. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65038. private _tmpPositionVector;
  65039. removePhysicsBody(impostor: PhysicsImpostor): void;
  65040. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65041. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65042. isSupported(): boolean;
  65043. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65044. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65045. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65046. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65047. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65048. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65049. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65050. getBodyMass(impostor: PhysicsImpostor): number;
  65051. getBodyFriction(impostor: PhysicsImpostor): number;
  65052. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65053. getBodyRestitution(impostor: PhysicsImpostor): number;
  65054. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65055. sleepBody(impostor: PhysicsImpostor): void;
  65056. wakeUpBody(impostor: PhysicsImpostor): void;
  65057. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65058. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  65059. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  65060. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65061. getRadius(impostor: PhysicsImpostor): number;
  65062. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65063. dispose(): void;
  65064. /**
  65065. * Does a raycast in the physics world
  65066. * @param from when should the ray start?
  65067. * @param to when should the ray end?
  65068. * @returns PhysicsRaycastResult
  65069. */
  65070. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65071. }
  65072. }
  65073. declare module BABYLON {
  65074. /**
  65075. * AmmoJS Physics plugin
  65076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  65077. * @see https://github.com/kripken/ammo.js/
  65078. */
  65079. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  65080. private _useDeltaForWorldStep;
  65081. /**
  65082. * Reference to the Ammo library
  65083. */
  65084. bjsAMMO: any;
  65085. /**
  65086. * Created ammoJS world which physics bodies are added to
  65087. */
  65088. world: any;
  65089. /**
  65090. * Name of the plugin
  65091. */
  65092. name: string;
  65093. private _timeStep;
  65094. private _fixedTimeStep;
  65095. private _maxSteps;
  65096. private _tmpQuaternion;
  65097. private _tmpAmmoTransform;
  65098. private _tmpAmmoQuaternion;
  65099. private _tmpAmmoConcreteContactResultCallback;
  65100. private _collisionConfiguration;
  65101. private _dispatcher;
  65102. private _overlappingPairCache;
  65103. private _solver;
  65104. private _softBodySolver;
  65105. private _tmpAmmoVectorA;
  65106. private _tmpAmmoVectorB;
  65107. private _tmpAmmoVectorC;
  65108. private _tmpAmmoVectorD;
  65109. private _tmpContactCallbackResult;
  65110. private _tmpAmmoVectorRCA;
  65111. private _tmpAmmoVectorRCB;
  65112. private _raycastResult;
  65113. private _tmpContactPoint;
  65114. private static readonly DISABLE_COLLISION_FLAG;
  65115. private static readonly KINEMATIC_FLAG;
  65116. private static readonly DISABLE_DEACTIVATION_FLAG;
  65117. /**
  65118. * Initializes the ammoJS plugin
  65119. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  65120. * @param ammoInjection can be used to inject your own ammo reference
  65121. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  65122. */
  65123. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  65124. /**
  65125. * Sets the gravity of the physics world (m/(s^2))
  65126. * @param gravity Gravity to set
  65127. */
  65128. setGravity(gravity: Vector3): void;
  65129. /**
  65130. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  65131. * @param timeStep timestep to use in seconds
  65132. */
  65133. setTimeStep(timeStep: number): void;
  65134. /**
  65135. * 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)
  65136. * @param fixedTimeStep fixedTimeStep to use in seconds
  65137. */
  65138. setFixedTimeStep(fixedTimeStep: number): void;
  65139. /**
  65140. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  65141. * @param maxSteps the maximum number of steps by the physics engine per frame
  65142. */
  65143. setMaxSteps(maxSteps: number): void;
  65144. /**
  65145. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  65146. * @returns the current timestep in seconds
  65147. */
  65148. getTimeStep(): number;
  65149. /**
  65150. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  65151. */
  65152. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  65153. private _isImpostorInContact;
  65154. private _isImpostorPairInContact;
  65155. private _stepSimulation;
  65156. /**
  65157. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  65158. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  65159. * After the step the babylon meshes are set to the position of the physics imposters
  65160. * @param delta amount of time to step forward
  65161. * @param impostors array of imposters to update before/after the step
  65162. */
  65163. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  65164. /**
  65165. * Update babylon mesh to match physics world object
  65166. * @param impostor imposter to match
  65167. */
  65168. private _afterSoftStep;
  65169. /**
  65170. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65171. * @param impostor imposter to match
  65172. */
  65173. private _ropeStep;
  65174. /**
  65175. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  65176. * @param impostor imposter to match
  65177. */
  65178. private _softbodyOrClothStep;
  65179. private _tmpMatrix;
  65180. /**
  65181. * Applies an impulse on the imposter
  65182. * @param impostor imposter to apply impulse to
  65183. * @param force amount of force to be applied to the imposter
  65184. * @param contactPoint the location to apply the impulse on the imposter
  65185. */
  65186. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65187. /**
  65188. * Applies a force on the imposter
  65189. * @param impostor imposter to apply force
  65190. * @param force amount of force to be applied to the imposter
  65191. * @param contactPoint the location to apply the force on the imposter
  65192. */
  65193. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  65194. /**
  65195. * Creates a physics body using the plugin
  65196. * @param impostor the imposter to create the physics body on
  65197. */
  65198. generatePhysicsBody(impostor: PhysicsImpostor): void;
  65199. /**
  65200. * Removes the physics body from the imposter and disposes of the body's memory
  65201. * @param impostor imposter to remove the physics body from
  65202. */
  65203. removePhysicsBody(impostor: PhysicsImpostor): void;
  65204. /**
  65205. * Generates a joint
  65206. * @param impostorJoint the imposter joint to create the joint with
  65207. */
  65208. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  65209. /**
  65210. * Removes a joint
  65211. * @param impostorJoint the imposter joint to remove the joint from
  65212. */
  65213. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  65214. private _addMeshVerts;
  65215. /**
  65216. * Initialise the soft body vertices to match its object's (mesh) vertices
  65217. * Softbody vertices (nodes) are in world space and to match this
  65218. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  65219. * @param impostor to create the softbody for
  65220. */
  65221. private _softVertexData;
  65222. /**
  65223. * Create an impostor's soft body
  65224. * @param impostor to create the softbody for
  65225. */
  65226. private _createSoftbody;
  65227. /**
  65228. * Create cloth for an impostor
  65229. * @param impostor to create the softbody for
  65230. */
  65231. private _createCloth;
  65232. /**
  65233. * Create rope for an impostor
  65234. * @param impostor to create the softbody for
  65235. */
  65236. private _createRope;
  65237. /**
  65238. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  65239. * @param impostor to create the custom physics shape for
  65240. */
  65241. private _createCustom;
  65242. private _addHullVerts;
  65243. private _createShape;
  65244. /**
  65245. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  65246. * @param impostor imposter containing the physics body and babylon object
  65247. */
  65248. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  65249. /**
  65250. * Sets the babylon object's position/rotation from the physics body's position/rotation
  65251. * @param impostor imposter containing the physics body and babylon object
  65252. * @param newPosition new position
  65253. * @param newRotation new rotation
  65254. */
  65255. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  65256. /**
  65257. * If this plugin is supported
  65258. * @returns true if its supported
  65259. */
  65260. isSupported(): boolean;
  65261. /**
  65262. * Sets the linear velocity of the physics body
  65263. * @param impostor imposter to set the velocity on
  65264. * @param velocity velocity to set
  65265. */
  65266. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65267. /**
  65268. * Sets the angular velocity of the physics body
  65269. * @param impostor imposter to set the velocity on
  65270. * @param velocity velocity to set
  65271. */
  65272. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  65273. /**
  65274. * gets the linear velocity
  65275. * @param impostor imposter to get linear velocity from
  65276. * @returns linear velocity
  65277. */
  65278. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65279. /**
  65280. * gets the angular velocity
  65281. * @param impostor imposter to get angular velocity from
  65282. * @returns angular velocity
  65283. */
  65284. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  65285. /**
  65286. * Sets the mass of physics body
  65287. * @param impostor imposter to set the mass on
  65288. * @param mass mass to set
  65289. */
  65290. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  65291. /**
  65292. * Gets the mass of the physics body
  65293. * @param impostor imposter to get the mass from
  65294. * @returns mass
  65295. */
  65296. getBodyMass(impostor: PhysicsImpostor): number;
  65297. /**
  65298. * Gets friction of the impostor
  65299. * @param impostor impostor to get friction from
  65300. * @returns friction value
  65301. */
  65302. getBodyFriction(impostor: PhysicsImpostor): number;
  65303. /**
  65304. * Sets friction of the impostor
  65305. * @param impostor impostor to set friction on
  65306. * @param friction friction value
  65307. */
  65308. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  65309. /**
  65310. * Gets restitution of the impostor
  65311. * @param impostor impostor to get restitution from
  65312. * @returns restitution value
  65313. */
  65314. getBodyRestitution(impostor: PhysicsImpostor): number;
  65315. /**
  65316. * Sets resitution of the impostor
  65317. * @param impostor impostor to set resitution on
  65318. * @param restitution resitution value
  65319. */
  65320. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  65321. /**
  65322. * Gets pressure inside the impostor
  65323. * @param impostor impostor to get pressure from
  65324. * @returns pressure value
  65325. */
  65326. getBodyPressure(impostor: PhysicsImpostor): number;
  65327. /**
  65328. * Sets pressure inside a soft body impostor
  65329. * Cloth and rope must remain 0 pressure
  65330. * @param impostor impostor to set pressure on
  65331. * @param pressure pressure value
  65332. */
  65333. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  65334. /**
  65335. * Gets stiffness of the impostor
  65336. * @param impostor impostor to get stiffness from
  65337. * @returns pressure value
  65338. */
  65339. getBodyStiffness(impostor: PhysicsImpostor): number;
  65340. /**
  65341. * Sets stiffness of the impostor
  65342. * @param impostor impostor to set stiffness on
  65343. * @param stiffness stiffness value from 0 to 1
  65344. */
  65345. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65346. /**
  65347. * Gets velocityIterations of the impostor
  65348. * @param impostor impostor to get velocity iterations from
  65349. * @returns velocityIterations value
  65350. */
  65351. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65352. /**
  65353. * Sets velocityIterations of the impostor
  65354. * @param impostor impostor to set velocity iterations on
  65355. * @param velocityIterations velocityIterations value
  65356. */
  65357. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65358. /**
  65359. * Gets positionIterations of the impostor
  65360. * @param impostor impostor to get position iterations from
  65361. * @returns positionIterations value
  65362. */
  65363. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65364. /**
  65365. * Sets positionIterations of the impostor
  65366. * @param impostor impostor to set position on
  65367. * @param positionIterations positionIterations value
  65368. */
  65369. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65370. /**
  65371. * Append an anchor to a cloth object
  65372. * @param impostor is the cloth impostor to add anchor to
  65373. * @param otherImpostor is the rigid impostor to anchor to
  65374. * @param width ratio across width from 0 to 1
  65375. * @param height ratio up height from 0 to 1
  65376. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65377. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65378. */
  65379. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65380. /**
  65381. * Append an hook to a rope object
  65382. * @param impostor is the rope impostor to add hook to
  65383. * @param otherImpostor is the rigid impostor to hook to
  65384. * @param length ratio along the rope from 0 to 1
  65385. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65386. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65387. */
  65388. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65389. /**
  65390. * Sleeps the physics body and stops it from being active
  65391. * @param impostor impostor to sleep
  65392. */
  65393. sleepBody(impostor: PhysicsImpostor): void;
  65394. /**
  65395. * Activates the physics body
  65396. * @param impostor impostor to activate
  65397. */
  65398. wakeUpBody(impostor: PhysicsImpostor): void;
  65399. /**
  65400. * Updates the distance parameters of the joint
  65401. * @param joint joint to update
  65402. * @param maxDistance maximum distance of the joint
  65403. * @param minDistance minimum distance of the joint
  65404. */
  65405. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65406. /**
  65407. * Sets a motor on the joint
  65408. * @param joint joint to set motor on
  65409. * @param speed speed of the motor
  65410. * @param maxForce maximum force of the motor
  65411. * @param motorIndex index of the motor
  65412. */
  65413. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65414. /**
  65415. * Sets the motors limit
  65416. * @param joint joint to set limit on
  65417. * @param upperLimit upper limit
  65418. * @param lowerLimit lower limit
  65419. */
  65420. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65421. /**
  65422. * Syncs the position and rotation of a mesh with the impostor
  65423. * @param mesh mesh to sync
  65424. * @param impostor impostor to update the mesh with
  65425. */
  65426. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65427. /**
  65428. * Gets the radius of the impostor
  65429. * @param impostor impostor to get radius from
  65430. * @returns the radius
  65431. */
  65432. getRadius(impostor: PhysicsImpostor): number;
  65433. /**
  65434. * Gets the box size of the impostor
  65435. * @param impostor impostor to get box size from
  65436. * @param result the resulting box size
  65437. */
  65438. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65439. /**
  65440. * Disposes of the impostor
  65441. */
  65442. dispose(): void;
  65443. /**
  65444. * Does a raycast in the physics world
  65445. * @param from when should the ray start?
  65446. * @param to when should the ray end?
  65447. * @returns PhysicsRaycastResult
  65448. */
  65449. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65450. }
  65451. }
  65452. declare module BABYLON {
  65453. interface AbstractScene {
  65454. /**
  65455. * The list of reflection probes added to the scene
  65456. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65457. */
  65458. reflectionProbes: Array<ReflectionProbe>;
  65459. /**
  65460. * Removes the given reflection probe from this scene.
  65461. * @param toRemove The reflection probe to remove
  65462. * @returns The index of the removed reflection probe
  65463. */
  65464. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65465. /**
  65466. * Adds the given reflection probe to this scene.
  65467. * @param newReflectionProbe The reflection probe to add
  65468. */
  65469. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65470. }
  65471. /**
  65472. * Class used to generate realtime reflection / refraction cube textures
  65473. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65474. */
  65475. export class ReflectionProbe {
  65476. /** defines the name of the probe */
  65477. name: string;
  65478. private _scene;
  65479. private _renderTargetTexture;
  65480. private _projectionMatrix;
  65481. private _viewMatrix;
  65482. private _target;
  65483. private _add;
  65484. private _attachedMesh;
  65485. private _invertYAxis;
  65486. /** Gets or sets probe position (center of the cube map) */
  65487. position: Vector3;
  65488. /**
  65489. * Creates a new reflection probe
  65490. * @param name defines the name of the probe
  65491. * @param size defines the texture resolution (for each face)
  65492. * @param scene defines the hosting scene
  65493. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65494. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65495. */
  65496. constructor(
  65497. /** defines the name of the probe */
  65498. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65499. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65500. get samples(): number;
  65501. set samples(value: number);
  65502. /** Gets or sets the refresh rate to use (on every frame by default) */
  65503. get refreshRate(): number;
  65504. set refreshRate(value: number);
  65505. /**
  65506. * Gets the hosting scene
  65507. * @returns a Scene
  65508. */
  65509. getScene(): Scene;
  65510. /** Gets the internal CubeTexture used to render to */
  65511. get cubeTexture(): RenderTargetTexture;
  65512. /** Gets the list of meshes to render */
  65513. get renderList(): Nullable<AbstractMesh[]>;
  65514. /**
  65515. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65516. * @param mesh defines the mesh to attach to
  65517. */
  65518. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65519. /**
  65520. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65521. * @param renderingGroupId The rendering group id corresponding to its index
  65522. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65523. */
  65524. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65525. /**
  65526. * Clean all associated resources
  65527. */
  65528. dispose(): void;
  65529. /**
  65530. * Converts the reflection probe information to a readable string for debug purpose.
  65531. * @param fullDetails Supports for multiple levels of logging within scene loading
  65532. * @returns the human readable reflection probe info
  65533. */
  65534. toString(fullDetails?: boolean): string;
  65535. /**
  65536. * Get the class name of the relfection probe.
  65537. * @returns "ReflectionProbe"
  65538. */
  65539. getClassName(): string;
  65540. /**
  65541. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65542. * @returns The JSON representation of the texture
  65543. */
  65544. serialize(): any;
  65545. /**
  65546. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65547. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65548. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65549. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65550. * @returns The parsed reflection probe if successful
  65551. */
  65552. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65553. }
  65554. }
  65555. declare module BABYLON {
  65556. /** @hidden */
  65557. export var _BabylonLoaderRegistered: boolean;
  65558. /**
  65559. * Helps setting up some configuration for the babylon file loader.
  65560. */
  65561. export class BabylonFileLoaderConfiguration {
  65562. /**
  65563. * The loader does not allow injecting custom physix engine into the plugins.
  65564. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65565. * So you could set this variable to your engine import to make it work.
  65566. */
  65567. static LoaderInjectedPhysicsEngine: any;
  65568. }
  65569. }
  65570. declare module BABYLON {
  65571. /**
  65572. * A material to use for fast depth-only rendering.
  65573. */
  65574. export class OcclusionMaterial extends ShaderMaterial {
  65575. constructor(name: string, scene: Scene);
  65576. }
  65577. }
  65578. declare module BABYLON {
  65579. /**
  65580. * The Physically based simple base material of BJS.
  65581. *
  65582. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65583. * It is used as the base class for both the specGloss and metalRough conventions.
  65584. */
  65585. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65586. /**
  65587. * Number of Simultaneous lights allowed on the material.
  65588. */
  65589. maxSimultaneousLights: number;
  65590. /**
  65591. * If sets to true, disables all the lights affecting the material.
  65592. */
  65593. disableLighting: boolean;
  65594. /**
  65595. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65596. */
  65597. environmentTexture: BaseTexture;
  65598. /**
  65599. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65600. */
  65601. invertNormalMapX: boolean;
  65602. /**
  65603. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65604. */
  65605. invertNormalMapY: boolean;
  65606. /**
  65607. * Normal map used in the model.
  65608. */
  65609. normalTexture: BaseTexture;
  65610. /**
  65611. * Emissivie color used to self-illuminate the model.
  65612. */
  65613. emissiveColor: Color3;
  65614. /**
  65615. * Emissivie texture used to self-illuminate the model.
  65616. */
  65617. emissiveTexture: BaseTexture;
  65618. /**
  65619. * Occlusion Channel Strenght.
  65620. */
  65621. occlusionStrength: number;
  65622. /**
  65623. * Occlusion Texture of the material (adding extra occlusion effects).
  65624. */
  65625. occlusionTexture: BaseTexture;
  65626. /**
  65627. * Defines the alpha limits in alpha test mode.
  65628. */
  65629. alphaCutOff: number;
  65630. /**
  65631. * Gets the current double sided mode.
  65632. */
  65633. get doubleSided(): boolean;
  65634. /**
  65635. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65636. */
  65637. set doubleSided(value: boolean);
  65638. /**
  65639. * Stores the pre-calculated light information of a mesh in a texture.
  65640. */
  65641. lightmapTexture: BaseTexture;
  65642. /**
  65643. * If true, the light map contains occlusion information instead of lighting info.
  65644. */
  65645. useLightmapAsShadowmap: boolean;
  65646. /**
  65647. * Instantiates a new PBRMaterial instance.
  65648. *
  65649. * @param name The material name
  65650. * @param scene The scene the material will be use in.
  65651. */
  65652. constructor(name: string, scene: Scene);
  65653. getClassName(): string;
  65654. }
  65655. }
  65656. declare module BABYLON {
  65657. /**
  65658. * The PBR material of BJS following the metal roughness convention.
  65659. *
  65660. * This fits to the PBR convention in the GLTF definition:
  65661. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65662. */
  65663. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65664. /**
  65665. * The base color has two different interpretations depending on the value of metalness.
  65666. * When the material is a metal, the base color is the specific measured reflectance value
  65667. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65668. * of the material.
  65669. */
  65670. baseColor: Color3;
  65671. /**
  65672. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65673. * well as opacity information in the alpha channel.
  65674. */
  65675. baseTexture: BaseTexture;
  65676. /**
  65677. * Specifies the metallic scalar value of the material.
  65678. * Can also be used to scale the metalness values of the metallic texture.
  65679. */
  65680. metallic: number;
  65681. /**
  65682. * Specifies the roughness scalar value of the material.
  65683. * Can also be used to scale the roughness values of the metallic texture.
  65684. */
  65685. roughness: number;
  65686. /**
  65687. * Texture containing both the metallic value in the B channel and the
  65688. * roughness value in the G channel to keep better precision.
  65689. */
  65690. metallicRoughnessTexture: BaseTexture;
  65691. /**
  65692. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65693. *
  65694. * @param name The material name
  65695. * @param scene The scene the material will be use in.
  65696. */
  65697. constructor(name: string, scene: Scene);
  65698. /**
  65699. * Return the currrent class name of the material.
  65700. */
  65701. getClassName(): string;
  65702. /**
  65703. * Makes a duplicate of the current material.
  65704. * @param name - name to use for the new material.
  65705. */
  65706. clone(name: string): PBRMetallicRoughnessMaterial;
  65707. /**
  65708. * Serialize the material to a parsable JSON object.
  65709. */
  65710. serialize(): any;
  65711. /**
  65712. * Parses a JSON object correponding to the serialize function.
  65713. */
  65714. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65715. }
  65716. }
  65717. declare module BABYLON {
  65718. /**
  65719. * The PBR material of BJS following the specular glossiness convention.
  65720. *
  65721. * This fits to the PBR convention in the GLTF definition:
  65722. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65723. */
  65724. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65725. /**
  65726. * Specifies the diffuse color of the material.
  65727. */
  65728. diffuseColor: Color3;
  65729. /**
  65730. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65731. * channel.
  65732. */
  65733. diffuseTexture: BaseTexture;
  65734. /**
  65735. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65736. */
  65737. specularColor: Color3;
  65738. /**
  65739. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65740. */
  65741. glossiness: number;
  65742. /**
  65743. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65744. */
  65745. specularGlossinessTexture: BaseTexture;
  65746. /**
  65747. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  65748. */
  65749. get useMicroSurfaceFromReflectivityMapAlpha(): boolean;
  65750. /**
  65751. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65752. *
  65753. * @param name The material name
  65754. * @param scene The scene the material will be use in.
  65755. */
  65756. constructor(name: string, scene: Scene);
  65757. /**
  65758. * Return the currrent class name of the material.
  65759. */
  65760. getClassName(): string;
  65761. /**
  65762. * Makes a duplicate of the current material.
  65763. * @param name - name to use for the new material.
  65764. */
  65765. clone(name: string): PBRSpecularGlossinessMaterial;
  65766. /**
  65767. * Serialize the material to a parsable JSON object.
  65768. */
  65769. serialize(): any;
  65770. /**
  65771. * Parses a JSON object correponding to the serialize function.
  65772. */
  65773. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65774. }
  65775. }
  65776. declare module BABYLON {
  65777. /**
  65778. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65779. * It can help converting any input color in a desired output one. This can then be used to create effects
  65780. * from sepia, black and white to sixties or futuristic rendering...
  65781. *
  65782. * The only supported format is currently 3dl.
  65783. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65784. */
  65785. export class ColorGradingTexture extends BaseTexture {
  65786. /**
  65787. * The texture URL.
  65788. */
  65789. url: string;
  65790. /**
  65791. * Empty line regex stored for GC.
  65792. */
  65793. private static _noneEmptyLineRegex;
  65794. private _textureMatrix;
  65795. private _onLoad;
  65796. /**
  65797. * Instantiates a ColorGradingTexture from the following parameters.
  65798. *
  65799. * @param url The location of the color gradind data (currently only supporting 3dl)
  65800. * @param sceneOrEngine The scene or engine the texture will be used in
  65801. * @param onLoad defines a callback triggered when the texture has been loaded
  65802. */
  65803. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65804. /**
  65805. * Fires the onload event from the constructor if requested.
  65806. */
  65807. private _triggerOnLoad;
  65808. /**
  65809. * Returns the texture matrix used in most of the material.
  65810. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65811. */
  65812. getTextureMatrix(): Matrix;
  65813. /**
  65814. * Occurs when the file being loaded is a .3dl LUT file.
  65815. */
  65816. private load3dlTexture;
  65817. /**
  65818. * Starts the loading process of the texture.
  65819. */
  65820. private loadTexture;
  65821. /**
  65822. * Clones the color gradind texture.
  65823. */
  65824. clone(): ColorGradingTexture;
  65825. /**
  65826. * Called during delayed load for textures.
  65827. */
  65828. delayLoad(): void;
  65829. /**
  65830. * Parses a color grading texture serialized by Babylon.
  65831. * @param parsedTexture The texture information being parsedTexture
  65832. * @param scene The scene to load the texture in
  65833. * @param rootUrl The root url of the data assets to load
  65834. * @return A color gradind texture
  65835. */
  65836. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65837. /**
  65838. * Serializes the LUT texture to json format.
  65839. */
  65840. serialize(): any;
  65841. }
  65842. }
  65843. declare module BABYLON {
  65844. /**
  65845. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65846. */
  65847. export class EquiRectangularCubeTexture extends BaseTexture {
  65848. /** The six faces of the cube. */
  65849. private static _FacesMapping;
  65850. private _noMipmap;
  65851. private _onLoad;
  65852. private _onError;
  65853. /** The size of the cubemap. */
  65854. private _size;
  65855. /** The buffer of the image. */
  65856. private _buffer;
  65857. /** The width of the input image. */
  65858. private _width;
  65859. /** The height of the input image. */
  65860. private _height;
  65861. /** The URL to the image. */
  65862. url: string;
  65863. /**
  65864. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65865. * @param url The location of the image
  65866. * @param scene The scene the texture will be used in
  65867. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65868. * @param noMipmap Forces to not generate the mipmap if true
  65869. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65870. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65871. * @param onLoad — defines a callback called when texture is loaded
  65872. * @param onError — defines a callback called if there is an error
  65873. */
  65874. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65875. /**
  65876. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65877. */
  65878. private loadImage;
  65879. /**
  65880. * Convert the image buffer into a cubemap and create a CubeTexture.
  65881. */
  65882. private loadTexture;
  65883. /**
  65884. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65885. * @param buffer The ArrayBuffer that should be converted.
  65886. * @returns The buffer as Float32Array.
  65887. */
  65888. private getFloat32ArrayFromArrayBuffer;
  65889. /**
  65890. * Get the current class name of the texture useful for serialization or dynamic coding.
  65891. * @returns "EquiRectangularCubeTexture"
  65892. */
  65893. getClassName(): string;
  65894. /**
  65895. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65896. * @returns A clone of the current EquiRectangularCubeTexture.
  65897. */
  65898. clone(): EquiRectangularCubeTexture;
  65899. }
  65900. }
  65901. declare module BABYLON {
  65902. /**
  65903. * Defines the options related to the creation of an HtmlElementTexture
  65904. */
  65905. export interface IHtmlElementTextureOptions {
  65906. /**
  65907. * Defines wether mip maps should be created or not.
  65908. */
  65909. generateMipMaps?: boolean;
  65910. /**
  65911. * Defines the sampling mode of the texture.
  65912. */
  65913. samplingMode?: number;
  65914. /**
  65915. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65916. */
  65917. engine: Nullable<ThinEngine>;
  65918. /**
  65919. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65920. */
  65921. scene: Nullable<Scene>;
  65922. }
  65923. /**
  65924. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65925. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65926. * is automatically managed.
  65927. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65928. * in your application.
  65929. *
  65930. * As the update is not automatic, you need to call them manually.
  65931. */
  65932. export class HtmlElementTexture extends BaseTexture {
  65933. /**
  65934. * The texture URL.
  65935. */
  65936. element: HTMLVideoElement | HTMLCanvasElement;
  65937. private static readonly DefaultOptions;
  65938. private _textureMatrix;
  65939. private _isVideo;
  65940. private _generateMipMaps;
  65941. private _samplingMode;
  65942. /**
  65943. * Instantiates a HtmlElementTexture from the following parameters.
  65944. *
  65945. * @param name Defines the name of the texture
  65946. * @param element Defines the video or canvas the texture is filled with
  65947. * @param options Defines the other none mandatory texture creation options
  65948. */
  65949. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65950. private _createInternalTexture;
  65951. /**
  65952. * Returns the texture matrix used in most of the material.
  65953. */
  65954. getTextureMatrix(): Matrix;
  65955. /**
  65956. * Updates the content of the texture.
  65957. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65958. */
  65959. update(invertY?: Nullable<boolean>): void;
  65960. }
  65961. }
  65962. declare module BABYLON {
  65963. /**
  65964. * Based on jsTGALoader - Javascript loader for TGA file
  65965. * By Vincent Thibault
  65966. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65967. */
  65968. export class TGATools {
  65969. private static _TYPE_INDEXED;
  65970. private static _TYPE_RGB;
  65971. private static _TYPE_GREY;
  65972. private static _TYPE_RLE_INDEXED;
  65973. private static _TYPE_RLE_RGB;
  65974. private static _TYPE_RLE_GREY;
  65975. private static _ORIGIN_MASK;
  65976. private static _ORIGIN_SHIFT;
  65977. private static _ORIGIN_BL;
  65978. private static _ORIGIN_BR;
  65979. private static _ORIGIN_UL;
  65980. private static _ORIGIN_UR;
  65981. /**
  65982. * Gets the header of a TGA file
  65983. * @param data defines the TGA data
  65984. * @returns the header
  65985. */
  65986. static GetTGAHeader(data: Uint8Array): any;
  65987. /**
  65988. * Uploads TGA content to a Babylon Texture
  65989. * @hidden
  65990. */
  65991. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65992. /** @hidden */
  65993. 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;
  65994. /** @hidden */
  65995. 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;
  65996. /** @hidden */
  65997. 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;
  65998. /** @hidden */
  65999. 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;
  66000. /** @hidden */
  66001. 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;
  66002. /** @hidden */
  66003. 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;
  66004. }
  66005. }
  66006. declare module BABYLON {
  66007. /**
  66008. * Implementation of the TGA Texture Loader.
  66009. * @hidden
  66010. */
  66011. export class _TGATextureLoader implements IInternalTextureLoader {
  66012. /**
  66013. * Defines wether the loader supports cascade loading the different faces.
  66014. */
  66015. readonly supportCascades: boolean;
  66016. /**
  66017. * This returns if the loader support the current file information.
  66018. * @param extension defines the file extension of the file being loaded
  66019. * @returns true if the loader can load the specified file
  66020. */
  66021. canLoad(extension: string): boolean;
  66022. /**
  66023. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66024. * @param data contains the texture data
  66025. * @param texture defines the BabylonJS internal texture
  66026. * @param createPolynomials will be true if polynomials have been requested
  66027. * @param onLoad defines the callback to trigger once the texture is ready
  66028. * @param onError defines the callback to trigger in case of error
  66029. */
  66030. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66031. /**
  66032. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66033. * @param data contains the texture data
  66034. * @param texture defines the BabylonJS internal texture
  66035. * @param callback defines the method to call once ready to upload
  66036. */
  66037. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66038. }
  66039. }
  66040. declare module BABYLON {
  66041. /**
  66042. * Info about the .basis files
  66043. */
  66044. class BasisFileInfo {
  66045. /**
  66046. * If the file has alpha
  66047. */
  66048. hasAlpha: boolean;
  66049. /**
  66050. * Info about each image of the basis file
  66051. */
  66052. images: Array<{
  66053. levels: Array<{
  66054. width: number;
  66055. height: number;
  66056. transcodedPixels: ArrayBufferView;
  66057. }>;
  66058. }>;
  66059. }
  66060. /**
  66061. * Result of transcoding a basis file
  66062. */
  66063. class TranscodeResult {
  66064. /**
  66065. * Info about the .basis file
  66066. */
  66067. fileInfo: BasisFileInfo;
  66068. /**
  66069. * Format to use when loading the file
  66070. */
  66071. format: number;
  66072. }
  66073. /**
  66074. * Configuration options for the Basis transcoder
  66075. */
  66076. export class BasisTranscodeConfiguration {
  66077. /**
  66078. * Supported compression formats used to determine the supported output format of the transcoder
  66079. */
  66080. supportedCompressionFormats?: {
  66081. /**
  66082. * etc1 compression format
  66083. */
  66084. etc1?: boolean;
  66085. /**
  66086. * s3tc compression format
  66087. */
  66088. s3tc?: boolean;
  66089. /**
  66090. * pvrtc compression format
  66091. */
  66092. pvrtc?: boolean;
  66093. /**
  66094. * etc2 compression format
  66095. */
  66096. etc2?: boolean;
  66097. };
  66098. /**
  66099. * If mipmap levels should be loaded for transcoded images (Default: true)
  66100. */
  66101. loadMipmapLevels?: boolean;
  66102. /**
  66103. * Index of a single image to load (Default: all images)
  66104. */
  66105. loadSingleImage?: number;
  66106. }
  66107. /**
  66108. * Used to load .Basis files
  66109. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  66110. */
  66111. export class BasisTools {
  66112. private static _IgnoreSupportedFormats;
  66113. /**
  66114. * URL to use when loading the basis transcoder
  66115. */
  66116. static JSModuleURL: string;
  66117. /**
  66118. * URL to use when loading the wasm module for the transcoder
  66119. */
  66120. static WasmModuleURL: string;
  66121. /**
  66122. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  66123. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  66124. * @returns internal format corresponding to the Basis format
  66125. */
  66126. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  66127. private static _WorkerPromise;
  66128. private static _Worker;
  66129. private static _actionId;
  66130. private static _CreateWorkerAsync;
  66131. /**
  66132. * Transcodes a loaded image file to compressed pixel data
  66133. * @param data image data to transcode
  66134. * @param config configuration options for the transcoding
  66135. * @returns a promise resulting in the transcoded image
  66136. */
  66137. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  66138. /**
  66139. * Loads a texture from the transcode result
  66140. * @param texture texture load to
  66141. * @param transcodeResult the result of transcoding the basis file to load from
  66142. */
  66143. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  66144. }
  66145. }
  66146. declare module BABYLON {
  66147. /**
  66148. * Loader for .basis file format
  66149. */
  66150. export class _BasisTextureLoader implements IInternalTextureLoader {
  66151. /**
  66152. * Defines whether the loader supports cascade loading the different faces.
  66153. */
  66154. readonly supportCascades: boolean;
  66155. /**
  66156. * This returns if the loader support the current file information.
  66157. * @param extension defines the file extension of the file being loaded
  66158. * @returns true if the loader can load the specified file
  66159. */
  66160. canLoad(extension: string): boolean;
  66161. /**
  66162. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  66163. * @param data contains the texture data
  66164. * @param texture defines the BabylonJS internal texture
  66165. * @param createPolynomials will be true if polynomials have been requested
  66166. * @param onLoad defines the callback to trigger once the texture is ready
  66167. * @param onError defines the callback to trigger in case of error
  66168. */
  66169. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  66170. /**
  66171. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  66172. * @param data contains the texture data
  66173. * @param texture defines the BabylonJS internal texture
  66174. * @param callback defines the method to call once ready to upload
  66175. */
  66176. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  66177. }
  66178. }
  66179. declare module BABYLON {
  66180. /**
  66181. * Defines the basic options interface of a TexturePacker Frame
  66182. */
  66183. export interface ITexturePackerFrame {
  66184. /**
  66185. * The frame ID
  66186. */
  66187. id: number;
  66188. /**
  66189. * The frames Scale
  66190. */
  66191. scale: Vector2;
  66192. /**
  66193. * The Frames offset
  66194. */
  66195. offset: Vector2;
  66196. }
  66197. /**
  66198. * This is a support class for frame Data on texture packer sets.
  66199. */
  66200. export class TexturePackerFrame implements ITexturePackerFrame {
  66201. /**
  66202. * The frame ID
  66203. */
  66204. id: number;
  66205. /**
  66206. * The frames Scale
  66207. */
  66208. scale: Vector2;
  66209. /**
  66210. * The Frames offset
  66211. */
  66212. offset: Vector2;
  66213. /**
  66214. * Initializes a texture package frame.
  66215. * @param id The numerical frame identifier
  66216. * @param scale Scalar Vector2 for UV frame
  66217. * @param offset Vector2 for the frame position in UV units.
  66218. * @returns TexturePackerFrame
  66219. */
  66220. constructor(id: number, scale: Vector2, offset: Vector2);
  66221. }
  66222. }
  66223. declare module BABYLON {
  66224. /**
  66225. * Defines the basic options interface of a TexturePacker
  66226. */
  66227. export interface ITexturePackerOptions {
  66228. /**
  66229. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  66230. */
  66231. map?: string[];
  66232. /**
  66233. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66234. */
  66235. uvsIn?: string;
  66236. /**
  66237. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  66238. */
  66239. uvsOut?: string;
  66240. /**
  66241. * number representing the layout style. Defaults to LAYOUT_STRIP
  66242. */
  66243. layout?: number;
  66244. /**
  66245. * number of columns if using custom column count layout(2). This defaults to 4.
  66246. */
  66247. colnum?: number;
  66248. /**
  66249. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  66250. */
  66251. updateInputMeshes?: boolean;
  66252. /**
  66253. * boolean flag to dispose all the source textures. Defaults to true.
  66254. */
  66255. disposeSources?: boolean;
  66256. /**
  66257. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  66258. */
  66259. fillBlanks?: boolean;
  66260. /**
  66261. * string value representing the context fill style color. Defaults to 'black'.
  66262. */
  66263. customFillColor?: string;
  66264. /**
  66265. * Width and Height Value of each Frame in the TexturePacker Sets
  66266. */
  66267. frameSize?: number;
  66268. /**
  66269. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  66270. */
  66271. paddingRatio?: number;
  66272. /**
  66273. * Number that declares the fill method for the padding gutter.
  66274. */
  66275. paddingMode?: number;
  66276. /**
  66277. * If in SUBUV_COLOR padding mode what color to use.
  66278. */
  66279. paddingColor?: Color3 | Color4;
  66280. }
  66281. /**
  66282. * Defines the basic interface of a TexturePacker JSON File
  66283. */
  66284. export interface ITexturePackerJSON {
  66285. /**
  66286. * The frame ID
  66287. */
  66288. name: string;
  66289. /**
  66290. * The base64 channel data
  66291. */
  66292. sets: any;
  66293. /**
  66294. * The options of the Packer
  66295. */
  66296. options: ITexturePackerOptions;
  66297. /**
  66298. * The frame data of the Packer
  66299. */
  66300. frames: Array<number>;
  66301. }
  66302. /**
  66303. * This is a support class that generates a series of packed texture sets.
  66304. * @see https://doc.babylonjs.com/babylon101/materials
  66305. */
  66306. export class TexturePacker {
  66307. /** Packer Layout Constant 0 */
  66308. static readonly LAYOUT_STRIP: number;
  66309. /** Packer Layout Constant 1 */
  66310. static readonly LAYOUT_POWER2: number;
  66311. /** Packer Layout Constant 2 */
  66312. static readonly LAYOUT_COLNUM: number;
  66313. /** Packer Layout Constant 0 */
  66314. static readonly SUBUV_WRAP: number;
  66315. /** Packer Layout Constant 1 */
  66316. static readonly SUBUV_EXTEND: number;
  66317. /** Packer Layout Constant 2 */
  66318. static readonly SUBUV_COLOR: number;
  66319. /** The Name of the Texture Package */
  66320. name: string;
  66321. /** The scene scope of the TexturePacker */
  66322. scene: Scene;
  66323. /** The Meshes to target */
  66324. meshes: AbstractMesh[];
  66325. /** Arguments passed with the Constructor */
  66326. options: ITexturePackerOptions;
  66327. /** The promise that is started upon initialization */
  66328. promise: Nullable<Promise<TexturePacker | string>>;
  66329. /** The Container object for the channel sets that are generated */
  66330. sets: object;
  66331. /** The Container array for the frames that are generated */
  66332. frames: TexturePackerFrame[];
  66333. /** The expected number of textures the system is parsing. */
  66334. private _expecting;
  66335. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66336. private _paddingValue;
  66337. /**
  66338. * Initializes a texture package series from an array of meshes or a single mesh.
  66339. * @param name The name of the package
  66340. * @param meshes The target meshes to compose the package from
  66341. * @param options The arguments that texture packer should follow while building.
  66342. * @param scene The scene which the textures are scoped to.
  66343. * @returns TexturePacker
  66344. */
  66345. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66346. /**
  66347. * Starts the package process
  66348. * @param resolve The promises resolution function
  66349. * @returns TexturePacker
  66350. */
  66351. private _createFrames;
  66352. /**
  66353. * Calculates the Size of the Channel Sets
  66354. * @returns Vector2
  66355. */
  66356. private _calculateSize;
  66357. /**
  66358. * Calculates the UV data for the frames.
  66359. * @param baseSize the base frameSize
  66360. * @param padding the base frame padding
  66361. * @param dtSize size of the Dynamic Texture for that channel
  66362. * @param dtUnits is 1/dtSize
  66363. * @param update flag to update the input meshes
  66364. */
  66365. private _calculateMeshUVFrames;
  66366. /**
  66367. * Calculates the frames Offset.
  66368. * @param index of the frame
  66369. * @returns Vector2
  66370. */
  66371. private _getFrameOffset;
  66372. /**
  66373. * Updates a Mesh to the frame data
  66374. * @param mesh that is the target
  66375. * @param frameID or the frame index
  66376. */
  66377. private _updateMeshUV;
  66378. /**
  66379. * Updates a Meshes materials to use the texture packer channels
  66380. * @param m is the mesh to target
  66381. * @param force all channels on the packer to be set.
  66382. */
  66383. private _updateTextureReferences;
  66384. /**
  66385. * Public method to set a Mesh to a frame
  66386. * @param m that is the target
  66387. * @param frameID or the frame index
  66388. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66389. */
  66390. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66391. /**
  66392. * Starts the async promise to compile the texture packer.
  66393. * @returns Promise<void>
  66394. */
  66395. processAsync(): Promise<void>;
  66396. /**
  66397. * Disposes all textures associated with this packer
  66398. */
  66399. dispose(): void;
  66400. /**
  66401. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66402. * @param imageType is the image type to use.
  66403. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66404. */
  66405. download(imageType?: string, quality?: number): void;
  66406. /**
  66407. * Public method to load a texturePacker JSON file.
  66408. * @param data of the JSON file in string format.
  66409. */
  66410. updateFromJSON(data: string): void;
  66411. }
  66412. }
  66413. declare module BABYLON {
  66414. /**
  66415. * 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.
  66416. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66417. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66418. */
  66419. export class CustomProceduralTexture extends ProceduralTexture {
  66420. private _animate;
  66421. private _time;
  66422. private _config;
  66423. private _texturePath;
  66424. /**
  66425. * Instantiates a new Custom Procedural Texture.
  66426. * 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.
  66427. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66428. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66429. * @param name Define the name of the texture
  66430. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66431. * @param size Define the size of the texture to create
  66432. * @param scene Define the scene the texture belongs to
  66433. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66434. * @param generateMipMaps Define if the texture should creates mip maps or not
  66435. */
  66436. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66437. private _loadJson;
  66438. /**
  66439. * Is the texture ready to be used ? (rendered at least once)
  66440. * @returns true if ready, otherwise, false.
  66441. */
  66442. isReady(): boolean;
  66443. /**
  66444. * Render the texture to its associated render target.
  66445. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66446. */
  66447. render(useCameraPostProcess?: boolean): void;
  66448. /**
  66449. * Update the list of dependant textures samplers in the shader.
  66450. */
  66451. updateTextures(): void;
  66452. /**
  66453. * Update the uniform values of the procedural texture in the shader.
  66454. */
  66455. updateShaderUniforms(): void;
  66456. /**
  66457. * Define if the texture animates or not.
  66458. */
  66459. get animate(): boolean;
  66460. set animate(value: boolean);
  66461. }
  66462. }
  66463. declare module BABYLON {
  66464. /** @hidden */
  66465. export var noisePixelShader: {
  66466. name: string;
  66467. shader: string;
  66468. };
  66469. }
  66470. declare module BABYLON {
  66471. /**
  66472. * Class used to generate noise procedural textures
  66473. */
  66474. export class NoiseProceduralTexture extends ProceduralTexture {
  66475. /** Gets or sets the start time (default is 0) */
  66476. time: number;
  66477. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66478. brightness: number;
  66479. /** Defines the number of octaves to process */
  66480. octaves: number;
  66481. /** Defines the level of persistence (0.8 by default) */
  66482. persistence: number;
  66483. /** Gets or sets animation speed factor (default is 1) */
  66484. animationSpeedFactor: number;
  66485. /**
  66486. * Creates a new NoiseProceduralTexture
  66487. * @param name defines the name fo the texture
  66488. * @param size defines the size of the texture (default is 256)
  66489. * @param scene defines the hosting scene
  66490. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66491. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66492. */
  66493. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66494. private _updateShaderUniforms;
  66495. protected _getDefines(): string;
  66496. /** Generate the current state of the procedural texture */
  66497. render(useCameraPostProcess?: boolean): void;
  66498. /**
  66499. * Serializes this noise procedural texture
  66500. * @returns a serialized noise procedural texture object
  66501. */
  66502. serialize(): any;
  66503. /**
  66504. * Clone the texture.
  66505. * @returns the cloned texture
  66506. */
  66507. clone(): NoiseProceduralTexture;
  66508. /**
  66509. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66510. * @param parsedTexture defines parsed texture data
  66511. * @param scene defines the current scene
  66512. * @param rootUrl defines the root URL containing noise procedural texture information
  66513. * @returns a parsed NoiseProceduralTexture
  66514. */
  66515. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66516. }
  66517. }
  66518. declare module BABYLON {
  66519. /**
  66520. * Raw cube texture where the raw buffers are passed in
  66521. */
  66522. export class RawCubeTexture extends CubeTexture {
  66523. /**
  66524. * Creates a cube texture where the raw buffers are passed in.
  66525. * @param scene defines the scene the texture is attached to
  66526. * @param data defines the array of data to use to create each face
  66527. * @param size defines the size of the textures
  66528. * @param format defines the format of the data
  66529. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66530. * @param generateMipMaps defines if the engine should generate the mip levels
  66531. * @param invertY defines if data must be stored with Y axis inverted
  66532. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66533. * @param compression defines the compression used (null by default)
  66534. */
  66535. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66536. /**
  66537. * Updates the raw cube texture.
  66538. * @param data defines the data to store
  66539. * @param format defines the data format
  66540. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66541. * @param invertY defines if data must be stored with Y axis inverted
  66542. * @param compression defines the compression used (null by default)
  66543. * @param level defines which level of the texture to update
  66544. */
  66545. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66546. /**
  66547. * Updates a raw cube texture with RGBD encoded data.
  66548. * @param data defines the array of data [mipmap][face] to use to create each face
  66549. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66550. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66551. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66552. * @returns a promsie that resolves when the operation is complete
  66553. */
  66554. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66555. /**
  66556. * Clones the raw cube texture.
  66557. * @return a new cube texture
  66558. */
  66559. clone(): CubeTexture;
  66560. /** @hidden */
  66561. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66562. }
  66563. }
  66564. declare module BABYLON {
  66565. /**
  66566. * Class used to store 2D array textures containing user data
  66567. */
  66568. export class RawTexture2DArray extends Texture {
  66569. /** Gets or sets the texture format to use */
  66570. format: number;
  66571. /**
  66572. * Create a new RawTexture2DArray
  66573. * @param data defines the data of the texture
  66574. * @param width defines the width of the texture
  66575. * @param height defines the height of the texture
  66576. * @param depth defines the number of layers of the texture
  66577. * @param format defines the texture format to use
  66578. * @param scene defines the hosting scene
  66579. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66580. * @param invertY defines if texture must be stored with Y axis inverted
  66581. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66582. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66583. */
  66584. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66585. /** Gets or sets the texture format to use */
  66586. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66587. /**
  66588. * Update the texture with new data
  66589. * @param data defines the data to store in the texture
  66590. */
  66591. update(data: ArrayBufferView): void;
  66592. }
  66593. }
  66594. declare module BABYLON {
  66595. /**
  66596. * Class used to store 3D textures containing user data
  66597. */
  66598. export class RawTexture3D extends Texture {
  66599. /** Gets or sets the texture format to use */
  66600. format: number;
  66601. /**
  66602. * Create a new RawTexture3D
  66603. * @param data defines the data of the texture
  66604. * @param width defines the width of the texture
  66605. * @param height defines the height of the texture
  66606. * @param depth defines the depth of the texture
  66607. * @param format defines the texture format to use
  66608. * @param scene defines the hosting scene
  66609. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66610. * @param invertY defines if texture must be stored with Y axis inverted
  66611. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66612. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66613. */
  66614. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66615. /** Gets or sets the texture format to use */
  66616. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66617. /**
  66618. * Update the texture with new data
  66619. * @param data defines the data to store in the texture
  66620. */
  66621. update(data: ArrayBufferView): void;
  66622. }
  66623. }
  66624. declare module BABYLON {
  66625. /**
  66626. * Creates a refraction texture used by refraction channel of the standard material.
  66627. * It is like a mirror but to see through a material.
  66628. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66629. */
  66630. export class RefractionTexture extends RenderTargetTexture {
  66631. /**
  66632. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66633. * 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.
  66634. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66635. */
  66636. refractionPlane: Plane;
  66637. /**
  66638. * Define how deep under the surface we should see.
  66639. */
  66640. depth: number;
  66641. /**
  66642. * Creates a refraction texture used by refraction channel of the standard material.
  66643. * It is like a mirror but to see through a material.
  66644. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66645. * @param name Define the texture name
  66646. * @param size Define the size of the underlying texture
  66647. * @param scene Define the scene the refraction belongs to
  66648. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66649. */
  66650. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66651. /**
  66652. * Clone the refraction texture.
  66653. * @returns the cloned texture
  66654. */
  66655. clone(): RefractionTexture;
  66656. /**
  66657. * Serialize the texture to a JSON representation you could use in Parse later on
  66658. * @returns the serialized JSON representation
  66659. */
  66660. serialize(): any;
  66661. }
  66662. }
  66663. declare module BABYLON {
  66664. /**
  66665. * Block used to add support for vertex skinning (bones)
  66666. */
  66667. export class BonesBlock extends NodeMaterialBlock {
  66668. /**
  66669. * Creates a new BonesBlock
  66670. * @param name defines the block name
  66671. */
  66672. constructor(name: string);
  66673. /**
  66674. * Initialize the block and prepare the context for build
  66675. * @param state defines the state that will be used for the build
  66676. */
  66677. initialize(state: NodeMaterialBuildState): void;
  66678. /**
  66679. * Gets the current class name
  66680. * @returns the class name
  66681. */
  66682. getClassName(): string;
  66683. /**
  66684. * Gets the matrix indices input component
  66685. */
  66686. get matricesIndices(): NodeMaterialConnectionPoint;
  66687. /**
  66688. * Gets the matrix weights input component
  66689. */
  66690. get matricesWeights(): NodeMaterialConnectionPoint;
  66691. /**
  66692. * Gets the extra matrix indices input component
  66693. */
  66694. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66695. /**
  66696. * Gets the extra matrix weights input component
  66697. */
  66698. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66699. /**
  66700. * Gets the world input component
  66701. */
  66702. get world(): NodeMaterialConnectionPoint;
  66703. /**
  66704. * Gets the output component
  66705. */
  66706. get output(): NodeMaterialConnectionPoint;
  66707. autoConfigure(material: NodeMaterial): void;
  66708. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66710. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66711. protected _buildBlock(state: NodeMaterialBuildState): this;
  66712. }
  66713. }
  66714. declare module BABYLON {
  66715. /**
  66716. * Block used to add support for instances
  66717. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66718. */
  66719. export class InstancesBlock extends NodeMaterialBlock {
  66720. /**
  66721. * Creates a new InstancesBlock
  66722. * @param name defines the block name
  66723. */
  66724. constructor(name: string);
  66725. /**
  66726. * Gets the current class name
  66727. * @returns the class name
  66728. */
  66729. getClassName(): string;
  66730. /**
  66731. * Gets the first world row input component
  66732. */
  66733. get world0(): NodeMaterialConnectionPoint;
  66734. /**
  66735. * Gets the second world row input component
  66736. */
  66737. get world1(): NodeMaterialConnectionPoint;
  66738. /**
  66739. * Gets the third world row input component
  66740. */
  66741. get world2(): NodeMaterialConnectionPoint;
  66742. /**
  66743. * Gets the forth world row input component
  66744. */
  66745. get world3(): NodeMaterialConnectionPoint;
  66746. /**
  66747. * Gets the world input component
  66748. */
  66749. get world(): NodeMaterialConnectionPoint;
  66750. /**
  66751. * Gets the output component
  66752. */
  66753. get output(): NodeMaterialConnectionPoint;
  66754. /**
  66755. * Gets the isntanceID component
  66756. */
  66757. get instanceID(): NodeMaterialConnectionPoint;
  66758. autoConfigure(material: NodeMaterial): void;
  66759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66760. protected _buildBlock(state: NodeMaterialBuildState): this;
  66761. }
  66762. }
  66763. declare module BABYLON {
  66764. /**
  66765. * Block used to add morph targets support to vertex shader
  66766. */
  66767. export class MorphTargetsBlock extends NodeMaterialBlock {
  66768. private _repeatableContentAnchor;
  66769. /**
  66770. * Create a new MorphTargetsBlock
  66771. * @param name defines the block name
  66772. */
  66773. constructor(name: string);
  66774. /**
  66775. * Gets the current class name
  66776. * @returns the class name
  66777. */
  66778. getClassName(): string;
  66779. /**
  66780. * Gets the position input component
  66781. */
  66782. get position(): NodeMaterialConnectionPoint;
  66783. /**
  66784. * Gets the normal input component
  66785. */
  66786. get normal(): NodeMaterialConnectionPoint;
  66787. /**
  66788. * Gets the tangent input component
  66789. */
  66790. get tangent(): NodeMaterialConnectionPoint;
  66791. /**
  66792. * Gets the tangent input component
  66793. */
  66794. get uv(): NodeMaterialConnectionPoint;
  66795. /**
  66796. * Gets the position output component
  66797. */
  66798. get positionOutput(): NodeMaterialConnectionPoint;
  66799. /**
  66800. * Gets the normal output component
  66801. */
  66802. get normalOutput(): NodeMaterialConnectionPoint;
  66803. /**
  66804. * Gets the tangent output component
  66805. */
  66806. get tangentOutput(): NodeMaterialConnectionPoint;
  66807. /**
  66808. * Gets the tangent output component
  66809. */
  66810. get uvOutput(): NodeMaterialConnectionPoint;
  66811. initialize(state: NodeMaterialBuildState): void;
  66812. autoConfigure(material: NodeMaterial): void;
  66813. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66814. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66815. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66816. protected _buildBlock(state: NodeMaterialBuildState): this;
  66817. }
  66818. }
  66819. declare module BABYLON {
  66820. /**
  66821. * Block used to get data information from a light
  66822. */
  66823. export class LightInformationBlock extends NodeMaterialBlock {
  66824. private _lightDataUniformName;
  66825. private _lightColorUniformName;
  66826. private _lightTypeDefineName;
  66827. /**
  66828. * Gets or sets the light associated with this block
  66829. */
  66830. light: Nullable<Light>;
  66831. /**
  66832. * Creates a new LightInformationBlock
  66833. * @param name defines the block name
  66834. */
  66835. constructor(name: string);
  66836. /**
  66837. * Gets the current class name
  66838. * @returns the class name
  66839. */
  66840. getClassName(): string;
  66841. /**
  66842. * Gets the world position input component
  66843. */
  66844. get worldPosition(): NodeMaterialConnectionPoint;
  66845. /**
  66846. * Gets the direction output component
  66847. */
  66848. get direction(): NodeMaterialConnectionPoint;
  66849. /**
  66850. * Gets the direction output component
  66851. */
  66852. get color(): NodeMaterialConnectionPoint;
  66853. /**
  66854. * Gets the direction output component
  66855. */
  66856. get intensity(): NodeMaterialConnectionPoint;
  66857. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66858. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66859. protected _buildBlock(state: NodeMaterialBuildState): this;
  66860. serialize(): any;
  66861. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66862. }
  66863. }
  66864. declare module BABYLON {
  66865. /**
  66866. * Block used to add image processing support to fragment shader
  66867. */
  66868. export class ImageProcessingBlock extends NodeMaterialBlock {
  66869. /**
  66870. * Create a new ImageProcessingBlock
  66871. * @param name defines the block name
  66872. */
  66873. constructor(name: string);
  66874. /**
  66875. * Gets the current class name
  66876. * @returns the class name
  66877. */
  66878. getClassName(): string;
  66879. /**
  66880. * Gets the color input component
  66881. */
  66882. get color(): NodeMaterialConnectionPoint;
  66883. /**
  66884. * Gets the output component
  66885. */
  66886. get output(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Initialize the block and prepare the context for build
  66889. * @param state defines the state that will be used for the build
  66890. */
  66891. initialize(state: NodeMaterialBuildState): void;
  66892. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66894. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66895. protected _buildBlock(state: NodeMaterialBuildState): this;
  66896. }
  66897. }
  66898. declare module BABYLON {
  66899. /**
  66900. * Block used to pertub normals based on a normal map
  66901. */
  66902. export class PerturbNormalBlock extends NodeMaterialBlock {
  66903. private _tangentSpaceParameterName;
  66904. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66905. invertX: boolean;
  66906. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66907. invertY: boolean;
  66908. /**
  66909. * Create a new PerturbNormalBlock
  66910. * @param name defines the block name
  66911. */
  66912. constructor(name: string);
  66913. /**
  66914. * Gets the current class name
  66915. * @returns the class name
  66916. */
  66917. getClassName(): string;
  66918. /**
  66919. * Gets the world position input component
  66920. */
  66921. get worldPosition(): NodeMaterialConnectionPoint;
  66922. /**
  66923. * Gets the world normal input component
  66924. */
  66925. get worldNormal(): NodeMaterialConnectionPoint;
  66926. /**
  66927. * Gets the world tangent input component
  66928. */
  66929. get worldTangent(): NodeMaterialConnectionPoint;
  66930. /**
  66931. * Gets the uv input component
  66932. */
  66933. get uv(): NodeMaterialConnectionPoint;
  66934. /**
  66935. * Gets the normal map color input component
  66936. */
  66937. get normalMapColor(): NodeMaterialConnectionPoint;
  66938. /**
  66939. * Gets the strength input component
  66940. */
  66941. get strength(): NodeMaterialConnectionPoint;
  66942. /**
  66943. * Gets the output component
  66944. */
  66945. get output(): NodeMaterialConnectionPoint;
  66946. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66947. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66948. autoConfigure(material: NodeMaterial): void;
  66949. protected _buildBlock(state: NodeMaterialBuildState): this;
  66950. protected _dumpPropertiesCode(): string;
  66951. serialize(): any;
  66952. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66953. }
  66954. }
  66955. declare module BABYLON {
  66956. /**
  66957. * Block used to discard a pixel if a value is smaller than a cutoff
  66958. */
  66959. export class DiscardBlock extends NodeMaterialBlock {
  66960. /**
  66961. * Create a new DiscardBlock
  66962. * @param name defines the block name
  66963. */
  66964. constructor(name: string);
  66965. /**
  66966. * Gets the current class name
  66967. * @returns the class name
  66968. */
  66969. getClassName(): string;
  66970. /**
  66971. * Gets the color input component
  66972. */
  66973. get value(): NodeMaterialConnectionPoint;
  66974. /**
  66975. * Gets the cutoff input component
  66976. */
  66977. get cutoff(): NodeMaterialConnectionPoint;
  66978. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66979. }
  66980. }
  66981. declare module BABYLON {
  66982. /**
  66983. * Block used to test if the fragment shader is front facing
  66984. */
  66985. export class FrontFacingBlock extends NodeMaterialBlock {
  66986. /**
  66987. * Creates a new FrontFacingBlock
  66988. * @param name defines the block name
  66989. */
  66990. constructor(name: string);
  66991. /**
  66992. * Gets the current class name
  66993. * @returns the class name
  66994. */
  66995. getClassName(): string;
  66996. /**
  66997. * Gets the output component
  66998. */
  66999. get output(): NodeMaterialConnectionPoint;
  67000. protected _buildBlock(state: NodeMaterialBuildState): this;
  67001. }
  67002. }
  67003. declare module BABYLON {
  67004. /**
  67005. * Block used to get the derivative value on x and y of a given input
  67006. */
  67007. export class DerivativeBlock extends NodeMaterialBlock {
  67008. /**
  67009. * Create a new DerivativeBlock
  67010. * @param name defines the block name
  67011. */
  67012. constructor(name: string);
  67013. /**
  67014. * Gets the current class name
  67015. * @returns the class name
  67016. */
  67017. getClassName(): string;
  67018. /**
  67019. * Gets the input component
  67020. */
  67021. get input(): NodeMaterialConnectionPoint;
  67022. /**
  67023. * Gets the derivative output on x
  67024. */
  67025. get dx(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the derivative output on y
  67028. */
  67029. get dy(): NodeMaterialConnectionPoint;
  67030. protected _buildBlock(state: NodeMaterialBuildState): this;
  67031. }
  67032. }
  67033. declare module BABYLON {
  67034. /**
  67035. * Block used to make gl_FragCoord available
  67036. */
  67037. export class FragCoordBlock extends NodeMaterialBlock {
  67038. /**
  67039. * Creates a new FragCoordBlock
  67040. * @param name defines the block name
  67041. */
  67042. constructor(name: string);
  67043. /**
  67044. * Gets the current class name
  67045. * @returns the class name
  67046. */
  67047. getClassName(): string;
  67048. /**
  67049. * Gets the xy component
  67050. */
  67051. get xy(): NodeMaterialConnectionPoint;
  67052. /**
  67053. * Gets the xyz component
  67054. */
  67055. get xyz(): NodeMaterialConnectionPoint;
  67056. /**
  67057. * Gets the xyzw component
  67058. */
  67059. get xyzw(): NodeMaterialConnectionPoint;
  67060. /**
  67061. * Gets the x component
  67062. */
  67063. get x(): NodeMaterialConnectionPoint;
  67064. /**
  67065. * Gets the y component
  67066. */
  67067. get y(): NodeMaterialConnectionPoint;
  67068. /**
  67069. * Gets the z component
  67070. */
  67071. get z(): NodeMaterialConnectionPoint;
  67072. /**
  67073. * Gets the w component
  67074. */
  67075. get output(): NodeMaterialConnectionPoint;
  67076. protected writeOutputs(state: NodeMaterialBuildState): string;
  67077. protected _buildBlock(state: NodeMaterialBuildState): this;
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /**
  67082. * Block used to get the screen sizes
  67083. */
  67084. export class ScreenSizeBlock extends NodeMaterialBlock {
  67085. private _varName;
  67086. private _scene;
  67087. /**
  67088. * Creates a new ScreenSizeBlock
  67089. * @param name defines the block name
  67090. */
  67091. constructor(name: string);
  67092. /**
  67093. * Gets the current class name
  67094. * @returns the class name
  67095. */
  67096. getClassName(): string;
  67097. /**
  67098. * Gets the xy component
  67099. */
  67100. get xy(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the x component
  67103. */
  67104. get x(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the y component
  67107. */
  67108. get y(): NodeMaterialConnectionPoint;
  67109. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67110. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  67111. protected _buildBlock(state: NodeMaterialBuildState): this;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. /**
  67116. * Block used to add support for scene fog
  67117. */
  67118. export class FogBlock extends NodeMaterialBlock {
  67119. private _fogDistanceName;
  67120. private _fogParameters;
  67121. /**
  67122. * Create a new FogBlock
  67123. * @param name defines the block name
  67124. */
  67125. constructor(name: string);
  67126. /**
  67127. * Gets the current class name
  67128. * @returns the class name
  67129. */
  67130. getClassName(): string;
  67131. /**
  67132. * Gets the world position input component
  67133. */
  67134. get worldPosition(): NodeMaterialConnectionPoint;
  67135. /**
  67136. * Gets the view input component
  67137. */
  67138. get view(): NodeMaterialConnectionPoint;
  67139. /**
  67140. * Gets the color input component
  67141. */
  67142. get input(): NodeMaterialConnectionPoint;
  67143. /**
  67144. * Gets the fog color input component
  67145. */
  67146. get fogColor(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the output component
  67149. */
  67150. get output(): NodeMaterialConnectionPoint;
  67151. autoConfigure(material: NodeMaterial): void;
  67152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67153. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67154. protected _buildBlock(state: NodeMaterialBuildState): this;
  67155. }
  67156. }
  67157. declare module BABYLON {
  67158. /**
  67159. * Block used to add light in the fragment shader
  67160. */
  67161. export class LightBlock extends NodeMaterialBlock {
  67162. private _lightId;
  67163. /**
  67164. * Gets or sets the light associated with this block
  67165. */
  67166. light: Nullable<Light>;
  67167. /**
  67168. * Create a new LightBlock
  67169. * @param name defines the block name
  67170. */
  67171. constructor(name: string);
  67172. /**
  67173. * Gets the current class name
  67174. * @returns the class name
  67175. */
  67176. getClassName(): string;
  67177. /**
  67178. * Gets the world position input component
  67179. */
  67180. get worldPosition(): NodeMaterialConnectionPoint;
  67181. /**
  67182. * Gets the world normal input component
  67183. */
  67184. get worldNormal(): NodeMaterialConnectionPoint;
  67185. /**
  67186. * Gets the camera (or eye) position component
  67187. */
  67188. get cameraPosition(): NodeMaterialConnectionPoint;
  67189. /**
  67190. * Gets the glossiness component
  67191. */
  67192. get glossiness(): NodeMaterialConnectionPoint;
  67193. /**
  67194. * Gets the glossinness power component
  67195. */
  67196. get glossPower(): NodeMaterialConnectionPoint;
  67197. /**
  67198. * Gets the diffuse color component
  67199. */
  67200. get diffuseColor(): NodeMaterialConnectionPoint;
  67201. /**
  67202. * Gets the specular color component
  67203. */
  67204. get specularColor(): NodeMaterialConnectionPoint;
  67205. /**
  67206. * Gets the view matrix component
  67207. */
  67208. get view(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the diffuse output component
  67211. */
  67212. get diffuseOutput(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the specular output component
  67215. */
  67216. get specularOutput(): NodeMaterialConnectionPoint;
  67217. /**
  67218. * Gets the shadow output component
  67219. */
  67220. get shadow(): NodeMaterialConnectionPoint;
  67221. autoConfigure(material: NodeMaterial): void;
  67222. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67223. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67224. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67225. private _injectVertexCode;
  67226. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67227. serialize(): any;
  67228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67229. }
  67230. }
  67231. declare module BABYLON {
  67232. /**
  67233. * Block used to read a reflection texture from a sampler
  67234. */
  67235. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67236. /**
  67237. * Create a new ReflectionTextureBlock
  67238. * @param name defines the block name
  67239. */
  67240. constructor(name: string);
  67241. /**
  67242. * Gets the current class name
  67243. * @returns the class name
  67244. */
  67245. getClassName(): string;
  67246. /**
  67247. * Gets the world position input component
  67248. */
  67249. get position(): NodeMaterialConnectionPoint;
  67250. /**
  67251. * Gets the world position input component
  67252. */
  67253. get worldPosition(): NodeMaterialConnectionPoint;
  67254. /**
  67255. * Gets the world normal input component
  67256. */
  67257. get worldNormal(): NodeMaterialConnectionPoint;
  67258. /**
  67259. * Gets the world input component
  67260. */
  67261. get world(): NodeMaterialConnectionPoint;
  67262. /**
  67263. * Gets the camera (or eye) position component
  67264. */
  67265. get cameraPosition(): NodeMaterialConnectionPoint;
  67266. /**
  67267. * Gets the view input component
  67268. */
  67269. get view(): NodeMaterialConnectionPoint;
  67270. /**
  67271. * Gets the rgb output component
  67272. */
  67273. get rgb(): NodeMaterialConnectionPoint;
  67274. /**
  67275. * Gets the rgba output component
  67276. */
  67277. get rgba(): NodeMaterialConnectionPoint;
  67278. /**
  67279. * Gets the r output component
  67280. */
  67281. get r(): NodeMaterialConnectionPoint;
  67282. /**
  67283. * Gets the g output component
  67284. */
  67285. get g(): NodeMaterialConnectionPoint;
  67286. /**
  67287. * Gets the b output component
  67288. */
  67289. get b(): NodeMaterialConnectionPoint;
  67290. /**
  67291. * Gets the a output component
  67292. */
  67293. get a(): NodeMaterialConnectionPoint;
  67294. autoConfigure(material: NodeMaterial): void;
  67295. protected _buildBlock(state: NodeMaterialBuildState): this;
  67296. }
  67297. }
  67298. declare module BABYLON {
  67299. /**
  67300. * Block used to add 2 vectors
  67301. */
  67302. export class AddBlock extends NodeMaterialBlock {
  67303. /**
  67304. * Creates a new AddBlock
  67305. * @param name defines the block name
  67306. */
  67307. constructor(name: string);
  67308. /**
  67309. * Gets the current class name
  67310. * @returns the class name
  67311. */
  67312. getClassName(): string;
  67313. /**
  67314. * Gets the left operand input component
  67315. */
  67316. get left(): NodeMaterialConnectionPoint;
  67317. /**
  67318. * Gets the right operand input component
  67319. */
  67320. get right(): NodeMaterialConnectionPoint;
  67321. /**
  67322. * Gets the output component
  67323. */
  67324. get output(): NodeMaterialConnectionPoint;
  67325. protected _buildBlock(state: NodeMaterialBuildState): this;
  67326. }
  67327. }
  67328. declare module BABYLON {
  67329. /**
  67330. * Block used to scale a vector by a float
  67331. */
  67332. export class ScaleBlock extends NodeMaterialBlock {
  67333. /**
  67334. * Creates a new ScaleBlock
  67335. * @param name defines the block name
  67336. */
  67337. constructor(name: string);
  67338. /**
  67339. * Gets the current class name
  67340. * @returns the class name
  67341. */
  67342. getClassName(): string;
  67343. /**
  67344. * Gets the input component
  67345. */
  67346. get input(): NodeMaterialConnectionPoint;
  67347. /**
  67348. * Gets the factor input component
  67349. */
  67350. get factor(): NodeMaterialConnectionPoint;
  67351. /**
  67352. * Gets the output component
  67353. */
  67354. get output(): NodeMaterialConnectionPoint;
  67355. protected _buildBlock(state: NodeMaterialBuildState): this;
  67356. }
  67357. }
  67358. declare module BABYLON {
  67359. /**
  67360. * Block used to clamp a float
  67361. */
  67362. export class ClampBlock extends NodeMaterialBlock {
  67363. /** Gets or sets the minimum range */
  67364. minimum: number;
  67365. /** Gets or sets the maximum range */
  67366. maximum: number;
  67367. /**
  67368. * Creates a new ClampBlock
  67369. * @param name defines the block name
  67370. */
  67371. constructor(name: string);
  67372. /**
  67373. * Gets the current class name
  67374. * @returns the class name
  67375. */
  67376. getClassName(): string;
  67377. /**
  67378. * Gets the value input component
  67379. */
  67380. get value(): NodeMaterialConnectionPoint;
  67381. /**
  67382. * Gets the output component
  67383. */
  67384. get output(): NodeMaterialConnectionPoint;
  67385. protected _buildBlock(state: NodeMaterialBuildState): this;
  67386. protected _dumpPropertiesCode(): string;
  67387. serialize(): any;
  67388. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67389. }
  67390. }
  67391. declare module BABYLON {
  67392. /**
  67393. * Block used to apply a cross product between 2 vectors
  67394. */
  67395. export class CrossBlock extends NodeMaterialBlock {
  67396. /**
  67397. * Creates a new CrossBlock
  67398. * @param name defines the block name
  67399. */
  67400. constructor(name: string);
  67401. /**
  67402. * Gets the current class name
  67403. * @returns the class name
  67404. */
  67405. getClassName(): string;
  67406. /**
  67407. * Gets the left operand input component
  67408. */
  67409. get left(): NodeMaterialConnectionPoint;
  67410. /**
  67411. * Gets the right operand input component
  67412. */
  67413. get right(): NodeMaterialConnectionPoint;
  67414. /**
  67415. * Gets the output component
  67416. */
  67417. get output(): NodeMaterialConnectionPoint;
  67418. protected _buildBlock(state: NodeMaterialBuildState): this;
  67419. }
  67420. }
  67421. declare module BABYLON {
  67422. /**
  67423. * Block used to apply a dot product between 2 vectors
  67424. */
  67425. export class DotBlock extends NodeMaterialBlock {
  67426. /**
  67427. * Creates a new DotBlock
  67428. * @param name defines the block name
  67429. */
  67430. constructor(name: string);
  67431. /**
  67432. * Gets the current class name
  67433. * @returns the class name
  67434. */
  67435. getClassName(): string;
  67436. /**
  67437. * Gets the left operand input component
  67438. */
  67439. get left(): NodeMaterialConnectionPoint;
  67440. /**
  67441. * Gets the right operand input component
  67442. */
  67443. get right(): NodeMaterialConnectionPoint;
  67444. /**
  67445. * Gets the output component
  67446. */
  67447. get output(): NodeMaterialConnectionPoint;
  67448. protected _buildBlock(state: NodeMaterialBuildState): this;
  67449. }
  67450. }
  67451. declare module BABYLON {
  67452. /**
  67453. * Block used to normalize a vector
  67454. */
  67455. export class NormalizeBlock extends NodeMaterialBlock {
  67456. /**
  67457. * Creates a new NormalizeBlock
  67458. * @param name defines the block name
  67459. */
  67460. constructor(name: string);
  67461. /**
  67462. * Gets the current class name
  67463. * @returns the class name
  67464. */
  67465. getClassName(): string;
  67466. /**
  67467. * Gets the input component
  67468. */
  67469. get input(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the output component
  67472. */
  67473. get output(): NodeMaterialConnectionPoint;
  67474. protected _buildBlock(state: NodeMaterialBuildState): this;
  67475. }
  67476. }
  67477. declare module BABYLON {
  67478. /**
  67479. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67480. */
  67481. export class ColorMergerBlock extends NodeMaterialBlock {
  67482. /**
  67483. * Create a new ColorMergerBlock
  67484. * @param name defines the block name
  67485. */
  67486. constructor(name: string);
  67487. /**
  67488. * Gets the current class name
  67489. * @returns the class name
  67490. */
  67491. getClassName(): string;
  67492. /**
  67493. * Gets the rgb component (input)
  67494. */
  67495. get rgbIn(): NodeMaterialConnectionPoint;
  67496. /**
  67497. * Gets the r component (input)
  67498. */
  67499. get r(): NodeMaterialConnectionPoint;
  67500. /**
  67501. * Gets the g component (input)
  67502. */
  67503. get g(): NodeMaterialConnectionPoint;
  67504. /**
  67505. * Gets the b component (input)
  67506. */
  67507. get b(): NodeMaterialConnectionPoint;
  67508. /**
  67509. * Gets the a component (input)
  67510. */
  67511. get a(): NodeMaterialConnectionPoint;
  67512. /**
  67513. * Gets the rgba component (output)
  67514. */
  67515. get rgba(): NodeMaterialConnectionPoint;
  67516. /**
  67517. * Gets the rgb component (output)
  67518. */
  67519. get rgbOut(): NodeMaterialConnectionPoint;
  67520. /**
  67521. * Gets the rgb component (output)
  67522. * @deprecated Please use rgbOut instead.
  67523. */
  67524. get rgb(): NodeMaterialConnectionPoint;
  67525. protected _buildBlock(state: NodeMaterialBuildState): this;
  67526. }
  67527. }
  67528. declare module BABYLON {
  67529. /**
  67530. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67531. */
  67532. export class VectorSplitterBlock extends NodeMaterialBlock {
  67533. /**
  67534. * Create a new VectorSplitterBlock
  67535. * @param name defines the block name
  67536. */
  67537. constructor(name: string);
  67538. /**
  67539. * Gets the current class name
  67540. * @returns the class name
  67541. */
  67542. getClassName(): string;
  67543. /**
  67544. * Gets the xyzw component (input)
  67545. */
  67546. get xyzw(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the xyz component (input)
  67549. */
  67550. get xyzIn(): NodeMaterialConnectionPoint;
  67551. /**
  67552. * Gets the xy component (input)
  67553. */
  67554. get xyIn(): NodeMaterialConnectionPoint;
  67555. /**
  67556. * Gets the xyz component (output)
  67557. */
  67558. get xyzOut(): NodeMaterialConnectionPoint;
  67559. /**
  67560. * Gets the xy component (output)
  67561. */
  67562. get xyOut(): NodeMaterialConnectionPoint;
  67563. /**
  67564. * Gets the x component (output)
  67565. */
  67566. get x(): NodeMaterialConnectionPoint;
  67567. /**
  67568. * Gets the y component (output)
  67569. */
  67570. get y(): NodeMaterialConnectionPoint;
  67571. /**
  67572. * Gets the z component (output)
  67573. */
  67574. get z(): NodeMaterialConnectionPoint;
  67575. /**
  67576. * Gets the w component (output)
  67577. */
  67578. get w(): NodeMaterialConnectionPoint;
  67579. protected _inputRename(name: string): string;
  67580. protected _outputRename(name: string): string;
  67581. protected _buildBlock(state: NodeMaterialBuildState): this;
  67582. }
  67583. }
  67584. declare module BABYLON {
  67585. /**
  67586. * Block used to lerp between 2 values
  67587. */
  67588. export class LerpBlock extends NodeMaterialBlock {
  67589. /**
  67590. * Creates a new LerpBlock
  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 left operand input component
  67601. */
  67602. get left(): NodeMaterialConnectionPoint;
  67603. /**
  67604. * Gets the right operand input component
  67605. */
  67606. get right(): NodeMaterialConnectionPoint;
  67607. /**
  67608. * Gets the gradient operand input component
  67609. */
  67610. get gradient(): NodeMaterialConnectionPoint;
  67611. /**
  67612. * Gets the output component
  67613. */
  67614. get output(): NodeMaterialConnectionPoint;
  67615. protected _buildBlock(state: NodeMaterialBuildState): this;
  67616. }
  67617. }
  67618. declare module BABYLON {
  67619. /**
  67620. * Block used to divide 2 vectors
  67621. */
  67622. export class DivideBlock extends NodeMaterialBlock {
  67623. /**
  67624. * Creates a new DivideBlock
  67625. * @param name defines the block name
  67626. */
  67627. constructor(name: string);
  67628. /**
  67629. * Gets the current class name
  67630. * @returns the class name
  67631. */
  67632. getClassName(): string;
  67633. /**
  67634. * Gets the left operand input component
  67635. */
  67636. get left(): NodeMaterialConnectionPoint;
  67637. /**
  67638. * Gets the right operand input component
  67639. */
  67640. get right(): NodeMaterialConnectionPoint;
  67641. /**
  67642. * Gets the output component
  67643. */
  67644. get output(): NodeMaterialConnectionPoint;
  67645. protected _buildBlock(state: NodeMaterialBuildState): this;
  67646. }
  67647. }
  67648. declare module BABYLON {
  67649. /**
  67650. * Block used to subtract 2 vectors
  67651. */
  67652. export class SubtractBlock extends NodeMaterialBlock {
  67653. /**
  67654. * Creates a new SubtractBlock
  67655. * @param name defines the block name
  67656. */
  67657. constructor(name: string);
  67658. /**
  67659. * Gets the current class name
  67660. * @returns the class name
  67661. */
  67662. getClassName(): string;
  67663. /**
  67664. * Gets the left operand input component
  67665. */
  67666. get left(): NodeMaterialConnectionPoint;
  67667. /**
  67668. * Gets the right operand input component
  67669. */
  67670. get right(): NodeMaterialConnectionPoint;
  67671. /**
  67672. * Gets the output component
  67673. */
  67674. get output(): NodeMaterialConnectionPoint;
  67675. protected _buildBlock(state: NodeMaterialBuildState): this;
  67676. }
  67677. }
  67678. declare module BABYLON {
  67679. /**
  67680. * Block used to step a value
  67681. */
  67682. export class StepBlock extends NodeMaterialBlock {
  67683. /**
  67684. * Creates a new StepBlock
  67685. * @param name defines the block name
  67686. */
  67687. constructor(name: string);
  67688. /**
  67689. * Gets the current class name
  67690. * @returns the class name
  67691. */
  67692. getClassName(): string;
  67693. /**
  67694. * Gets the value operand input component
  67695. */
  67696. get value(): NodeMaterialConnectionPoint;
  67697. /**
  67698. * Gets the edge operand input component
  67699. */
  67700. get edge(): NodeMaterialConnectionPoint;
  67701. /**
  67702. * Gets the output component
  67703. */
  67704. get output(): NodeMaterialConnectionPoint;
  67705. protected _buildBlock(state: NodeMaterialBuildState): this;
  67706. }
  67707. }
  67708. declare module BABYLON {
  67709. /**
  67710. * Block used to get the opposite (1 - x) of a value
  67711. */
  67712. export class OneMinusBlock extends NodeMaterialBlock {
  67713. /**
  67714. * Creates a new OneMinusBlock
  67715. * @param name defines the block name
  67716. */
  67717. constructor(name: string);
  67718. /**
  67719. * Gets the current class name
  67720. * @returns the class name
  67721. */
  67722. getClassName(): string;
  67723. /**
  67724. * Gets the input component
  67725. */
  67726. get input(): NodeMaterialConnectionPoint;
  67727. /**
  67728. * Gets the output component
  67729. */
  67730. get output(): NodeMaterialConnectionPoint;
  67731. protected _buildBlock(state: NodeMaterialBuildState): this;
  67732. }
  67733. }
  67734. declare module BABYLON {
  67735. /**
  67736. * Block used to get the view direction
  67737. */
  67738. export class ViewDirectionBlock extends NodeMaterialBlock {
  67739. /**
  67740. * Creates a new ViewDirectionBlock
  67741. * @param name defines the block name
  67742. */
  67743. constructor(name: string);
  67744. /**
  67745. * Gets the current class name
  67746. * @returns the class name
  67747. */
  67748. getClassName(): string;
  67749. /**
  67750. * Gets the world position component
  67751. */
  67752. get worldPosition(): NodeMaterialConnectionPoint;
  67753. /**
  67754. * Gets the camera position component
  67755. */
  67756. get cameraPosition(): NodeMaterialConnectionPoint;
  67757. /**
  67758. * Gets the output component
  67759. */
  67760. get output(): NodeMaterialConnectionPoint;
  67761. autoConfigure(material: NodeMaterial): void;
  67762. protected _buildBlock(state: NodeMaterialBuildState): this;
  67763. }
  67764. }
  67765. declare module BABYLON {
  67766. /**
  67767. * Block used to compute fresnel value
  67768. */
  67769. export class FresnelBlock extends NodeMaterialBlock {
  67770. /**
  67771. * Create a new FresnelBlock
  67772. * @param name defines the block name
  67773. */
  67774. constructor(name: string);
  67775. /**
  67776. * Gets the current class name
  67777. * @returns the class name
  67778. */
  67779. getClassName(): string;
  67780. /**
  67781. * Gets the world normal input component
  67782. */
  67783. get worldNormal(): NodeMaterialConnectionPoint;
  67784. /**
  67785. * Gets the view direction input component
  67786. */
  67787. get viewDirection(): NodeMaterialConnectionPoint;
  67788. /**
  67789. * Gets the bias input component
  67790. */
  67791. get bias(): NodeMaterialConnectionPoint;
  67792. /**
  67793. * Gets the camera (or eye) position component
  67794. */
  67795. get power(): NodeMaterialConnectionPoint;
  67796. /**
  67797. * Gets the fresnel output component
  67798. */
  67799. get fresnel(): NodeMaterialConnectionPoint;
  67800. autoConfigure(material: NodeMaterial): void;
  67801. protected _buildBlock(state: NodeMaterialBuildState): this;
  67802. }
  67803. }
  67804. declare module BABYLON {
  67805. /**
  67806. * Block used to get the max of 2 values
  67807. */
  67808. export class MaxBlock extends NodeMaterialBlock {
  67809. /**
  67810. * Creates a new MaxBlock
  67811. * @param name defines the block name
  67812. */
  67813. constructor(name: string);
  67814. /**
  67815. * Gets the current class name
  67816. * @returns the class name
  67817. */
  67818. getClassName(): string;
  67819. /**
  67820. * Gets the left operand input component
  67821. */
  67822. get left(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the right operand input component
  67825. */
  67826. get right(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the output component
  67829. */
  67830. get output(): NodeMaterialConnectionPoint;
  67831. protected _buildBlock(state: NodeMaterialBuildState): this;
  67832. }
  67833. }
  67834. declare module BABYLON {
  67835. /**
  67836. * Block used to get the min of 2 values
  67837. */
  67838. export class MinBlock extends NodeMaterialBlock {
  67839. /**
  67840. * Creates a new MinBlock
  67841. * @param name defines the block name
  67842. */
  67843. constructor(name: string);
  67844. /**
  67845. * Gets the current class name
  67846. * @returns the class name
  67847. */
  67848. getClassName(): string;
  67849. /**
  67850. * Gets the left operand input component
  67851. */
  67852. get left(): NodeMaterialConnectionPoint;
  67853. /**
  67854. * Gets the right operand input component
  67855. */
  67856. get right(): NodeMaterialConnectionPoint;
  67857. /**
  67858. * Gets the output component
  67859. */
  67860. get output(): NodeMaterialConnectionPoint;
  67861. protected _buildBlock(state: NodeMaterialBuildState): this;
  67862. }
  67863. }
  67864. declare module BABYLON {
  67865. /**
  67866. * Block used to get the distance between 2 values
  67867. */
  67868. export class DistanceBlock extends NodeMaterialBlock {
  67869. /**
  67870. * Creates a new DistanceBlock
  67871. * @param name defines the block name
  67872. */
  67873. constructor(name: string);
  67874. /**
  67875. * Gets the current class name
  67876. * @returns the class name
  67877. */
  67878. getClassName(): string;
  67879. /**
  67880. * Gets the left operand input component
  67881. */
  67882. get left(): NodeMaterialConnectionPoint;
  67883. /**
  67884. * Gets the right operand input component
  67885. */
  67886. get right(): NodeMaterialConnectionPoint;
  67887. /**
  67888. * Gets the output component
  67889. */
  67890. get output(): NodeMaterialConnectionPoint;
  67891. protected _buildBlock(state: NodeMaterialBuildState): this;
  67892. }
  67893. }
  67894. declare module BABYLON {
  67895. /**
  67896. * Block used to get the length of a vector
  67897. */
  67898. export class LengthBlock extends NodeMaterialBlock {
  67899. /**
  67900. * Creates a new LengthBlock
  67901. * @param name defines the block name
  67902. */
  67903. constructor(name: string);
  67904. /**
  67905. * Gets the current class name
  67906. * @returns the class name
  67907. */
  67908. getClassName(): string;
  67909. /**
  67910. * Gets the value input component
  67911. */
  67912. get value(): NodeMaterialConnectionPoint;
  67913. /**
  67914. * Gets the output component
  67915. */
  67916. get output(): NodeMaterialConnectionPoint;
  67917. protected _buildBlock(state: NodeMaterialBuildState): this;
  67918. }
  67919. }
  67920. declare module BABYLON {
  67921. /**
  67922. * Block used to get negative version of a value (i.e. x * -1)
  67923. */
  67924. export class NegateBlock extends NodeMaterialBlock {
  67925. /**
  67926. * Creates a new NegateBlock
  67927. * @param name defines the block name
  67928. */
  67929. constructor(name: string);
  67930. /**
  67931. * Gets the current class name
  67932. * @returns the class name
  67933. */
  67934. getClassName(): string;
  67935. /**
  67936. * Gets the value input component
  67937. */
  67938. get value(): NodeMaterialConnectionPoint;
  67939. /**
  67940. * Gets the output component
  67941. */
  67942. get output(): NodeMaterialConnectionPoint;
  67943. protected _buildBlock(state: NodeMaterialBuildState): this;
  67944. }
  67945. }
  67946. declare module BABYLON {
  67947. /**
  67948. * Block used to get the value of the first parameter raised to the power of the second
  67949. */
  67950. export class PowBlock extends NodeMaterialBlock {
  67951. /**
  67952. * Creates a new PowBlock
  67953. * @param name defines the block name
  67954. */
  67955. constructor(name: string);
  67956. /**
  67957. * Gets the current class name
  67958. * @returns the class name
  67959. */
  67960. getClassName(): string;
  67961. /**
  67962. * Gets the value operand input component
  67963. */
  67964. get value(): NodeMaterialConnectionPoint;
  67965. /**
  67966. * Gets the power operand input component
  67967. */
  67968. get power(): NodeMaterialConnectionPoint;
  67969. /**
  67970. * Gets the output component
  67971. */
  67972. get output(): NodeMaterialConnectionPoint;
  67973. protected _buildBlock(state: NodeMaterialBuildState): this;
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /**
  67978. * Block used to get a random number
  67979. */
  67980. export class RandomNumberBlock extends NodeMaterialBlock {
  67981. /**
  67982. * Creates a new RandomNumberBlock
  67983. * @param name defines the block name
  67984. */
  67985. constructor(name: string);
  67986. /**
  67987. * Gets the current class name
  67988. * @returns the class name
  67989. */
  67990. getClassName(): string;
  67991. /**
  67992. * Gets the seed input component
  67993. */
  67994. get seed(): NodeMaterialConnectionPoint;
  67995. /**
  67996. * Gets the output component
  67997. */
  67998. get output(): NodeMaterialConnectionPoint;
  67999. protected _buildBlock(state: NodeMaterialBuildState): this;
  68000. }
  68001. }
  68002. declare module BABYLON {
  68003. /**
  68004. * Block used to compute arc tangent of 2 values
  68005. */
  68006. export class ArcTan2Block extends NodeMaterialBlock {
  68007. /**
  68008. * Creates a new ArcTan2Block
  68009. * @param name defines the block name
  68010. */
  68011. constructor(name: string);
  68012. /**
  68013. * Gets the current class name
  68014. * @returns the class name
  68015. */
  68016. getClassName(): string;
  68017. /**
  68018. * Gets the x operand input component
  68019. */
  68020. get x(): NodeMaterialConnectionPoint;
  68021. /**
  68022. * Gets the y operand input component
  68023. */
  68024. get y(): NodeMaterialConnectionPoint;
  68025. /**
  68026. * Gets the output component
  68027. */
  68028. get output(): NodeMaterialConnectionPoint;
  68029. protected _buildBlock(state: NodeMaterialBuildState): this;
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /**
  68034. * Block used to smooth step a value
  68035. */
  68036. export class SmoothStepBlock extends NodeMaterialBlock {
  68037. /**
  68038. * Creates a new SmoothStepBlock
  68039. * @param name defines the block name
  68040. */
  68041. constructor(name: string);
  68042. /**
  68043. * Gets the current class name
  68044. * @returns the class name
  68045. */
  68046. getClassName(): string;
  68047. /**
  68048. * Gets the value operand input component
  68049. */
  68050. get value(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the first edge operand input component
  68053. */
  68054. get edge0(): NodeMaterialConnectionPoint;
  68055. /**
  68056. * Gets the second edge operand input component
  68057. */
  68058. get edge1(): NodeMaterialConnectionPoint;
  68059. /**
  68060. * Gets the output component
  68061. */
  68062. get output(): NodeMaterialConnectionPoint;
  68063. protected _buildBlock(state: NodeMaterialBuildState): this;
  68064. }
  68065. }
  68066. declare module BABYLON {
  68067. /**
  68068. * Block used to get the reciprocal (1 / x) of a value
  68069. */
  68070. export class ReciprocalBlock extends NodeMaterialBlock {
  68071. /**
  68072. * Creates a new ReciprocalBlock
  68073. * @param name defines the block name
  68074. */
  68075. constructor(name: string);
  68076. /**
  68077. * Gets the current class name
  68078. * @returns the class name
  68079. */
  68080. getClassName(): string;
  68081. /**
  68082. * Gets the input component
  68083. */
  68084. get input(): NodeMaterialConnectionPoint;
  68085. /**
  68086. * Gets the output component
  68087. */
  68088. get output(): NodeMaterialConnectionPoint;
  68089. protected _buildBlock(state: NodeMaterialBuildState): this;
  68090. }
  68091. }
  68092. declare module BABYLON {
  68093. /**
  68094. * Block used to replace a color by another one
  68095. */
  68096. export class ReplaceColorBlock extends NodeMaterialBlock {
  68097. /**
  68098. * Creates a new ReplaceColorBlock
  68099. * @param name defines the block name
  68100. */
  68101. constructor(name: string);
  68102. /**
  68103. * Gets the current class name
  68104. * @returns the class name
  68105. */
  68106. getClassName(): string;
  68107. /**
  68108. * Gets the value input component
  68109. */
  68110. get value(): NodeMaterialConnectionPoint;
  68111. /**
  68112. * Gets the reference input component
  68113. */
  68114. get reference(): NodeMaterialConnectionPoint;
  68115. /**
  68116. * Gets the distance input component
  68117. */
  68118. get distance(): NodeMaterialConnectionPoint;
  68119. /**
  68120. * Gets the replacement input component
  68121. */
  68122. get replacement(): NodeMaterialConnectionPoint;
  68123. /**
  68124. * Gets the output component
  68125. */
  68126. get output(): NodeMaterialConnectionPoint;
  68127. protected _buildBlock(state: NodeMaterialBuildState): this;
  68128. }
  68129. }
  68130. declare module BABYLON {
  68131. /**
  68132. * Block used to posterize a value
  68133. * @see https://en.wikipedia.org/wiki/Posterization
  68134. */
  68135. export class PosterizeBlock extends NodeMaterialBlock {
  68136. /**
  68137. * Creates a new PosterizeBlock
  68138. * @param name defines the block name
  68139. */
  68140. constructor(name: string);
  68141. /**
  68142. * Gets the current class name
  68143. * @returns the class name
  68144. */
  68145. getClassName(): string;
  68146. /**
  68147. * Gets the value input component
  68148. */
  68149. get value(): NodeMaterialConnectionPoint;
  68150. /**
  68151. * Gets the steps input component
  68152. */
  68153. get steps(): NodeMaterialConnectionPoint;
  68154. /**
  68155. * Gets the output component
  68156. */
  68157. get output(): NodeMaterialConnectionPoint;
  68158. protected _buildBlock(state: NodeMaterialBuildState): this;
  68159. }
  68160. }
  68161. declare module BABYLON {
  68162. /**
  68163. * Operations supported by the Wave block
  68164. */
  68165. export enum WaveBlockKind {
  68166. /** SawTooth */
  68167. SawTooth = 0,
  68168. /** Square */
  68169. Square = 1,
  68170. /** Triangle */
  68171. Triangle = 2
  68172. }
  68173. /**
  68174. * Block used to apply wave operation to floats
  68175. */
  68176. export class WaveBlock extends NodeMaterialBlock {
  68177. /**
  68178. * Gets or sets the kibnd of wave to be applied by the block
  68179. */
  68180. kind: WaveBlockKind;
  68181. /**
  68182. * Creates a new WaveBlock
  68183. * @param name defines the block name
  68184. */
  68185. constructor(name: string);
  68186. /**
  68187. * Gets the current class name
  68188. * @returns the class name
  68189. */
  68190. getClassName(): string;
  68191. /**
  68192. * Gets the input component
  68193. */
  68194. get input(): NodeMaterialConnectionPoint;
  68195. /**
  68196. * Gets the output component
  68197. */
  68198. get output(): NodeMaterialConnectionPoint;
  68199. protected _buildBlock(state: NodeMaterialBuildState): this;
  68200. serialize(): any;
  68201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68202. }
  68203. }
  68204. declare module BABYLON {
  68205. /**
  68206. * Class used to store a color step for the GradientBlock
  68207. */
  68208. export class GradientBlockColorStep {
  68209. private _step;
  68210. /**
  68211. * Gets value indicating which step this color is associated with (between 0 and 1)
  68212. */
  68213. get step(): number;
  68214. /**
  68215. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68216. */
  68217. set step(val: number);
  68218. private _color;
  68219. /**
  68220. * Gets the color associated with this step
  68221. */
  68222. get color(): Color3;
  68223. /**
  68224. * Sets the color associated with this step
  68225. */
  68226. set color(val: Color3);
  68227. /**
  68228. * Creates a new GradientBlockColorStep
  68229. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68230. * @param color defines the color associated with this step
  68231. */
  68232. constructor(step: number, color: Color3);
  68233. }
  68234. /**
  68235. * Block used to return a color from a gradient based on an input value between 0 and 1
  68236. */
  68237. export class GradientBlock extends NodeMaterialBlock {
  68238. /**
  68239. * Gets or sets the list of color steps
  68240. */
  68241. colorSteps: GradientBlockColorStep[];
  68242. /** Gets an observable raised when the value is changed */
  68243. onValueChangedObservable: Observable<GradientBlock>;
  68244. /** calls observable when the value is changed*/
  68245. colorStepsUpdated(): void;
  68246. /**
  68247. * Creates a new GradientBlock
  68248. * @param name defines the block name
  68249. */
  68250. constructor(name: string);
  68251. /**
  68252. * Gets the current class name
  68253. * @returns the class name
  68254. */
  68255. getClassName(): string;
  68256. /**
  68257. * Gets the gradient input component
  68258. */
  68259. get gradient(): NodeMaterialConnectionPoint;
  68260. /**
  68261. * Gets the output component
  68262. */
  68263. get output(): NodeMaterialConnectionPoint;
  68264. private _writeColorConstant;
  68265. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68266. serialize(): any;
  68267. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68268. protected _dumpPropertiesCode(): string;
  68269. }
  68270. }
  68271. declare module BABYLON {
  68272. /**
  68273. * Block used to normalize lerp between 2 values
  68274. */
  68275. export class NLerpBlock extends NodeMaterialBlock {
  68276. /**
  68277. * Creates a new NLerpBlock
  68278. * @param name defines the block name
  68279. */
  68280. constructor(name: string);
  68281. /**
  68282. * Gets the current class name
  68283. * @returns the class name
  68284. */
  68285. getClassName(): string;
  68286. /**
  68287. * Gets the left operand input component
  68288. */
  68289. get left(): NodeMaterialConnectionPoint;
  68290. /**
  68291. * Gets the right operand input component
  68292. */
  68293. get right(): NodeMaterialConnectionPoint;
  68294. /**
  68295. * Gets the gradient operand input component
  68296. */
  68297. get gradient(): NodeMaterialConnectionPoint;
  68298. /**
  68299. * Gets the output component
  68300. */
  68301. get output(): NodeMaterialConnectionPoint;
  68302. protected _buildBlock(state: NodeMaterialBuildState): this;
  68303. }
  68304. }
  68305. declare module BABYLON {
  68306. /**
  68307. * block used to Generate a Worley Noise 3D Noise Pattern
  68308. */
  68309. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68310. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68311. manhattanDistance: boolean;
  68312. /**
  68313. * Creates a new WorleyNoise3DBlock
  68314. * @param name defines the block name
  68315. */
  68316. constructor(name: string);
  68317. /**
  68318. * Gets the current class name
  68319. * @returns the class name
  68320. */
  68321. getClassName(): string;
  68322. /**
  68323. * Gets the seed input component
  68324. */
  68325. get seed(): NodeMaterialConnectionPoint;
  68326. /**
  68327. * Gets the jitter input component
  68328. */
  68329. get jitter(): NodeMaterialConnectionPoint;
  68330. /**
  68331. * Gets the output component
  68332. */
  68333. get output(): NodeMaterialConnectionPoint;
  68334. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68335. /**
  68336. * Exposes the properties to the UI?
  68337. */
  68338. protected _dumpPropertiesCode(): string;
  68339. /**
  68340. * Exposes the properties to the Seralize?
  68341. */
  68342. serialize(): any;
  68343. /**
  68344. * Exposes the properties to the deseralize?
  68345. */
  68346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68347. }
  68348. }
  68349. declare module BABYLON {
  68350. /**
  68351. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68352. */
  68353. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68354. /**
  68355. * Creates a new SimplexPerlin3DBlock
  68356. * @param name defines the block name
  68357. */
  68358. constructor(name: string);
  68359. /**
  68360. * Gets the current class name
  68361. * @returns the class name
  68362. */
  68363. getClassName(): string;
  68364. /**
  68365. * Gets the seed operand input component
  68366. */
  68367. get seed(): NodeMaterialConnectionPoint;
  68368. /**
  68369. * Gets the output component
  68370. */
  68371. get output(): NodeMaterialConnectionPoint;
  68372. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68373. }
  68374. }
  68375. declare module BABYLON {
  68376. /**
  68377. * Block used to blend normals
  68378. */
  68379. export class NormalBlendBlock extends NodeMaterialBlock {
  68380. /**
  68381. * Creates a new NormalBlendBlock
  68382. * @param name defines the block name
  68383. */
  68384. constructor(name: string);
  68385. /**
  68386. * Gets the current class name
  68387. * @returns the class name
  68388. */
  68389. getClassName(): string;
  68390. /**
  68391. * Gets the first input component
  68392. */
  68393. get normalMap0(): NodeMaterialConnectionPoint;
  68394. /**
  68395. * Gets the second input component
  68396. */
  68397. get normalMap1(): NodeMaterialConnectionPoint;
  68398. /**
  68399. * Gets the output component
  68400. */
  68401. get output(): NodeMaterialConnectionPoint;
  68402. protected _buildBlock(state: NodeMaterialBuildState): this;
  68403. }
  68404. }
  68405. declare module BABYLON {
  68406. /**
  68407. * Block used to rotate a 2d vector by a given angle
  68408. */
  68409. export class Rotate2dBlock extends NodeMaterialBlock {
  68410. /**
  68411. * Creates a new Rotate2dBlock
  68412. * @param name defines the block name
  68413. */
  68414. constructor(name: string);
  68415. /**
  68416. * Gets the current class name
  68417. * @returns the class name
  68418. */
  68419. getClassName(): string;
  68420. /**
  68421. * Gets the input vector
  68422. */
  68423. get input(): NodeMaterialConnectionPoint;
  68424. /**
  68425. * Gets the input angle
  68426. */
  68427. get angle(): NodeMaterialConnectionPoint;
  68428. /**
  68429. * Gets the output component
  68430. */
  68431. get output(): NodeMaterialConnectionPoint;
  68432. autoConfigure(material: NodeMaterial): void;
  68433. protected _buildBlock(state: NodeMaterialBuildState): this;
  68434. }
  68435. }
  68436. declare module BABYLON {
  68437. /**
  68438. * Block used to get the reflected vector from a direction and a normal
  68439. */
  68440. export class ReflectBlock extends NodeMaterialBlock {
  68441. /**
  68442. * Creates a new ReflectBlock
  68443. * @param name defines the block name
  68444. */
  68445. constructor(name: string);
  68446. /**
  68447. * Gets the current class name
  68448. * @returns the class name
  68449. */
  68450. getClassName(): string;
  68451. /**
  68452. * Gets the incident component
  68453. */
  68454. get incident(): NodeMaterialConnectionPoint;
  68455. /**
  68456. * Gets the normal component
  68457. */
  68458. get normal(): NodeMaterialConnectionPoint;
  68459. /**
  68460. * Gets the output component
  68461. */
  68462. get output(): NodeMaterialConnectionPoint;
  68463. protected _buildBlock(state: NodeMaterialBuildState): this;
  68464. }
  68465. }
  68466. declare module BABYLON {
  68467. /**
  68468. * Block used to get the refracted vector from a direction and a normal
  68469. */
  68470. export class RefractBlock extends NodeMaterialBlock {
  68471. /**
  68472. * Creates a new RefractBlock
  68473. * @param name defines the block name
  68474. */
  68475. constructor(name: string);
  68476. /**
  68477. * Gets the current class name
  68478. * @returns the class name
  68479. */
  68480. getClassName(): string;
  68481. /**
  68482. * Gets the incident component
  68483. */
  68484. get incident(): NodeMaterialConnectionPoint;
  68485. /**
  68486. * Gets the normal component
  68487. */
  68488. get normal(): NodeMaterialConnectionPoint;
  68489. /**
  68490. * Gets the index of refraction component
  68491. */
  68492. get ior(): NodeMaterialConnectionPoint;
  68493. /**
  68494. * Gets the output component
  68495. */
  68496. get output(): NodeMaterialConnectionPoint;
  68497. protected _buildBlock(state: NodeMaterialBuildState): this;
  68498. }
  68499. }
  68500. declare module BABYLON {
  68501. /**
  68502. * Block used to desaturate a color
  68503. */
  68504. export class DesaturateBlock extends NodeMaterialBlock {
  68505. /**
  68506. * Creates a new DesaturateBlock
  68507. * @param name defines the block name
  68508. */
  68509. constructor(name: string);
  68510. /**
  68511. * Gets the current class name
  68512. * @returns the class name
  68513. */
  68514. getClassName(): string;
  68515. /**
  68516. * Gets the color operand input component
  68517. */
  68518. get color(): NodeMaterialConnectionPoint;
  68519. /**
  68520. * Gets the level operand input component
  68521. */
  68522. get level(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the output component
  68525. */
  68526. get output(): NodeMaterialConnectionPoint;
  68527. protected _buildBlock(state: NodeMaterialBuildState): this;
  68528. }
  68529. }
  68530. declare module BABYLON {
  68531. /**
  68532. * Block used to implement the reflection module of the PBR material
  68533. */
  68534. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68535. /** @hidden */
  68536. _defineLODReflectionAlpha: string;
  68537. /** @hidden */
  68538. _defineLinearSpecularReflection: string;
  68539. private _vEnvironmentIrradianceName;
  68540. /** @hidden */
  68541. _vReflectionMicrosurfaceInfosName: string;
  68542. /** @hidden */
  68543. _vReflectionInfosName: string;
  68544. /** @hidden */
  68545. _vReflectionFilteringInfoName: string;
  68546. private _scene;
  68547. /**
  68548. * The properties below are set by the main PBR block prior to calling methods of this class.
  68549. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68550. * It's less burden on the user side in the editor part.
  68551. */
  68552. /** @hidden */
  68553. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68554. /** @hidden */
  68555. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68556. /** @hidden */
  68557. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68558. /** @hidden */
  68559. viewConnectionPoint: NodeMaterialConnectionPoint;
  68560. /**
  68561. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68562. * diffuse part of the IBL.
  68563. */
  68564. useSphericalHarmonics: boolean;
  68565. /**
  68566. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68567. */
  68568. forceIrradianceInFragment: boolean;
  68569. /**
  68570. * Create a new ReflectionBlock
  68571. * @param name defines the block name
  68572. */
  68573. constructor(name: string);
  68574. /**
  68575. * Gets the current class name
  68576. * @returns the class name
  68577. */
  68578. getClassName(): string;
  68579. /**
  68580. * Gets the position input component
  68581. */
  68582. get position(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the world position input component
  68585. */
  68586. get worldPosition(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the world normal input component
  68589. */
  68590. get worldNormal(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the world input component
  68593. */
  68594. get world(): NodeMaterialConnectionPoint;
  68595. /**
  68596. * Gets the camera (or eye) position component
  68597. */
  68598. get cameraPosition(): NodeMaterialConnectionPoint;
  68599. /**
  68600. * Gets the view input component
  68601. */
  68602. get view(): NodeMaterialConnectionPoint;
  68603. /**
  68604. * Gets the color input component
  68605. */
  68606. get color(): NodeMaterialConnectionPoint;
  68607. /**
  68608. * Gets the reflection object output component
  68609. */
  68610. get reflection(): NodeMaterialConnectionPoint;
  68611. /**
  68612. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68613. */
  68614. get hasTexture(): boolean;
  68615. /**
  68616. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68617. */
  68618. get reflectionColor(): string;
  68619. protected _getTexture(): Nullable<BaseTexture>;
  68620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68621. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68622. /**
  68623. * Gets the code to inject in the vertex shader
  68624. * @param state current state of the node material building
  68625. * @returns the shader code
  68626. */
  68627. handleVertexSide(state: NodeMaterialBuildState): string;
  68628. /**
  68629. * Gets the main code of the block (fragment side)
  68630. * @param state current state of the node material building
  68631. * @param normalVarName name of the existing variable corresponding to the normal
  68632. * @returns the shader code
  68633. */
  68634. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68635. protected _buildBlock(state: NodeMaterialBuildState): this;
  68636. protected _dumpPropertiesCode(): string;
  68637. serialize(): any;
  68638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68639. }
  68640. }
  68641. declare module BABYLON {
  68642. /**
  68643. * Block used to implement the sheen module of the PBR material
  68644. */
  68645. export class SheenBlock extends NodeMaterialBlock {
  68646. /**
  68647. * Create a new SheenBlock
  68648. * @param name defines the block name
  68649. */
  68650. constructor(name: string);
  68651. /**
  68652. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68653. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68654. * making it easier to setup and tweak the effect
  68655. */
  68656. albedoScaling: boolean;
  68657. /**
  68658. * Defines if the sheen is linked to the sheen color.
  68659. */
  68660. linkSheenWithAlbedo: boolean;
  68661. /**
  68662. * Initialize the block and prepare the context for build
  68663. * @param state defines the state that will be used for the build
  68664. */
  68665. initialize(state: NodeMaterialBuildState): void;
  68666. /**
  68667. * Gets the current class name
  68668. * @returns the class name
  68669. */
  68670. getClassName(): string;
  68671. /**
  68672. * Gets the intensity input component
  68673. */
  68674. get intensity(): NodeMaterialConnectionPoint;
  68675. /**
  68676. * Gets the color input component
  68677. */
  68678. get color(): NodeMaterialConnectionPoint;
  68679. /**
  68680. * Gets the roughness input component
  68681. */
  68682. get roughness(): NodeMaterialConnectionPoint;
  68683. /**
  68684. * Gets the sheen object output component
  68685. */
  68686. get sheen(): NodeMaterialConnectionPoint;
  68687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68688. /**
  68689. * Gets the main code of the block (fragment side)
  68690. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68691. * @returns the shader code
  68692. */
  68693. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68694. protected _buildBlock(state: NodeMaterialBuildState): this;
  68695. protected _dumpPropertiesCode(): string;
  68696. serialize(): any;
  68697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68698. }
  68699. }
  68700. declare module BABYLON {
  68701. /**
  68702. * Block used to implement the anisotropy module of the PBR material
  68703. */
  68704. export class AnisotropyBlock extends NodeMaterialBlock {
  68705. /**
  68706. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68707. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68708. * It's less burden on the user side in the editor part.
  68709. */
  68710. /** @hidden */
  68711. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68712. /** @hidden */
  68713. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68714. /**
  68715. * Create a new AnisotropyBlock
  68716. * @param name defines the block name
  68717. */
  68718. constructor(name: string);
  68719. /**
  68720. * Initialize the block and prepare the context for build
  68721. * @param state defines the state that will be used for the build
  68722. */
  68723. initialize(state: NodeMaterialBuildState): void;
  68724. /**
  68725. * Gets the current class name
  68726. * @returns the class name
  68727. */
  68728. getClassName(): string;
  68729. /**
  68730. * Gets the intensity input component
  68731. */
  68732. get intensity(): NodeMaterialConnectionPoint;
  68733. /**
  68734. * Gets the direction input component
  68735. */
  68736. get direction(): NodeMaterialConnectionPoint;
  68737. /**
  68738. * Gets the uv input component
  68739. */
  68740. get uv(): NodeMaterialConnectionPoint;
  68741. /**
  68742. * Gets the worldTangent input component
  68743. */
  68744. get worldTangent(): NodeMaterialConnectionPoint;
  68745. /**
  68746. * Gets the anisotropy object output component
  68747. */
  68748. get anisotropy(): NodeMaterialConnectionPoint;
  68749. private _generateTBNSpace;
  68750. /**
  68751. * Gets the main code of the block (fragment side)
  68752. * @param state current state of the node material building
  68753. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68754. * @returns the shader code
  68755. */
  68756. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68757. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68758. protected _buildBlock(state: NodeMaterialBuildState): this;
  68759. }
  68760. }
  68761. declare module BABYLON {
  68762. /**
  68763. * Block used to implement the clear coat module of the PBR material
  68764. */
  68765. export class ClearCoatBlock extends NodeMaterialBlock {
  68766. private _scene;
  68767. /**
  68768. * Create a new ClearCoatBlock
  68769. * @param name defines the block name
  68770. */
  68771. constructor(name: string);
  68772. /**
  68773. * Defines if the F0 value should be remapped to account for the interface change in the material.
  68774. */
  68775. remapF0OnInterfaceChange: boolean;
  68776. /**
  68777. * Initialize the block and prepare the context for build
  68778. * @param state defines the state that will be used for the build
  68779. */
  68780. initialize(state: NodeMaterialBuildState): void;
  68781. /**
  68782. * Gets the current class name
  68783. * @returns the class name
  68784. */
  68785. getClassName(): string;
  68786. /**
  68787. * Gets the intensity input component
  68788. */
  68789. get intensity(): NodeMaterialConnectionPoint;
  68790. /**
  68791. * Gets the roughness input component
  68792. */
  68793. get roughness(): NodeMaterialConnectionPoint;
  68794. /**
  68795. * Gets the ior input component
  68796. */
  68797. get indexOfRefraction(): NodeMaterialConnectionPoint;
  68798. /**
  68799. * Gets the bump texture input component
  68800. */
  68801. get normalMapColor(): NodeMaterialConnectionPoint;
  68802. /**
  68803. * Gets the uv input component
  68804. */
  68805. get uv(): NodeMaterialConnectionPoint;
  68806. /**
  68807. * Gets the tint color input component
  68808. */
  68809. get tintColor(): NodeMaterialConnectionPoint;
  68810. /**
  68811. * Gets the tint "at distance" input component
  68812. */
  68813. get tintAtDistance(): NodeMaterialConnectionPoint;
  68814. /**
  68815. * Gets the tint thickness input component
  68816. */
  68817. get tintThickness(): NodeMaterialConnectionPoint;
  68818. /**
  68819. * Gets the world tangent input component
  68820. */
  68821. get worldTangent(): NodeMaterialConnectionPoint;
  68822. /**
  68823. * Gets the clear coat object output component
  68824. */
  68825. get clearcoat(): NodeMaterialConnectionPoint;
  68826. autoConfigure(material: NodeMaterial): void;
  68827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68828. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68829. private _generateTBNSpace;
  68830. /**
  68831. * Gets the main code of the block (fragment side)
  68832. * @param state current state of the node material building
  68833. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68834. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68835. * @param worldPosVarName name of the variable holding the world position
  68836. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68837. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68838. * @param worldNormalVarName name of the variable holding the world normal
  68839. * @returns the shader code
  68840. */
  68841. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68842. protected _buildBlock(state: NodeMaterialBuildState): this;
  68843. protected _dumpPropertiesCode(): string;
  68844. serialize(): any;
  68845. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68846. }
  68847. }
  68848. declare module BABYLON {
  68849. /**
  68850. * Block used to implement the sub surface module of the PBR material
  68851. */
  68852. export class SubSurfaceBlock extends NodeMaterialBlock {
  68853. /**
  68854. * Create a new SubSurfaceBlock
  68855. * @param name defines the block name
  68856. */
  68857. constructor(name: string);
  68858. /**
  68859. * Initialize the block and prepare the context for build
  68860. * @param state defines the state that will be used for the build
  68861. */
  68862. initialize(state: NodeMaterialBuildState): void;
  68863. /**
  68864. * Gets the current class name
  68865. * @returns the class name
  68866. */
  68867. getClassName(): string;
  68868. /**
  68869. * Gets the thickness component
  68870. */
  68871. get thickness(): NodeMaterialConnectionPoint;
  68872. /**
  68873. * Gets the tint color input component
  68874. */
  68875. get tintColor(): NodeMaterialConnectionPoint;
  68876. /**
  68877. * Gets the translucency intensity input component
  68878. */
  68879. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68880. /**
  68881. * Gets the translucency diffusion distance input component
  68882. */
  68883. get translucencyDiffusionDist(): NodeMaterialConnectionPoint;
  68884. /**
  68885. * Gets the refraction object parameters
  68886. */
  68887. get refraction(): NodeMaterialConnectionPoint;
  68888. /**
  68889. * Gets the sub surface object output component
  68890. */
  68891. get subsurface(): NodeMaterialConnectionPoint;
  68892. autoConfigure(material: NodeMaterial): void;
  68893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68894. /**
  68895. * Gets the main code of the block (fragment side)
  68896. * @param state current state of the node material building
  68897. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68898. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68899. * @param worldPosVarName name of the variable holding the world position
  68900. * @returns the shader code
  68901. */
  68902. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68903. protected _buildBlock(state: NodeMaterialBuildState): this;
  68904. }
  68905. }
  68906. declare module BABYLON {
  68907. /**
  68908. * Block used to implement the PBR metallic/roughness model
  68909. */
  68910. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68911. /**
  68912. * Gets or sets the light associated with this block
  68913. */
  68914. light: Nullable<Light>;
  68915. private _lightId;
  68916. private _scene;
  68917. private _environmentBRDFTexture;
  68918. private _environmentBrdfSamplerName;
  68919. private _vNormalWName;
  68920. private _invertNormalName;
  68921. private _metallicReflectanceColor;
  68922. private _metallicF0Factor;
  68923. private _vMetallicReflectanceFactorsName;
  68924. /**
  68925. * Create a new ReflectionBlock
  68926. * @param name defines the block name
  68927. */
  68928. constructor(name: string);
  68929. /**
  68930. * Intensity of the direct lights e.g. the four lights available in your scene.
  68931. * This impacts both the direct diffuse and specular highlights.
  68932. */
  68933. directIntensity: number;
  68934. /**
  68935. * Intensity of the environment e.g. how much the environment will light the object
  68936. * either through harmonics for rough material or through the refelction for shiny ones.
  68937. */
  68938. environmentIntensity: number;
  68939. /**
  68940. * This is a special control allowing the reduction of the specular highlights coming from the
  68941. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68942. */
  68943. specularIntensity: number;
  68944. /**
  68945. * Defines the falloff type used in this material.
  68946. * It by default is Physical.
  68947. */
  68948. lightFalloff: number;
  68949. /**
  68950. * Specifies that alpha test should be used
  68951. */
  68952. useAlphaTest: boolean;
  68953. /**
  68954. * Defines the alpha limits in alpha test mode.
  68955. */
  68956. alphaTestCutoff: number;
  68957. /**
  68958. * Specifies that alpha blending should be used
  68959. */
  68960. useAlphaBlending: boolean;
  68961. /**
  68962. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68963. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68964. */
  68965. useRadianceOverAlpha: boolean;
  68966. /**
  68967. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68968. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68969. */
  68970. useSpecularOverAlpha: boolean;
  68971. /**
  68972. * Enables specular anti aliasing in the PBR shader.
  68973. * It will both interacts on the Geometry for analytical and IBL lighting.
  68974. * It also prefilter the roughness map based on the bump values.
  68975. */
  68976. enableSpecularAntiAliasing: boolean;
  68977. /**
  68978. * Enables realtime filtering on the texture.
  68979. */
  68980. realTimeFiltering: boolean;
  68981. /**
  68982. * Quality switch for realtime filtering
  68983. */
  68984. realTimeFilteringQuality: number;
  68985. /**
  68986. * Defines if the material uses energy conservation.
  68987. */
  68988. useEnergyConservation: boolean;
  68989. /**
  68990. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68991. * too much the area relying on ambient texture to define their ambient occlusion.
  68992. */
  68993. useRadianceOcclusion: boolean;
  68994. /**
  68995. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68996. * makes the reflect vector face the model (under horizon).
  68997. */
  68998. useHorizonOcclusion: boolean;
  68999. /**
  69000. * If set to true, no lighting calculations will be applied.
  69001. */
  69002. unlit: boolean;
  69003. /**
  69004. * Force normal to face away from face.
  69005. */
  69006. forceNormalForward: boolean;
  69007. /**
  69008. * Defines the material debug mode.
  69009. * It helps seeing only some components of the material while troubleshooting.
  69010. */
  69011. debugMode: number;
  69012. /**
  69013. * Specify from where on screen the debug mode should start.
  69014. * The value goes from -1 (full screen) to 1 (not visible)
  69015. * It helps with side by side comparison against the final render
  69016. * This defaults to 0
  69017. */
  69018. debugLimit: number;
  69019. /**
  69020. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69021. * You can use the factor to better multiply the final value.
  69022. */
  69023. debugFactor: number;
  69024. /**
  69025. * Initialize the block and prepare the context for build
  69026. * @param state defines the state that will be used for the build
  69027. */
  69028. initialize(state: NodeMaterialBuildState): void;
  69029. /**
  69030. * Gets the current class name
  69031. * @returns the class name
  69032. */
  69033. getClassName(): string;
  69034. /**
  69035. * Gets the world position input component
  69036. */
  69037. get worldPosition(): NodeMaterialConnectionPoint;
  69038. /**
  69039. * Gets the world normal input component
  69040. */
  69041. get worldNormal(): NodeMaterialConnectionPoint;
  69042. /**
  69043. * Gets the view matrix parameter
  69044. */
  69045. get view(): NodeMaterialConnectionPoint;
  69046. /**
  69047. * Gets the camera position input component
  69048. */
  69049. get cameraPosition(): NodeMaterialConnectionPoint;
  69050. /**
  69051. * Gets the perturbed normal input component
  69052. */
  69053. get perturbedNormal(): NodeMaterialConnectionPoint;
  69054. /**
  69055. * Gets the base color input component
  69056. */
  69057. get baseColor(): NodeMaterialConnectionPoint;
  69058. /**
  69059. * Gets the metallic input component
  69060. */
  69061. get metallic(): NodeMaterialConnectionPoint;
  69062. /**
  69063. * Gets the roughness input component
  69064. */
  69065. get roughness(): NodeMaterialConnectionPoint;
  69066. /**
  69067. * Gets the ambient occlusion input component
  69068. */
  69069. get ambientOcc(): NodeMaterialConnectionPoint;
  69070. /**
  69071. * Gets the opacity input component
  69072. */
  69073. get opacity(): NodeMaterialConnectionPoint;
  69074. /**
  69075. * Gets the index of refraction input component
  69076. */
  69077. get indexOfRefraction(): NodeMaterialConnectionPoint;
  69078. /**
  69079. * Gets the ambient color input component
  69080. */
  69081. get ambientColor(): NodeMaterialConnectionPoint;
  69082. /**
  69083. * Gets the reflection object parameters
  69084. */
  69085. get reflection(): NodeMaterialConnectionPoint;
  69086. /**
  69087. * Gets the clear coat object parameters
  69088. */
  69089. get clearcoat(): NodeMaterialConnectionPoint;
  69090. /**
  69091. * Gets the sheen object parameters
  69092. */
  69093. get sheen(): NodeMaterialConnectionPoint;
  69094. /**
  69095. * Gets the sub surface object parameters
  69096. */
  69097. get subsurface(): NodeMaterialConnectionPoint;
  69098. /**
  69099. * Gets the anisotropy object parameters
  69100. */
  69101. get anisotropy(): NodeMaterialConnectionPoint;
  69102. /**
  69103. * Gets the ambient output component
  69104. */
  69105. get ambientClr(): NodeMaterialConnectionPoint;
  69106. /**
  69107. * Gets the diffuse output component
  69108. */
  69109. get diffuseDir(): NodeMaterialConnectionPoint;
  69110. /**
  69111. * Gets the specular output component
  69112. */
  69113. get specularDir(): NodeMaterialConnectionPoint;
  69114. /**
  69115. * Gets the clear coat output component
  69116. */
  69117. get clearcoatDir(): NodeMaterialConnectionPoint;
  69118. /**
  69119. * Gets the sheen output component
  69120. */
  69121. get sheenDir(): NodeMaterialConnectionPoint;
  69122. /**
  69123. * Gets the indirect diffuse output component
  69124. */
  69125. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69126. /**
  69127. * Gets the indirect specular output component
  69128. */
  69129. get specularIndirect(): NodeMaterialConnectionPoint;
  69130. /**
  69131. * Gets the indirect clear coat output component
  69132. */
  69133. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69134. /**
  69135. * Gets the indirect sheen output component
  69136. */
  69137. get sheenIndirect(): NodeMaterialConnectionPoint;
  69138. /**
  69139. * Gets the refraction output component
  69140. */
  69141. get refraction(): NodeMaterialConnectionPoint;
  69142. /**
  69143. * Gets the global lighting output component
  69144. */
  69145. get lighting(): NodeMaterialConnectionPoint;
  69146. /**
  69147. * Gets the shadow output component
  69148. */
  69149. get shadow(): NodeMaterialConnectionPoint;
  69150. /**
  69151. * Gets the alpha output component
  69152. */
  69153. get alpha(): NodeMaterialConnectionPoint;
  69154. autoConfigure(material: NodeMaterial): void;
  69155. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69156. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69157. isReady(): boolean;
  69158. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69159. private _injectVertexCode;
  69160. private _getAlbedoOpacityCode;
  69161. private _getAmbientOcclusionCode;
  69162. private _getReflectivityCode;
  69163. protected _buildBlock(state: NodeMaterialBuildState): this;
  69164. protected _dumpPropertiesCode(): string;
  69165. serialize(): any;
  69166. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69167. }
  69168. }
  69169. declare module BABYLON {
  69170. /**
  69171. * Block used to compute value of one parameter modulo another
  69172. */
  69173. export class ModBlock extends NodeMaterialBlock {
  69174. /**
  69175. * Creates a new ModBlock
  69176. * @param name defines the block name
  69177. */
  69178. constructor(name: string);
  69179. /**
  69180. * Gets the current class name
  69181. * @returns the class name
  69182. */
  69183. getClassName(): string;
  69184. /**
  69185. * Gets the left operand input component
  69186. */
  69187. get left(): NodeMaterialConnectionPoint;
  69188. /**
  69189. * Gets the right operand input component
  69190. */
  69191. get right(): NodeMaterialConnectionPoint;
  69192. /**
  69193. * Gets the output component
  69194. */
  69195. get output(): NodeMaterialConnectionPoint;
  69196. protected _buildBlock(state: NodeMaterialBuildState): this;
  69197. }
  69198. }
  69199. declare module BABYLON {
  69200. /**
  69201. * Configuration for Draco compression
  69202. */
  69203. export interface IDracoCompressionConfiguration {
  69204. /**
  69205. * Configuration for the decoder.
  69206. */
  69207. decoder: {
  69208. /**
  69209. * The url to the WebAssembly module.
  69210. */
  69211. wasmUrl?: string;
  69212. /**
  69213. * The url to the WebAssembly binary.
  69214. */
  69215. wasmBinaryUrl?: string;
  69216. /**
  69217. * The url to the fallback JavaScript module.
  69218. */
  69219. fallbackUrl?: string;
  69220. };
  69221. }
  69222. /**
  69223. * Draco compression (https://google.github.io/draco/)
  69224. *
  69225. * This class wraps the Draco module.
  69226. *
  69227. * **Encoder**
  69228. *
  69229. * The encoder is not currently implemented.
  69230. *
  69231. * **Decoder**
  69232. *
  69233. * 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.
  69234. *
  69235. * To update the configuration, use the following code:
  69236. * ```javascript
  69237. * DracoCompression.Configuration = {
  69238. * decoder: {
  69239. * wasmUrl: "<url to the WebAssembly library>",
  69240. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69241. * fallbackUrl: "<url to the fallback JavaScript library>",
  69242. * }
  69243. * };
  69244. * ```
  69245. *
  69246. * Draco has two versions, one for WebAssembly and one for JavaScript. The decoder configuration can be set to only support Webssembly or only support the JavaScript version.
  69247. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69248. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69249. *
  69250. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69251. * ```javascript
  69252. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69253. * ```
  69254. *
  69255. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69256. */
  69257. export class DracoCompression implements IDisposable {
  69258. private _workerPoolPromise?;
  69259. private _decoderModulePromise?;
  69260. /**
  69261. * The configuration. Defaults to the following urls:
  69262. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69263. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69264. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69265. */
  69266. static Configuration: IDracoCompressionConfiguration;
  69267. /**
  69268. * Returns true if the decoder configuration is available.
  69269. */
  69270. static get DecoderAvailable(): boolean;
  69271. /**
  69272. * Default number of workers to create when creating the draco compression object.
  69273. */
  69274. static DefaultNumWorkers: number;
  69275. private static GetDefaultNumWorkers;
  69276. private static _Default;
  69277. /**
  69278. * Default instance for the draco compression object.
  69279. */
  69280. static get Default(): DracoCompression;
  69281. /**
  69282. * Constructor
  69283. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69284. */
  69285. constructor(numWorkers?: number);
  69286. /**
  69287. * Stop all async operations and release resources.
  69288. */
  69289. dispose(): void;
  69290. /**
  69291. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69292. * @returns a promise that resolves when ready
  69293. */
  69294. whenReadyAsync(): Promise<void>;
  69295. /**
  69296. * Decode Draco compressed mesh data to vertex data.
  69297. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69298. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69299. * @returns A promise that resolves with the decoded vertex data
  69300. */
  69301. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69302. [kind: string]: number;
  69303. }): Promise<VertexData>;
  69304. }
  69305. }
  69306. declare module BABYLON {
  69307. /**
  69308. * Class for building Constructive Solid Geometry
  69309. */
  69310. export class CSG {
  69311. private polygons;
  69312. /**
  69313. * The world matrix
  69314. */
  69315. matrix: Matrix;
  69316. /**
  69317. * Stores the position
  69318. */
  69319. position: Vector3;
  69320. /**
  69321. * Stores the rotation
  69322. */
  69323. rotation: Vector3;
  69324. /**
  69325. * Stores the rotation quaternion
  69326. */
  69327. rotationQuaternion: Nullable<Quaternion>;
  69328. /**
  69329. * Stores the scaling vector
  69330. */
  69331. scaling: Vector3;
  69332. /**
  69333. * Convert the Mesh to CSG
  69334. * @param mesh The Mesh to convert to CSG
  69335. * @returns A new CSG from the Mesh
  69336. */
  69337. static FromMesh(mesh: Mesh): CSG;
  69338. /**
  69339. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69340. * @param polygons Polygons used to construct a CSG solid
  69341. */
  69342. private static FromPolygons;
  69343. /**
  69344. * Clones, or makes a deep copy, of the CSG
  69345. * @returns A new CSG
  69346. */
  69347. clone(): CSG;
  69348. /**
  69349. * Unions this CSG with another CSG
  69350. * @param csg The CSG to union against this CSG
  69351. * @returns The unioned CSG
  69352. */
  69353. union(csg: CSG): CSG;
  69354. /**
  69355. * Unions this CSG with another CSG in place
  69356. * @param csg The CSG to union against this CSG
  69357. */
  69358. unionInPlace(csg: CSG): void;
  69359. /**
  69360. * Subtracts this CSG with another CSG
  69361. * @param csg The CSG to subtract against this CSG
  69362. * @returns A new CSG
  69363. */
  69364. subtract(csg: CSG): CSG;
  69365. /**
  69366. * Subtracts this CSG with another CSG in place
  69367. * @param csg The CSG to subtact against this CSG
  69368. */
  69369. subtractInPlace(csg: CSG): void;
  69370. /**
  69371. * Intersect this CSG with another CSG
  69372. * @param csg The CSG to intersect against this CSG
  69373. * @returns A new CSG
  69374. */
  69375. intersect(csg: CSG): CSG;
  69376. /**
  69377. * Intersects this CSG with another CSG in place
  69378. * @param csg The CSG to intersect against this CSG
  69379. */
  69380. intersectInPlace(csg: CSG): void;
  69381. /**
  69382. * Return a new CSG solid with solid and empty space switched. This solid is
  69383. * not modified.
  69384. * @returns A new CSG solid with solid and empty space switched
  69385. */
  69386. inverse(): CSG;
  69387. /**
  69388. * Inverses the CSG in place
  69389. */
  69390. inverseInPlace(): void;
  69391. /**
  69392. * This is used to keep meshes transformations so they can be restored
  69393. * when we build back a Babylon Mesh
  69394. * NB : All CSG operations are performed in world coordinates
  69395. * @param csg The CSG to copy the transform attributes from
  69396. * @returns This CSG
  69397. */
  69398. copyTransformAttributes(csg: CSG): CSG;
  69399. /**
  69400. * Build Raw mesh from CSG
  69401. * Coordinates here are in world space
  69402. * @param name The name of the mesh geometry
  69403. * @param scene The Scene
  69404. * @param keepSubMeshes Specifies if the submeshes should be kept
  69405. * @returns A new Mesh
  69406. */
  69407. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69408. /**
  69409. * Build Mesh from CSG taking material and transforms into account
  69410. * @param name The name of the Mesh
  69411. * @param material The material of the Mesh
  69412. * @param scene The Scene
  69413. * @param keepSubMeshes Specifies if submeshes should be kept
  69414. * @returns The new Mesh
  69415. */
  69416. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69417. }
  69418. }
  69419. declare module BABYLON {
  69420. /**
  69421. * Class used to create a trail following a mesh
  69422. */
  69423. export class TrailMesh extends Mesh {
  69424. private _generator;
  69425. private _autoStart;
  69426. private _running;
  69427. private _diameter;
  69428. private _length;
  69429. private _sectionPolygonPointsCount;
  69430. private _sectionVectors;
  69431. private _sectionNormalVectors;
  69432. private _beforeRenderObserver;
  69433. /**
  69434. * @constructor
  69435. * @param name The value used by scene.getMeshByName() to do a lookup.
  69436. * @param generator The mesh or transform node to generate a trail.
  69437. * @param scene The scene to add this mesh to.
  69438. * @param diameter Diameter of trailing mesh. Default is 1.
  69439. * @param length Length of trailing mesh. Default is 60.
  69440. * @param autoStart Automatically start trailing mesh. Default true.
  69441. */
  69442. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69443. /**
  69444. * "TrailMesh"
  69445. * @returns "TrailMesh"
  69446. */
  69447. getClassName(): string;
  69448. private _createMesh;
  69449. /**
  69450. * Start trailing mesh.
  69451. */
  69452. start(): void;
  69453. /**
  69454. * Stop trailing mesh.
  69455. */
  69456. stop(): void;
  69457. /**
  69458. * Update trailing mesh geometry.
  69459. */
  69460. update(): void;
  69461. /**
  69462. * Returns a new TrailMesh object.
  69463. * @param name is a string, the name given to the new mesh
  69464. * @param newGenerator use new generator object for cloned trail mesh
  69465. * @returns a new mesh
  69466. */
  69467. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69468. /**
  69469. * Serializes this trail mesh
  69470. * @param serializationObject object to write serialization to
  69471. */
  69472. serialize(serializationObject: any): void;
  69473. /**
  69474. * Parses a serialized trail mesh
  69475. * @param parsedMesh the serialized mesh
  69476. * @param scene the scene to create the trail mesh in
  69477. * @returns the created trail mesh
  69478. */
  69479. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69480. }
  69481. }
  69482. declare module BABYLON {
  69483. /**
  69484. * Class containing static functions to help procedurally build meshes
  69485. */
  69486. export class TiledBoxBuilder {
  69487. /**
  69488. * Creates a box mesh
  69489. * 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)
  69490. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69492. * * 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
  69493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69494. * @param name defines the name of the mesh
  69495. * @param options defines the options used to create the mesh
  69496. * @param scene defines the hosting scene
  69497. * @returns the box mesh
  69498. */
  69499. static CreateTiledBox(name: string, options: {
  69500. pattern?: number;
  69501. width?: number;
  69502. height?: number;
  69503. depth?: number;
  69504. tileSize?: number;
  69505. tileWidth?: number;
  69506. tileHeight?: number;
  69507. alignHorizontal?: number;
  69508. alignVertical?: number;
  69509. faceUV?: Vector4[];
  69510. faceColors?: Color4[];
  69511. sideOrientation?: number;
  69512. updatable?: boolean;
  69513. }, scene?: Nullable<Scene>): Mesh;
  69514. }
  69515. }
  69516. declare module BABYLON {
  69517. /**
  69518. * Class containing static functions to help procedurally build meshes
  69519. */
  69520. export class TorusKnotBuilder {
  69521. /**
  69522. * Creates a torus knot mesh
  69523. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69524. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69525. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69526. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69528. * * 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
  69529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69530. * @param name defines the name of the mesh
  69531. * @param options defines the options used to create the mesh
  69532. * @param scene defines the hosting scene
  69533. * @returns the torus knot mesh
  69534. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69535. */
  69536. static CreateTorusKnot(name: string, options: {
  69537. radius?: number;
  69538. tube?: number;
  69539. radialSegments?: number;
  69540. tubularSegments?: number;
  69541. p?: number;
  69542. q?: number;
  69543. updatable?: boolean;
  69544. sideOrientation?: number;
  69545. frontUVs?: Vector4;
  69546. backUVs?: Vector4;
  69547. }, scene: any): Mesh;
  69548. }
  69549. }
  69550. declare module BABYLON {
  69551. /**
  69552. * Polygon
  69553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69554. */
  69555. export class Polygon {
  69556. /**
  69557. * Creates a rectangle
  69558. * @param xmin bottom X coord
  69559. * @param ymin bottom Y coord
  69560. * @param xmax top X coord
  69561. * @param ymax top Y coord
  69562. * @returns points that make the resulting rectation
  69563. */
  69564. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69565. /**
  69566. * Creates a circle
  69567. * @param radius radius of circle
  69568. * @param cx scale in x
  69569. * @param cy scale in y
  69570. * @param numberOfSides number of sides that make up the circle
  69571. * @returns points that make the resulting circle
  69572. */
  69573. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69574. /**
  69575. * Creates a polygon from input string
  69576. * @param input Input polygon data
  69577. * @returns the parsed points
  69578. */
  69579. static Parse(input: string): Vector2[];
  69580. /**
  69581. * Starts building a polygon from x and y coordinates
  69582. * @param x x coordinate
  69583. * @param y y coordinate
  69584. * @returns the started path2
  69585. */
  69586. static StartingAt(x: number, y: number): Path2;
  69587. }
  69588. /**
  69589. * Builds a polygon
  69590. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69591. */
  69592. export class PolygonMeshBuilder {
  69593. private _points;
  69594. private _outlinepoints;
  69595. private _holes;
  69596. private _name;
  69597. private _scene;
  69598. private _epoints;
  69599. private _eholes;
  69600. private _addToepoint;
  69601. /**
  69602. * Babylon reference to the earcut plugin.
  69603. */
  69604. bjsEarcut: any;
  69605. /**
  69606. * Creates a PolygonMeshBuilder
  69607. * @param name name of the builder
  69608. * @param contours Path of the polygon
  69609. * @param scene scene to add to when creating the mesh
  69610. * @param earcutInjection can be used to inject your own earcut reference
  69611. */
  69612. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69613. /**
  69614. * Adds a hole within the polygon
  69615. * @param hole Array of points defining the hole
  69616. * @returns this
  69617. */
  69618. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69619. /**
  69620. * Creates the polygon
  69621. * @param updatable If the mesh should be updatable
  69622. * @param depth The depth of the mesh created
  69623. * @param smoothingThreshold Dot product threshold for smoothed normals
  69624. * @returns the created mesh
  69625. */
  69626. build(updatable?: boolean, depth?: number, smoothingThreshold?: number): Mesh;
  69627. /**
  69628. * Creates the polygon
  69629. * @param depth The depth of the mesh created
  69630. * @param smoothingThreshold Dot product threshold for smoothed normals
  69631. * @returns the created VertexData
  69632. */
  69633. buildVertexData(depth?: number, smoothingThreshold?: number): VertexData;
  69634. /**
  69635. * Adds a side to the polygon
  69636. * @param positions points that make the polygon
  69637. * @param normals normals of the polygon
  69638. * @param uvs uvs of the polygon
  69639. * @param indices indices of the polygon
  69640. * @param bounds bounds of the polygon
  69641. * @param points points of the polygon
  69642. * @param depth depth of the polygon
  69643. * @param flip flip of the polygon
  69644. */
  69645. private addSide;
  69646. }
  69647. }
  69648. declare module BABYLON {
  69649. /**
  69650. * Class containing static functions to help procedurally build meshes
  69651. */
  69652. export class PolygonBuilder {
  69653. /**
  69654. * Creates a polygon mesh
  69655. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69656. * * 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
  69657. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69659. * * 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)
  69660. * * Remember you can only change the shape positions, not their number when updating a polygon
  69661. * @param name defines the name of the mesh
  69662. * @param options defines the options used to create the mesh
  69663. * @param scene defines the hosting scene
  69664. * @param earcutInjection can be used to inject your own earcut reference
  69665. * @returns the polygon mesh
  69666. */
  69667. static CreatePolygon(name: string, options: {
  69668. shape: Vector3[];
  69669. holes?: Vector3[][];
  69670. depth?: number;
  69671. smoothingThreshold?: number;
  69672. faceUV?: Vector4[];
  69673. faceColors?: Color4[];
  69674. updatable?: boolean;
  69675. sideOrientation?: number;
  69676. frontUVs?: Vector4;
  69677. backUVs?: Vector4;
  69678. wrap?: boolean;
  69679. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69680. /**
  69681. * Creates an extruded polygon mesh, with depth in the Y direction.
  69682. * * 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)
  69683. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69684. * @param name defines the name of the mesh
  69685. * @param options defines the options used to create the mesh
  69686. * @param scene defines the hosting scene
  69687. * @param earcutInjection can be used to inject your own earcut reference
  69688. * @returns the polygon mesh
  69689. */
  69690. static ExtrudePolygon(name: string, options: {
  69691. shape: Vector3[];
  69692. holes?: Vector3[][];
  69693. depth?: number;
  69694. faceUV?: Vector4[];
  69695. faceColors?: Color4[];
  69696. updatable?: boolean;
  69697. sideOrientation?: number;
  69698. frontUVs?: Vector4;
  69699. backUVs?: Vector4;
  69700. wrap?: boolean;
  69701. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69702. }
  69703. }
  69704. declare module BABYLON {
  69705. /**
  69706. * Class containing static functions to help procedurally build meshes
  69707. */
  69708. export class LatheBuilder {
  69709. /**
  69710. * Creates lathe mesh.
  69711. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69712. * * 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
  69713. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69714. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69715. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69716. * * 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
  69717. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69718. * * 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
  69719. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69720. * * 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
  69721. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69722. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69723. * @param name defines the name of the mesh
  69724. * @param options defines the options used to create the mesh
  69725. * @param scene defines the hosting scene
  69726. * @returns the lathe mesh
  69727. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69728. */
  69729. static CreateLathe(name: string, options: {
  69730. shape: Vector3[];
  69731. radius?: number;
  69732. tessellation?: number;
  69733. clip?: number;
  69734. arc?: number;
  69735. closed?: boolean;
  69736. updatable?: boolean;
  69737. sideOrientation?: number;
  69738. frontUVs?: Vector4;
  69739. backUVs?: Vector4;
  69740. cap?: number;
  69741. invertUV?: boolean;
  69742. }, scene?: Nullable<Scene>): Mesh;
  69743. }
  69744. }
  69745. declare module BABYLON {
  69746. /**
  69747. * Class containing static functions to help procedurally build meshes
  69748. */
  69749. export class TiledPlaneBuilder {
  69750. /**
  69751. * Creates a tiled plane mesh
  69752. * * The parameter `pattern` will, depending on value, do nothing or
  69753. * * * flip (reflect about central vertical) alternate tiles across and up
  69754. * * * flip every tile on alternate rows
  69755. * * * rotate (180 degs) alternate tiles across and up
  69756. * * * rotate every tile on alternate rows
  69757. * * * flip and rotate alternate tiles across and up
  69758. * * * flip and rotate every tile on alternate rows
  69759. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69760. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69761. * * 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
  69762. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69763. * * 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)
  69764. * * 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)
  69765. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69766. * @param name defines the name of the mesh
  69767. * @param options defines the options used to create the mesh
  69768. * @param scene defines the hosting scene
  69769. * @returns the box mesh
  69770. */
  69771. static CreateTiledPlane(name: string, options: {
  69772. pattern?: number;
  69773. tileSize?: number;
  69774. tileWidth?: number;
  69775. tileHeight?: number;
  69776. size?: number;
  69777. width?: number;
  69778. height?: number;
  69779. alignHorizontal?: number;
  69780. alignVertical?: number;
  69781. sideOrientation?: number;
  69782. frontUVs?: Vector4;
  69783. backUVs?: Vector4;
  69784. updatable?: boolean;
  69785. }, scene?: Nullable<Scene>): Mesh;
  69786. }
  69787. }
  69788. declare module BABYLON {
  69789. /**
  69790. * Class containing static functions to help procedurally build meshes
  69791. */
  69792. export class TubeBuilder {
  69793. /**
  69794. * Creates a tube mesh.
  69795. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69796. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69797. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69798. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69799. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69800. * * 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)
  69801. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69802. * * 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
  69803. * * 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
  69804. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69805. * * 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
  69806. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69808. * @param name defines the name of the mesh
  69809. * @param options defines the options used to create the mesh
  69810. * @param scene defines the hosting scene
  69811. * @returns the tube mesh
  69812. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69813. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69814. */
  69815. static CreateTube(name: string, options: {
  69816. path: Vector3[];
  69817. radius?: number;
  69818. tessellation?: number;
  69819. radiusFunction?: {
  69820. (i: number, distance: number): number;
  69821. };
  69822. cap?: number;
  69823. arc?: number;
  69824. updatable?: boolean;
  69825. sideOrientation?: number;
  69826. frontUVs?: Vector4;
  69827. backUVs?: Vector4;
  69828. instance?: Mesh;
  69829. invertUV?: boolean;
  69830. }, scene?: Nullable<Scene>): Mesh;
  69831. }
  69832. }
  69833. declare module BABYLON {
  69834. /**
  69835. * Class containing static functions to help procedurally build meshes
  69836. */
  69837. export class IcoSphereBuilder {
  69838. /**
  69839. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69840. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69841. * * 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`)
  69842. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69843. * * 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
  69844. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69845. * * 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
  69846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69847. * @param name defines the name of the mesh
  69848. * @param options defines the options used to create the mesh
  69849. * @param scene defines the hosting scene
  69850. * @returns the icosahedron mesh
  69851. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69852. */
  69853. static CreateIcoSphere(name: string, options: {
  69854. radius?: number;
  69855. radiusX?: number;
  69856. radiusY?: number;
  69857. radiusZ?: number;
  69858. flat?: boolean;
  69859. subdivisions?: number;
  69860. sideOrientation?: number;
  69861. frontUVs?: Vector4;
  69862. backUVs?: Vector4;
  69863. updatable?: boolean;
  69864. }, scene?: Nullable<Scene>): Mesh;
  69865. }
  69866. }
  69867. declare module BABYLON {
  69868. /**
  69869. * Class containing static functions to help procedurally build meshes
  69870. */
  69871. export class DecalBuilder {
  69872. /**
  69873. * Creates a decal mesh.
  69874. * 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
  69875. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69876. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69877. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69878. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69879. * @param name defines the name of the mesh
  69880. * @param sourceMesh defines the mesh where the decal must be applied
  69881. * @param options defines the options used to create the mesh
  69882. * @param scene defines the hosting scene
  69883. * @returns the decal mesh
  69884. * @see https://doc.babylonjs.com/how_to/decals
  69885. */
  69886. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69887. position?: Vector3;
  69888. normal?: Vector3;
  69889. size?: Vector3;
  69890. angle?: number;
  69891. }): Mesh;
  69892. }
  69893. }
  69894. declare module BABYLON {
  69895. /**
  69896. * Class containing static functions to help procedurally build meshes
  69897. */
  69898. export class MeshBuilder {
  69899. /**
  69900. * Creates a box mesh
  69901. * * The parameter `size` sets the size (float) of each box side (default 1)
  69902. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69903. * * 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)
  69904. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69905. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69906. * * 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
  69907. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69908. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69909. * @param name defines the name of the mesh
  69910. * @param options defines the options used to create the mesh
  69911. * @param scene defines the hosting scene
  69912. * @returns the box mesh
  69913. */
  69914. static CreateBox(name: string, options: {
  69915. size?: number;
  69916. width?: number;
  69917. height?: number;
  69918. depth?: number;
  69919. faceUV?: Vector4[];
  69920. faceColors?: Color4[];
  69921. sideOrientation?: number;
  69922. frontUVs?: Vector4;
  69923. backUVs?: Vector4;
  69924. wrap?: boolean;
  69925. topBaseAt?: number;
  69926. bottomBaseAt?: number;
  69927. updatable?: boolean;
  69928. }, scene?: Nullable<Scene>): Mesh;
  69929. /**
  69930. * Creates a tiled box mesh
  69931. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69933. * @param name defines the name of the mesh
  69934. * @param options defines the options used to create the mesh
  69935. * @param scene defines the hosting scene
  69936. * @returns the tiled box mesh
  69937. */
  69938. static CreateTiledBox(name: string, options: {
  69939. pattern?: number;
  69940. size?: number;
  69941. width?: number;
  69942. height?: number;
  69943. depth: number;
  69944. tileSize?: number;
  69945. tileWidth?: number;
  69946. tileHeight?: number;
  69947. faceUV?: Vector4[];
  69948. faceColors?: Color4[];
  69949. alignHorizontal?: number;
  69950. alignVertical?: number;
  69951. sideOrientation?: number;
  69952. updatable?: boolean;
  69953. }, scene?: Nullable<Scene>): Mesh;
  69954. /**
  69955. * Creates a sphere mesh
  69956. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69957. * * 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`)
  69958. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69959. * * 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
  69960. * * 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)
  69961. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69962. * * 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
  69963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69964. * @param name defines the name of the mesh
  69965. * @param options defines the options used to create the mesh
  69966. * @param scene defines the hosting scene
  69967. * @returns the sphere mesh
  69968. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69969. */
  69970. static CreateSphere(name: string, options: {
  69971. segments?: number;
  69972. diameter?: number;
  69973. diameterX?: number;
  69974. diameterY?: number;
  69975. diameterZ?: number;
  69976. arc?: number;
  69977. slice?: number;
  69978. sideOrientation?: number;
  69979. frontUVs?: Vector4;
  69980. backUVs?: Vector4;
  69981. updatable?: boolean;
  69982. }, scene?: Nullable<Scene>): Mesh;
  69983. /**
  69984. * Creates a plane polygonal mesh. By default, this is a disc
  69985. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69986. * * 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
  69987. * * 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
  69988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69989. * * 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
  69990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69991. * @param name defines the name of the mesh
  69992. * @param options defines the options used to create the mesh
  69993. * @param scene defines the hosting scene
  69994. * @returns the plane polygonal mesh
  69995. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69996. */
  69997. static CreateDisc(name: string, options: {
  69998. radius?: number;
  69999. tessellation?: number;
  70000. arc?: number;
  70001. updatable?: boolean;
  70002. sideOrientation?: number;
  70003. frontUVs?: Vector4;
  70004. backUVs?: Vector4;
  70005. }, scene?: Nullable<Scene>): Mesh;
  70006. /**
  70007. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70008. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70009. * * 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`)
  70010. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70011. * * 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
  70012. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70013. * * 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
  70014. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70015. * @param name defines the name of the mesh
  70016. * @param options defines the options used to create the mesh
  70017. * @param scene defines the hosting scene
  70018. * @returns the icosahedron mesh
  70019. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70020. */
  70021. static CreateIcoSphere(name: string, options: {
  70022. radius?: number;
  70023. radiusX?: number;
  70024. radiusY?: number;
  70025. radiusZ?: number;
  70026. flat?: boolean;
  70027. subdivisions?: number;
  70028. sideOrientation?: number;
  70029. frontUVs?: Vector4;
  70030. backUVs?: Vector4;
  70031. updatable?: boolean;
  70032. }, scene?: Nullable<Scene>): Mesh;
  70033. /**
  70034. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70035. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70036. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70037. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70038. * * 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
  70039. * * 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
  70040. * * 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
  70041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70042. * * 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
  70043. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70044. * * 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
  70045. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70046. * * 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
  70047. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70048. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70049. * @param name defines the name of the mesh
  70050. * @param options defines the options used to create the mesh
  70051. * @param scene defines the hosting scene
  70052. * @returns the ribbon mesh
  70053. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70055. */
  70056. static CreateRibbon(name: string, options: {
  70057. pathArray: Vector3[][];
  70058. closeArray?: boolean;
  70059. closePath?: boolean;
  70060. offset?: number;
  70061. updatable?: boolean;
  70062. sideOrientation?: number;
  70063. frontUVs?: Vector4;
  70064. backUVs?: Vector4;
  70065. instance?: Mesh;
  70066. invertUV?: boolean;
  70067. uvs?: Vector2[];
  70068. colors?: Color4[];
  70069. }, scene?: Nullable<Scene>): Mesh;
  70070. /**
  70071. * Creates a cylinder or a cone mesh
  70072. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70073. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70074. * * 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.
  70075. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70076. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70077. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70078. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70079. * * 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).
  70080. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70081. * * 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).
  70082. * * 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
  70083. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70084. * * 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
  70085. * * 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.
  70086. * * If `enclose` is false, a ring surface is one element.
  70087. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70088. * * 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
  70089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70090. * * 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
  70091. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70092. * @param name defines the name of the mesh
  70093. * @param options defines the options used to create the mesh
  70094. * @param scene defines the hosting scene
  70095. * @returns the cylinder mesh
  70096. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70097. */
  70098. static CreateCylinder(name: string, options: {
  70099. height?: number;
  70100. diameterTop?: number;
  70101. diameterBottom?: number;
  70102. diameter?: number;
  70103. tessellation?: number;
  70104. subdivisions?: number;
  70105. arc?: number;
  70106. faceColors?: Color4[];
  70107. faceUV?: Vector4[];
  70108. updatable?: boolean;
  70109. hasRings?: boolean;
  70110. enclose?: boolean;
  70111. cap?: number;
  70112. sideOrientation?: number;
  70113. frontUVs?: Vector4;
  70114. backUVs?: Vector4;
  70115. }, scene?: Nullable<Scene>): Mesh;
  70116. /**
  70117. * Creates a torus mesh
  70118. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70119. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70120. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70122. * * 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
  70123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70124. * @param name defines the name of the mesh
  70125. * @param options defines the options used to create the mesh
  70126. * @param scene defines the hosting scene
  70127. * @returns the torus mesh
  70128. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70129. */
  70130. static CreateTorus(name: string, options: {
  70131. diameter?: number;
  70132. thickness?: number;
  70133. tessellation?: number;
  70134. updatable?: boolean;
  70135. sideOrientation?: number;
  70136. frontUVs?: Vector4;
  70137. backUVs?: Vector4;
  70138. }, scene?: Nullable<Scene>): Mesh;
  70139. /**
  70140. * Creates a torus knot mesh
  70141. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70142. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70143. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70144. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70145. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70146. * * 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
  70147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70148. * @param name defines the name of the mesh
  70149. * @param options defines the options used to create the mesh
  70150. * @param scene defines the hosting scene
  70151. * @returns the torus knot mesh
  70152. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70153. */
  70154. static CreateTorusKnot(name: string, options: {
  70155. radius?: number;
  70156. tube?: number;
  70157. radialSegments?: number;
  70158. tubularSegments?: number;
  70159. p?: number;
  70160. q?: number;
  70161. updatable?: boolean;
  70162. sideOrientation?: number;
  70163. frontUVs?: Vector4;
  70164. backUVs?: Vector4;
  70165. }, scene?: Nullable<Scene>): Mesh;
  70166. /**
  70167. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70168. * * 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
  70169. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70170. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70171. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70172. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70173. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70174. * * 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
  70175. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70176. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70177. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70178. * @param name defines the name of the new line system
  70179. * @param options defines the options used to create the line system
  70180. * @param scene defines the hosting scene
  70181. * @returns a new line system mesh
  70182. */
  70183. static CreateLineSystem(name: string, options: {
  70184. lines: Vector3[][];
  70185. updatable?: boolean;
  70186. instance?: Nullable<LinesMesh>;
  70187. colors?: Nullable<Color4[][]>;
  70188. useVertexAlpha?: boolean;
  70189. }, scene: Nullable<Scene>): LinesMesh;
  70190. /**
  70191. * Creates a line mesh
  70192. * 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
  70193. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70194. * * The parameter `points` is an array successive Vector3
  70195. * * 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
  70196. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70197. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70198. * * When updating an instance, remember that only point positions can change, not the number of points
  70199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70200. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70201. * @param name defines the name of the new line system
  70202. * @param options defines the options used to create the line system
  70203. * @param scene defines the hosting scene
  70204. * @returns a new line mesh
  70205. */
  70206. static CreateLines(name: string, options: {
  70207. points: Vector3[];
  70208. updatable?: boolean;
  70209. instance?: Nullable<LinesMesh>;
  70210. colors?: Color4[];
  70211. useVertexAlpha?: boolean;
  70212. }, scene?: Nullable<Scene>): LinesMesh;
  70213. /**
  70214. * Creates a dashed line mesh
  70215. * * 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
  70216. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70217. * * The parameter `points` is an array successive Vector3
  70218. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70219. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70220. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70221. * * 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
  70222. * * When updating an instance, remember that only point positions can change, not the number of points
  70223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70224. * @param name defines the name of the mesh
  70225. * @param options defines the options used to create the mesh
  70226. * @param scene defines the hosting scene
  70227. * @returns the dashed line mesh
  70228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70229. */
  70230. static CreateDashedLines(name: string, options: {
  70231. points: Vector3[];
  70232. dashSize?: number;
  70233. gapSize?: number;
  70234. dashNb?: number;
  70235. updatable?: boolean;
  70236. instance?: LinesMesh;
  70237. }, scene?: Nullable<Scene>): LinesMesh;
  70238. /**
  70239. * 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.
  70240. * * 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.
  70241. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70242. * * 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.
  70243. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70244. * * 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
  70245. * * 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
  70246. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70248. * * 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
  70249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70250. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70251. * @param name defines the name of the mesh
  70252. * @param options defines the options used to create the mesh
  70253. * @param scene defines the hosting scene
  70254. * @returns the extruded shape mesh
  70255. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70257. */
  70258. static ExtrudeShape(name: string, options: {
  70259. shape: Vector3[];
  70260. path: Vector3[];
  70261. scale?: number;
  70262. rotation?: number;
  70263. cap?: number;
  70264. updatable?: boolean;
  70265. sideOrientation?: number;
  70266. frontUVs?: Vector4;
  70267. backUVs?: Vector4;
  70268. instance?: Mesh;
  70269. invertUV?: boolean;
  70270. }, scene?: Nullable<Scene>): Mesh;
  70271. /**
  70272. * Creates an custom extruded shape mesh.
  70273. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70274. * * 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.
  70275. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70276. * * 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 begining of the path
  70277. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70278. * * 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
  70279. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70280. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70281. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70282. * * 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
  70283. * * 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
  70284. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70285. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70286. * * 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
  70287. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70288. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70289. * @param name defines the name of the mesh
  70290. * @param options defines the options used to create the mesh
  70291. * @param scene defines the hosting scene
  70292. * @returns the custom extruded shape mesh
  70293. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70294. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70295. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70296. */
  70297. static ExtrudeShapeCustom(name: string, options: {
  70298. shape: Vector3[];
  70299. path: Vector3[];
  70300. scaleFunction?: any;
  70301. rotationFunction?: any;
  70302. ribbonCloseArray?: boolean;
  70303. ribbonClosePath?: boolean;
  70304. cap?: number;
  70305. updatable?: boolean;
  70306. sideOrientation?: number;
  70307. frontUVs?: Vector4;
  70308. backUVs?: Vector4;
  70309. instance?: Mesh;
  70310. invertUV?: boolean;
  70311. }, scene?: Nullable<Scene>): Mesh;
  70312. /**
  70313. * Creates lathe mesh.
  70314. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70315. * * 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
  70316. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70317. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70318. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70319. * * 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
  70320. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70321. * * 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
  70322. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70323. * * 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
  70324. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70326. * @param name defines the name of the mesh
  70327. * @param options defines the options used to create the mesh
  70328. * @param scene defines the hosting scene
  70329. * @returns the lathe mesh
  70330. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70331. */
  70332. static CreateLathe(name: string, options: {
  70333. shape: Vector3[];
  70334. radius?: number;
  70335. tessellation?: number;
  70336. clip?: number;
  70337. arc?: number;
  70338. closed?: boolean;
  70339. updatable?: boolean;
  70340. sideOrientation?: number;
  70341. frontUVs?: Vector4;
  70342. backUVs?: Vector4;
  70343. cap?: number;
  70344. invertUV?: boolean;
  70345. }, scene?: Nullable<Scene>): Mesh;
  70346. /**
  70347. * Creates a tiled plane mesh
  70348. * * You can set a limited pattern arrangement with the tiles
  70349. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70350. * * 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
  70351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70352. * @param name defines the name of the mesh
  70353. * @param options defines the options used to create the mesh
  70354. * @param scene defines the hosting scene
  70355. * @returns the plane mesh
  70356. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70357. */
  70358. static CreateTiledPlane(name: string, options: {
  70359. pattern?: number;
  70360. tileSize?: number;
  70361. tileWidth?: number;
  70362. tileHeight?: number;
  70363. size?: number;
  70364. width?: number;
  70365. height?: number;
  70366. alignHorizontal?: number;
  70367. alignVertical?: number;
  70368. sideOrientation?: number;
  70369. frontUVs?: Vector4;
  70370. backUVs?: Vector4;
  70371. updatable?: boolean;
  70372. }, scene?: Nullable<Scene>): Mesh;
  70373. /**
  70374. * Creates a plane mesh
  70375. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70376. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70377. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70378. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70379. * * 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
  70380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70381. * @param name defines the name of the mesh
  70382. * @param options defines the options used to create the mesh
  70383. * @param scene defines the hosting scene
  70384. * @returns the plane mesh
  70385. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70386. */
  70387. static CreatePlane(name: string, options: {
  70388. size?: number;
  70389. width?: number;
  70390. height?: number;
  70391. sideOrientation?: number;
  70392. frontUVs?: Vector4;
  70393. backUVs?: Vector4;
  70394. updatable?: boolean;
  70395. sourcePlane?: Plane;
  70396. }, scene?: Nullable<Scene>): Mesh;
  70397. /**
  70398. * Creates a ground mesh
  70399. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70400. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70402. * @param name defines the name of the mesh
  70403. * @param options defines the options used to create the mesh
  70404. * @param scene defines the hosting scene
  70405. * @returns the ground mesh
  70406. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70407. */
  70408. static CreateGround(name: string, options: {
  70409. width?: number;
  70410. height?: number;
  70411. subdivisions?: number;
  70412. subdivisionsX?: number;
  70413. subdivisionsY?: number;
  70414. updatable?: boolean;
  70415. }, scene?: Nullable<Scene>): Mesh;
  70416. /**
  70417. * Creates a tiled ground mesh
  70418. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70419. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70420. * * 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
  70421. * * 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
  70422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70423. * @param name defines the name of the mesh
  70424. * @param options defines the options used to create the mesh
  70425. * @param scene defines the hosting scene
  70426. * @returns the tiled ground mesh
  70427. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70428. */
  70429. static CreateTiledGround(name: string, options: {
  70430. xmin: number;
  70431. zmin: number;
  70432. xmax: number;
  70433. zmax: number;
  70434. subdivisions?: {
  70435. w: number;
  70436. h: number;
  70437. };
  70438. precision?: {
  70439. w: number;
  70440. h: number;
  70441. };
  70442. updatable?: boolean;
  70443. }, scene?: Nullable<Scene>): Mesh;
  70444. /**
  70445. * Creates a ground mesh from a height map
  70446. * * The parameter `url` sets the URL of the height map image resource.
  70447. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70448. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70449. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70450. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70451. * * 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.
  70452. * * 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).
  70453. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70455. * @param name defines the name of the mesh
  70456. * @param url defines the url to the height map
  70457. * @param options defines the options used to create the mesh
  70458. * @param scene defines the hosting scene
  70459. * @returns the ground mesh
  70460. * @see https://doc.babylonjs.com/babylon101/height_map
  70461. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70462. */
  70463. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70464. width?: number;
  70465. height?: number;
  70466. subdivisions?: number;
  70467. minHeight?: number;
  70468. maxHeight?: number;
  70469. colorFilter?: Color3;
  70470. alphaFilter?: number;
  70471. updatable?: boolean;
  70472. onReady?: (mesh: GroundMesh) => void;
  70473. }, scene?: Nullable<Scene>): GroundMesh;
  70474. /**
  70475. * Creates a polygon mesh
  70476. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70477. * * 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
  70478. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70480. * * 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)
  70481. * * Remember you can only change the shape positions, not their number when updating a polygon
  70482. * @param name defines the name of the mesh
  70483. * @param options defines the options used to create the mesh
  70484. * @param scene defines the hosting scene
  70485. * @param earcutInjection can be used to inject your own earcut reference
  70486. * @returns the polygon mesh
  70487. */
  70488. static CreatePolygon(name: string, options: {
  70489. shape: Vector3[];
  70490. holes?: Vector3[][];
  70491. depth?: number;
  70492. faceUV?: Vector4[];
  70493. faceColors?: Color4[];
  70494. updatable?: boolean;
  70495. sideOrientation?: number;
  70496. frontUVs?: Vector4;
  70497. backUVs?: Vector4;
  70498. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70499. /**
  70500. * Creates an extruded polygon mesh, with depth in the Y direction.
  70501. * * 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)
  70502. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70503. * @param name defines the name of the mesh
  70504. * @param options defines the options used to create the mesh
  70505. * @param scene defines the hosting scene
  70506. * @param earcutInjection can be used to inject your own earcut reference
  70507. * @returns the polygon mesh
  70508. */
  70509. static ExtrudePolygon(name: string, options: {
  70510. shape: Vector3[];
  70511. holes?: Vector3[][];
  70512. depth?: number;
  70513. faceUV?: Vector4[];
  70514. faceColors?: Color4[];
  70515. updatable?: boolean;
  70516. sideOrientation?: number;
  70517. frontUVs?: Vector4;
  70518. backUVs?: Vector4;
  70519. wrap?: boolean;
  70520. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70521. /**
  70522. * Creates a tube mesh.
  70523. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70524. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70525. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70526. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70527. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70528. * * 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)
  70529. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70530. * * 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
  70531. * * 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
  70532. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70533. * * 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
  70534. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70535. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70536. * @param name defines the name of the mesh
  70537. * @param options defines the options used to create the mesh
  70538. * @param scene defines the hosting scene
  70539. * @returns the tube mesh
  70540. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70541. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70542. */
  70543. static CreateTube(name: string, options: {
  70544. path: Vector3[];
  70545. radius?: number;
  70546. tessellation?: number;
  70547. radiusFunction?: {
  70548. (i: number, distance: number): number;
  70549. };
  70550. cap?: number;
  70551. arc?: number;
  70552. updatable?: boolean;
  70553. sideOrientation?: number;
  70554. frontUVs?: Vector4;
  70555. backUVs?: Vector4;
  70556. instance?: Mesh;
  70557. invertUV?: boolean;
  70558. }, scene?: Nullable<Scene>): Mesh;
  70559. /**
  70560. * Creates a polyhedron mesh
  70561. * * 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
  70562. * * The parameter `size` (positive float, default 1) sets the polygon size
  70563. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70564. * * 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`
  70565. * * 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
  70566. * * 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)`)
  70567. * * 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
  70568. * * 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
  70569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70570. * * 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
  70571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70572. * @param name defines the name of the mesh
  70573. * @param options defines the options used to create the mesh
  70574. * @param scene defines the hosting scene
  70575. * @returns the polyhedron mesh
  70576. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70577. */
  70578. static CreatePolyhedron(name: string, options: {
  70579. type?: number;
  70580. size?: number;
  70581. sizeX?: number;
  70582. sizeY?: number;
  70583. sizeZ?: number;
  70584. custom?: any;
  70585. faceUV?: Vector4[];
  70586. faceColors?: Color4[];
  70587. flat?: boolean;
  70588. updatable?: boolean;
  70589. sideOrientation?: number;
  70590. frontUVs?: Vector4;
  70591. backUVs?: Vector4;
  70592. }, scene?: Nullable<Scene>): Mesh;
  70593. /**
  70594. * Creates a decal mesh.
  70595. * 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
  70596. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70597. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70598. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70599. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70600. * @param name defines the name of the mesh
  70601. * @param sourceMesh defines the mesh where the decal must be applied
  70602. * @param options defines the options used to create the mesh
  70603. * @param scene defines the hosting scene
  70604. * @returns the decal mesh
  70605. * @see https://doc.babylonjs.com/how_to/decals
  70606. */
  70607. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70608. position?: Vector3;
  70609. normal?: Vector3;
  70610. size?: Vector3;
  70611. angle?: number;
  70612. }): Mesh;
  70613. /**
  70614. * Creates a Capsule Mesh
  70615. * @param name defines the name of the mesh.
  70616. * @param options the constructors options used to shape the mesh.
  70617. * @param scene defines the scene the mesh is scoped to.
  70618. * @returns the capsule mesh
  70619. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70620. */
  70621. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70622. }
  70623. }
  70624. declare module BABYLON {
  70625. /**
  70626. * A simplifier interface for future simplification implementations
  70627. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70628. */
  70629. export interface ISimplifier {
  70630. /**
  70631. * Simplification of a given mesh according to the given settings.
  70632. * Since this requires computation, it is assumed that the function runs async.
  70633. * @param settings The settings of the simplification, including quality and distance
  70634. * @param successCallback A callback that will be called after the mesh was simplified.
  70635. * @param errorCallback in case of an error, this callback will be called. optional.
  70636. */
  70637. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70638. }
  70639. /**
  70640. * Expected simplification settings.
  70641. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70642. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70643. */
  70644. export interface ISimplificationSettings {
  70645. /**
  70646. * Gets or sets the expected quality
  70647. */
  70648. quality: number;
  70649. /**
  70650. * Gets or sets the distance when this optimized version should be used
  70651. */
  70652. distance: number;
  70653. /**
  70654. * Gets an already optimized mesh
  70655. */
  70656. optimizeMesh?: boolean;
  70657. }
  70658. /**
  70659. * Class used to specify simplification options
  70660. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70661. */
  70662. export class SimplificationSettings implements ISimplificationSettings {
  70663. /** expected quality */
  70664. quality: number;
  70665. /** distance when this optimized version should be used */
  70666. distance: number;
  70667. /** already optimized mesh */
  70668. optimizeMesh?: boolean | undefined;
  70669. /**
  70670. * Creates a SimplificationSettings
  70671. * @param quality expected quality
  70672. * @param distance distance when this optimized version should be used
  70673. * @param optimizeMesh already optimized mesh
  70674. */
  70675. constructor(
  70676. /** expected quality */
  70677. quality: number,
  70678. /** distance when this optimized version should be used */
  70679. distance: number,
  70680. /** already optimized mesh */
  70681. optimizeMesh?: boolean | undefined);
  70682. }
  70683. /**
  70684. * Interface used to define a simplification task
  70685. */
  70686. export interface ISimplificationTask {
  70687. /**
  70688. * Array of settings
  70689. */
  70690. settings: Array<ISimplificationSettings>;
  70691. /**
  70692. * Simplification type
  70693. */
  70694. simplificationType: SimplificationType;
  70695. /**
  70696. * Mesh to simplify
  70697. */
  70698. mesh: Mesh;
  70699. /**
  70700. * Callback called on success
  70701. */
  70702. successCallback?: () => void;
  70703. /**
  70704. * Defines if parallel processing can be used
  70705. */
  70706. parallelProcessing: boolean;
  70707. }
  70708. /**
  70709. * Queue used to order the simplification tasks
  70710. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70711. */
  70712. export class SimplificationQueue {
  70713. private _simplificationArray;
  70714. /**
  70715. * Gets a boolean indicating that the process is still running
  70716. */
  70717. running: boolean;
  70718. /**
  70719. * Creates a new queue
  70720. */
  70721. constructor();
  70722. /**
  70723. * Adds a new simplification task
  70724. * @param task defines a task to add
  70725. */
  70726. addTask(task: ISimplificationTask): void;
  70727. /**
  70728. * Execute next task
  70729. */
  70730. executeNext(): void;
  70731. /**
  70732. * Execute a simplification task
  70733. * @param task defines the task to run
  70734. */
  70735. runSimplification(task: ISimplificationTask): void;
  70736. private getSimplifier;
  70737. }
  70738. /**
  70739. * The implemented types of simplification
  70740. * At the moment only Quadratic Error Decimation is implemented
  70741. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70742. */
  70743. export enum SimplificationType {
  70744. /** Quadratic error decimation */
  70745. QUADRATIC = 0
  70746. }
  70747. /**
  70748. * An implementation of the Quadratic Error simplification algorithm.
  70749. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70750. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70751. * @author RaananW
  70752. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70753. */
  70754. export class QuadraticErrorSimplification implements ISimplifier {
  70755. private _mesh;
  70756. private triangles;
  70757. private vertices;
  70758. private references;
  70759. private _reconstructedMesh;
  70760. /** Gets or sets the number pf sync interations */
  70761. syncIterations: number;
  70762. /** Gets or sets the aggressiveness of the simplifier */
  70763. aggressiveness: number;
  70764. /** Gets or sets the number of allowed iterations for decimation */
  70765. decimationIterations: number;
  70766. /** Gets or sets the espilon to use for bounding box computation */
  70767. boundingBoxEpsilon: number;
  70768. /**
  70769. * Creates a new QuadraticErrorSimplification
  70770. * @param _mesh defines the target mesh
  70771. */
  70772. constructor(_mesh: Mesh);
  70773. /**
  70774. * Simplification of a given mesh according to the given settings.
  70775. * Since this requires computation, it is assumed that the function runs async.
  70776. * @param settings The settings of the simplification, including quality and distance
  70777. * @param successCallback A callback that will be called after the mesh was simplified.
  70778. */
  70779. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70780. private runDecimation;
  70781. private initWithMesh;
  70782. private init;
  70783. private reconstructMesh;
  70784. private initDecimatedMesh;
  70785. private isFlipped;
  70786. private updateTriangles;
  70787. private identifyBorder;
  70788. private updateMesh;
  70789. private vertexError;
  70790. private calculateError;
  70791. }
  70792. }
  70793. declare module BABYLON {
  70794. interface Scene {
  70795. /** @hidden (Backing field) */
  70796. _simplificationQueue: SimplificationQueue;
  70797. /**
  70798. * Gets or sets the simplification queue attached to the scene
  70799. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70800. */
  70801. simplificationQueue: SimplificationQueue;
  70802. }
  70803. interface Mesh {
  70804. /**
  70805. * Simplify the mesh according to the given array of settings.
  70806. * Function will return immediately and will simplify async
  70807. * @param settings a collection of simplification settings
  70808. * @param parallelProcessing should all levels calculate parallel or one after the other
  70809. * @param simplificationType the type of simplification to run
  70810. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70811. * @returns the current mesh
  70812. */
  70813. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70814. }
  70815. /**
  70816. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70817. * created in a scene
  70818. */
  70819. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70820. /**
  70821. * The component name helpfull to identify the component in the list of scene components.
  70822. */
  70823. readonly name: string;
  70824. /**
  70825. * The scene the component belongs to.
  70826. */
  70827. scene: Scene;
  70828. /**
  70829. * Creates a new instance of the component for the given scene
  70830. * @param scene Defines the scene to register the component in
  70831. */
  70832. constructor(scene: Scene);
  70833. /**
  70834. * Registers the component in a given scene
  70835. */
  70836. register(): void;
  70837. /**
  70838. * Rebuilds the elements related to this component in case of
  70839. * context lost for instance.
  70840. */
  70841. rebuild(): void;
  70842. /**
  70843. * Disposes the component and the associated ressources
  70844. */
  70845. dispose(): void;
  70846. private _beforeCameraUpdate;
  70847. }
  70848. }
  70849. declare module BABYLON {
  70850. interface Mesh {
  70851. /**
  70852. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70853. */
  70854. thinInstanceEnablePicking: boolean;
  70855. /**
  70856. * Creates a new thin instance
  70857. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70858. * @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
  70859. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70860. */
  70861. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70862. /**
  70863. * Adds the transformation (matrix) of the current mesh as a thin instance
  70864. * @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
  70865. * @returns the thin instance index number
  70866. */
  70867. thinInstanceAddSelf(refresh: boolean): number;
  70868. /**
  70869. * Registers a custom attribute to be used with thin instances
  70870. * @param kind name of the attribute
  70871. * @param stride size in floats of the attribute
  70872. */
  70873. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70874. /**
  70875. * Sets the matrix of a thin instance
  70876. * @param index index of the thin instance
  70877. * @param matrix matrix to set
  70878. * @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
  70879. */
  70880. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70881. /**
  70882. * Sets the value of a custom attribute for a thin instance
  70883. * @param kind name of the attribute
  70884. * @param index index of the thin instance
  70885. * @param value value to set
  70886. * @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
  70887. */
  70888. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70889. /**
  70890. * 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.
  70891. */
  70892. thinInstanceCount: number;
  70893. /**
  70894. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70895. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70896. * @param buffer buffer to set
  70897. * @param stride size in floats of each value of the buffer
  70898. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70899. */
  70900. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70901. /**
  70902. * Gets the list of world matrices
  70903. * @return an array containing all the world matrices from the thin instances
  70904. */
  70905. thinInstanceGetWorldMatrices(): Matrix[];
  70906. /**
  70907. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70908. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70909. */
  70910. thinInstanceBufferUpdated(kind: string): void;
  70911. /**
  70912. * Applies a partial update to a buffer directly on the GPU
  70913. * 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
  70914. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70915. * @param data the data to set in the GPU buffer
  70916. * @param offset the offset in the GPU buffer where to update the data
  70917. */
  70918. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70919. /**
  70920. * Refreshes the bounding info, taking into account all the thin instances defined
  70921. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70922. */
  70923. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70924. /** @hidden */
  70925. _thinInstanceInitializeUserStorage(): void;
  70926. /** @hidden */
  70927. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70928. /** @hidden */
  70929. _userThinInstanceBuffersStorage: {
  70930. data: {
  70931. [key: string]: Float32Array;
  70932. };
  70933. sizes: {
  70934. [key: string]: number;
  70935. };
  70936. vertexBuffers: {
  70937. [key: string]: Nullable<VertexBuffer>;
  70938. };
  70939. strides: {
  70940. [key: string]: number;
  70941. };
  70942. };
  70943. }
  70944. }
  70945. declare module BABYLON {
  70946. /**
  70947. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70948. */
  70949. export interface INavigationEnginePlugin {
  70950. /**
  70951. * plugin name
  70952. */
  70953. name: string;
  70954. /**
  70955. * Creates a navigation mesh
  70956. * @param meshes array of all the geometry used to compute the navigatio mesh
  70957. * @param parameters bunch of parameters used to filter geometry
  70958. */
  70959. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70960. /**
  70961. * Create a navigation mesh debug mesh
  70962. * @param scene is where the mesh will be added
  70963. * @returns debug display mesh
  70964. */
  70965. createDebugNavMesh(scene: Scene): Mesh;
  70966. /**
  70967. * Get a navigation mesh constrained position, closest to the parameter position
  70968. * @param position world position
  70969. * @returns the closest point to position constrained by the navigation mesh
  70970. */
  70971. getClosestPoint(position: Vector3): Vector3;
  70972. /**
  70973. * Get a navigation mesh constrained position, closest to the parameter position
  70974. * @param position world position
  70975. * @param result output the closest point to position constrained by the navigation mesh
  70976. */
  70977. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70978. /**
  70979. * Get a navigation mesh constrained position, within a particular radius
  70980. * @param position world position
  70981. * @param maxRadius the maximum distance to the constrained world position
  70982. * @returns the closest point to position constrained by the navigation mesh
  70983. */
  70984. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70985. /**
  70986. * Get a navigation mesh constrained position, within a particular radius
  70987. * @param position world position
  70988. * @param maxRadius the maximum distance to the constrained world position
  70989. * @param result output the closest point to position constrained by the navigation mesh
  70990. */
  70991. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70992. /**
  70993. * Compute the final position from a segment made of destination-position
  70994. * @param position world position
  70995. * @param destination world position
  70996. * @returns the resulting point along the navmesh
  70997. */
  70998. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70999. /**
  71000. * Compute the final position from a segment made of destination-position
  71001. * @param position world position
  71002. * @param destination world position
  71003. * @param result output the resulting point along the navmesh
  71004. */
  71005. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71006. /**
  71007. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71008. * @param start world position
  71009. * @param end world position
  71010. * @returns array containing world position composing the path
  71011. */
  71012. computePath(start: Vector3, end: Vector3): Vector3[];
  71013. /**
  71014. * If this plugin is supported
  71015. * @returns true if plugin is supported
  71016. */
  71017. isSupported(): boolean;
  71018. /**
  71019. * Create a new Crowd so you can add agents
  71020. * @param maxAgents the maximum agent count in the crowd
  71021. * @param maxAgentRadius the maximum radius an agent can have
  71022. * @param scene to attach the crowd to
  71023. * @returns the crowd you can add agents to
  71024. */
  71025. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71026. /**
  71027. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71028. * The queries will try to find a solution within those bounds
  71029. * default is (1,1,1)
  71030. * @param extent x,y,z value that define the extent around the queries point of reference
  71031. */
  71032. setDefaultQueryExtent(extent: Vector3): void;
  71033. /**
  71034. * Get the Bounding box extent specified by setDefaultQueryExtent
  71035. * @returns the box extent values
  71036. */
  71037. getDefaultQueryExtent(): Vector3;
  71038. /**
  71039. * build the navmesh from a previously saved state using getNavmeshData
  71040. * @param data the Uint8Array returned by getNavmeshData
  71041. */
  71042. buildFromNavmeshData(data: Uint8Array): void;
  71043. /**
  71044. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71045. * @returns data the Uint8Array that can be saved and reused
  71046. */
  71047. getNavmeshData(): Uint8Array;
  71048. /**
  71049. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71050. * @param result output the box extent values
  71051. */
  71052. getDefaultQueryExtentToRef(result: Vector3): void;
  71053. /**
  71054. * Set the time step of the navigation tick update.
  71055. * Default is 1/60.
  71056. * A value of 0 will disable fixed time update
  71057. * @param newTimeStep the new timestep to apply to this world.
  71058. */
  71059. setTimeStep(newTimeStep: number): void;
  71060. /**
  71061. * Get the time step of the navigation tick update.
  71062. * @returns the current time step
  71063. */
  71064. getTimeStep(): number;
  71065. /**
  71066. * If delta time in navigation tick update is greater than the time step
  71067. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71068. * they will be discarded.
  71069. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71070. * @param newStepCount the maximum number of iterations
  71071. */
  71072. setMaximumSubStepCount(newStepCount: number): void;
  71073. /**
  71074. * Get the maximum number of iterations per navigation tick update
  71075. * @returns the maximum number of iterations
  71076. */
  71077. getMaximumSubStepCount(): number;
  71078. /**
  71079. * Release all resources
  71080. */
  71081. dispose(): void;
  71082. }
  71083. /**
  71084. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71085. */
  71086. export interface ICrowd {
  71087. /**
  71088. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71089. * You can attach anything to that node. The node position is updated in the scene update tick.
  71090. * @param pos world position that will be constrained by the navigation mesh
  71091. * @param parameters agent parameters
  71092. * @param transform hooked to the agent that will be update by the scene
  71093. * @returns agent index
  71094. */
  71095. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71096. /**
  71097. * Returns the agent position in world space
  71098. * @param index agent index returned by addAgent
  71099. * @returns world space position
  71100. */
  71101. getAgentPosition(index: number): Vector3;
  71102. /**
  71103. * Gets the agent position result in world space
  71104. * @param index agent index returned by addAgent
  71105. * @param result output world space position
  71106. */
  71107. getAgentPositionToRef(index: number, result: Vector3): void;
  71108. /**
  71109. * Gets the agent velocity in world space
  71110. * @param index agent index returned by addAgent
  71111. * @returns world space velocity
  71112. */
  71113. getAgentVelocity(index: number): Vector3;
  71114. /**
  71115. * Gets the agent velocity result in world space
  71116. * @param index agent index returned by addAgent
  71117. * @param result output world space velocity
  71118. */
  71119. getAgentVelocityToRef(index: number, result: Vector3): void;
  71120. /**
  71121. * Gets the agent next target point on the path
  71122. * @param index agent index returned by addAgent
  71123. * @returns world space position
  71124. */
  71125. getAgentNextTargetPath(index: number): Vector3;
  71126. /**
  71127. * Gets the agent state
  71128. * @param index agent index returned by addAgent
  71129. * @returns agent state
  71130. */
  71131. getAgentState(index: number): number;
  71132. /**
  71133. * returns true if the agent in over an off mesh link connection
  71134. * @param index agent index returned by addAgent
  71135. * @returns true if over an off mesh link connection
  71136. */
  71137. overOffmeshConnection(index: number): boolean;
  71138. /**
  71139. * Gets the agent next target point on the path
  71140. * @param index agent index returned by addAgent
  71141. * @param result output world space position
  71142. */
  71143. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71144. /**
  71145. * remove a particular agent previously created
  71146. * @param index agent index returned by addAgent
  71147. */
  71148. removeAgent(index: number): void;
  71149. /**
  71150. * get the list of all agents attached to this crowd
  71151. * @returns list of agent indices
  71152. */
  71153. getAgents(): number[];
  71154. /**
  71155. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71156. * @param deltaTime in seconds
  71157. */
  71158. update(deltaTime: number): void;
  71159. /**
  71160. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71161. * @param index agent index returned by addAgent
  71162. * @param destination targeted world position
  71163. */
  71164. agentGoto(index: number, destination: Vector3): void;
  71165. /**
  71166. * Teleport the agent to a new position
  71167. * @param index agent index returned by addAgent
  71168. * @param destination targeted world position
  71169. */
  71170. agentTeleport(index: number, destination: Vector3): void;
  71171. /**
  71172. * Update agent parameters
  71173. * @param index agent index returned by addAgent
  71174. * @param parameters agent parameters
  71175. */
  71176. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71177. /**
  71178. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71179. * The queries will try to find a solution within those bounds
  71180. * default is (1,1,1)
  71181. * @param extent x,y,z value that define the extent around the queries point of reference
  71182. */
  71183. setDefaultQueryExtent(extent: Vector3): void;
  71184. /**
  71185. * Get the Bounding box extent specified by setDefaultQueryExtent
  71186. * @returns the box extent values
  71187. */
  71188. getDefaultQueryExtent(): Vector3;
  71189. /**
  71190. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71191. * @param result output the box extent values
  71192. */
  71193. getDefaultQueryExtentToRef(result: Vector3): void;
  71194. /**
  71195. * Release all resources
  71196. */
  71197. dispose(): void;
  71198. }
  71199. /**
  71200. * Configures an agent
  71201. */
  71202. export interface IAgentParameters {
  71203. /**
  71204. * Agent radius. [Limit: >= 0]
  71205. */
  71206. radius: number;
  71207. /**
  71208. * Agent height. [Limit: > 0]
  71209. */
  71210. height: number;
  71211. /**
  71212. * Maximum allowed acceleration. [Limit: >= 0]
  71213. */
  71214. maxAcceleration: number;
  71215. /**
  71216. * Maximum allowed speed. [Limit: >= 0]
  71217. */
  71218. maxSpeed: number;
  71219. /**
  71220. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71221. */
  71222. collisionQueryRange: number;
  71223. /**
  71224. * The path visibility optimization range. [Limit: > 0]
  71225. */
  71226. pathOptimizationRange: number;
  71227. /**
  71228. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71229. */
  71230. separationWeight: number;
  71231. }
  71232. /**
  71233. * Configures the navigation mesh creation
  71234. */
  71235. export interface INavMeshParameters {
  71236. /**
  71237. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71238. */
  71239. cs: number;
  71240. /**
  71241. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71242. */
  71243. ch: number;
  71244. /**
  71245. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71246. */
  71247. walkableSlopeAngle: number;
  71248. /**
  71249. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71250. * be considered walkable. [Limit: >= 3] [Units: vx]
  71251. */
  71252. walkableHeight: number;
  71253. /**
  71254. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71255. */
  71256. walkableClimb: number;
  71257. /**
  71258. * The distance to erode/shrink the walkable area of the heightfield away from
  71259. * obstructions. [Limit: >=0] [Units: vx]
  71260. */
  71261. walkableRadius: number;
  71262. /**
  71263. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71264. */
  71265. maxEdgeLen: number;
  71266. /**
  71267. * The maximum distance a simplfied contour's border edges should deviate
  71268. * the original raw contour. [Limit: >=0] [Units: vx]
  71269. */
  71270. maxSimplificationError: number;
  71271. /**
  71272. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71273. */
  71274. minRegionArea: number;
  71275. /**
  71276. * Any regions with a span count smaller than this value will, if possible,
  71277. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71278. */
  71279. mergeRegionArea: number;
  71280. /**
  71281. * The maximum number of vertices allowed for polygons generated during the
  71282. * contour to polygon conversion process. [Limit: >= 3]
  71283. */
  71284. maxVertsPerPoly: number;
  71285. /**
  71286. * Sets the sampling distance to use when generating the detail mesh.
  71287. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71288. */
  71289. detailSampleDist: number;
  71290. /**
  71291. * The maximum distance the detail mesh surface should deviate from heightfield
  71292. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71293. */
  71294. detailSampleMaxError: number;
  71295. }
  71296. }
  71297. declare module BABYLON {
  71298. /**
  71299. * RecastJS navigation plugin
  71300. */
  71301. export class RecastJSPlugin implements INavigationEnginePlugin {
  71302. /**
  71303. * Reference to the Recast library
  71304. */
  71305. bjsRECAST: any;
  71306. /**
  71307. * plugin name
  71308. */
  71309. name: string;
  71310. /**
  71311. * the first navmesh created. We might extend this to support multiple navmeshes
  71312. */
  71313. navMesh: any;
  71314. private _maximumSubStepCount;
  71315. private _timeStep;
  71316. /**
  71317. * Initializes the recastJS plugin
  71318. * @param recastInjection can be used to inject your own recast reference
  71319. */
  71320. constructor(recastInjection?: any);
  71321. /**
  71322. * Set the time step of the navigation tick update.
  71323. * Default is 1/60.
  71324. * A value of 0 will disable fixed time update
  71325. * @param newTimeStep the new timestep to apply to this world.
  71326. */
  71327. setTimeStep(newTimeStep?: number): void;
  71328. /**
  71329. * Get the time step of the navigation tick update.
  71330. * @returns the current time step
  71331. */
  71332. getTimeStep(): number;
  71333. /**
  71334. * If delta time in navigation tick update is greater than the time step
  71335. * a number of sub iterations are done. If more iterations are need to reach deltatime
  71336. * they will be discarded.
  71337. * A value of 0 will set to no maximum and update will use as many substeps as needed
  71338. * @param newStepCount the maximum number of iterations
  71339. */
  71340. setMaximumSubStepCount(newStepCount?: number): void;
  71341. /**
  71342. * Get the maximum number of iterations per navigation tick update
  71343. * @returns the maximum number of iterations
  71344. */
  71345. getMaximumSubStepCount(): number;
  71346. /**
  71347. * Creates a navigation mesh
  71348. * @param meshes array of all the geometry used to compute the navigatio mesh
  71349. * @param parameters bunch of parameters used to filter geometry
  71350. */
  71351. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71352. /**
  71353. * Create a navigation mesh debug mesh
  71354. * @param scene is where the mesh will be added
  71355. * @returns debug display mesh
  71356. */
  71357. createDebugNavMesh(scene: Scene): Mesh;
  71358. /**
  71359. * Get a navigation mesh constrained position, closest to the parameter position
  71360. * @param position world position
  71361. * @returns the closest point to position constrained by the navigation mesh
  71362. */
  71363. getClosestPoint(position: Vector3): Vector3;
  71364. /**
  71365. * Get a navigation mesh constrained position, closest to the parameter position
  71366. * @param position world position
  71367. * @param result output the closest point to position constrained by the navigation mesh
  71368. */
  71369. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71370. /**
  71371. * Get a navigation mesh constrained position, within a particular radius
  71372. * @param position world position
  71373. * @param maxRadius the maximum distance to the constrained world position
  71374. * @returns the closest point to position constrained by the navigation mesh
  71375. */
  71376. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71377. /**
  71378. * Get a navigation mesh constrained position, within a particular radius
  71379. * @param position world position
  71380. * @param maxRadius the maximum distance to the constrained world position
  71381. * @param result output the closest point to position constrained by the navigation mesh
  71382. */
  71383. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71384. /**
  71385. * Compute the final position from a segment made of destination-position
  71386. * @param position world position
  71387. * @param destination world position
  71388. * @returns the resulting point along the navmesh
  71389. */
  71390. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71391. /**
  71392. * Compute the final position from a segment made of destination-position
  71393. * @param position world position
  71394. * @param destination world position
  71395. * @param result output the resulting point along the navmesh
  71396. */
  71397. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71398. /**
  71399. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71400. * @param start world position
  71401. * @param end world position
  71402. * @returns array containing world position composing the path
  71403. */
  71404. computePath(start: Vector3, end: Vector3): Vector3[];
  71405. /**
  71406. * Create a new Crowd so you can add agents
  71407. * @param maxAgents the maximum agent count in the crowd
  71408. * @param maxAgentRadius the maximum radius an agent can have
  71409. * @param scene to attach the crowd to
  71410. * @returns the crowd you can add agents to
  71411. */
  71412. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71413. /**
  71414. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71415. * The queries will try to find a solution within those bounds
  71416. * default is (1,1,1)
  71417. * @param extent x,y,z value that define the extent around the queries point of reference
  71418. */
  71419. setDefaultQueryExtent(extent: Vector3): void;
  71420. /**
  71421. * Get the Bounding box extent specified by setDefaultQueryExtent
  71422. * @returns the box extent values
  71423. */
  71424. getDefaultQueryExtent(): Vector3;
  71425. /**
  71426. * build the navmesh from a previously saved state using getNavmeshData
  71427. * @param data the Uint8Array returned by getNavmeshData
  71428. */
  71429. buildFromNavmeshData(data: Uint8Array): void;
  71430. /**
  71431. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71432. * @returns data the Uint8Array that can be saved and reused
  71433. */
  71434. getNavmeshData(): Uint8Array;
  71435. /**
  71436. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71437. * @param result output the box extent values
  71438. */
  71439. getDefaultQueryExtentToRef(result: Vector3): void;
  71440. /**
  71441. * Disposes
  71442. */
  71443. dispose(): void;
  71444. /**
  71445. * If this plugin is supported
  71446. * @returns true if plugin is supported
  71447. */
  71448. isSupported(): boolean;
  71449. }
  71450. /**
  71451. * Recast detour crowd implementation
  71452. */
  71453. export class RecastJSCrowd implements ICrowd {
  71454. /**
  71455. * Recast/detour plugin
  71456. */
  71457. bjsRECASTPlugin: RecastJSPlugin;
  71458. /**
  71459. * Link to the detour crowd
  71460. */
  71461. recastCrowd: any;
  71462. /**
  71463. * One transform per agent
  71464. */
  71465. transforms: TransformNode[];
  71466. /**
  71467. * All agents created
  71468. */
  71469. agents: number[];
  71470. /**
  71471. * Link to the scene is kept to unregister the crowd from the scene
  71472. */
  71473. private _scene;
  71474. /**
  71475. * Observer for crowd updates
  71476. */
  71477. private _onBeforeAnimationsObserver;
  71478. /**
  71479. * Constructor
  71480. * @param plugin recastJS plugin
  71481. * @param maxAgents the maximum agent count in the crowd
  71482. * @param maxAgentRadius the maximum radius an agent can have
  71483. * @param scene to attach the crowd to
  71484. * @returns the crowd you can add agents to
  71485. */
  71486. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71487. /**
  71488. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71489. * You can attach anything to that node. The node position is updated in the scene update tick.
  71490. * @param pos world position that will be constrained by the navigation mesh
  71491. * @param parameters agent parameters
  71492. * @param transform hooked to the agent that will be update by the scene
  71493. * @returns agent index
  71494. */
  71495. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71496. /**
  71497. * Returns the agent position in world space
  71498. * @param index agent index returned by addAgent
  71499. * @returns world space position
  71500. */
  71501. getAgentPosition(index: number): Vector3;
  71502. /**
  71503. * Returns the agent position result in world space
  71504. * @param index agent index returned by addAgent
  71505. * @param result output world space position
  71506. */
  71507. getAgentPositionToRef(index: number, result: Vector3): void;
  71508. /**
  71509. * Returns the agent velocity in world space
  71510. * @param index agent index returned by addAgent
  71511. * @returns world space velocity
  71512. */
  71513. getAgentVelocity(index: number): Vector3;
  71514. /**
  71515. * Returns the agent velocity result in world space
  71516. * @param index agent index returned by addAgent
  71517. * @param result output world space velocity
  71518. */
  71519. getAgentVelocityToRef(index: number, result: Vector3): void;
  71520. /**
  71521. * Returns the agent next target point on the path
  71522. * @param index agent index returned by addAgent
  71523. * @returns world space position
  71524. */
  71525. getAgentNextTargetPath(index: number): Vector3;
  71526. /**
  71527. * Returns the agent next target point on the path
  71528. * @param index agent index returned by addAgent
  71529. * @param result output world space position
  71530. */
  71531. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71532. /**
  71533. * Gets the agent state
  71534. * @param index agent index returned by addAgent
  71535. * @returns agent state
  71536. */
  71537. getAgentState(index: number): number;
  71538. /**
  71539. * returns true if the agent in over an off mesh link connection
  71540. * @param index agent index returned by addAgent
  71541. * @returns true if over an off mesh link connection
  71542. */
  71543. overOffmeshConnection(index: number): boolean;
  71544. /**
  71545. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71546. * @param index agent index returned by addAgent
  71547. * @param destination targeted world position
  71548. */
  71549. agentGoto(index: number, destination: Vector3): void;
  71550. /**
  71551. * Teleport the agent to a new position
  71552. * @param index agent index returned by addAgent
  71553. * @param destination targeted world position
  71554. */
  71555. agentTeleport(index: number, destination: Vector3): void;
  71556. /**
  71557. * Update agent parameters
  71558. * @param index agent index returned by addAgent
  71559. * @param parameters agent parameters
  71560. */
  71561. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71562. /**
  71563. * remove a particular agent previously created
  71564. * @param index agent index returned by addAgent
  71565. */
  71566. removeAgent(index: number): void;
  71567. /**
  71568. * get the list of all agents attached to this crowd
  71569. * @returns list of agent indices
  71570. */
  71571. getAgents(): number[];
  71572. /**
  71573. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71574. * @param deltaTime in seconds
  71575. */
  71576. update(deltaTime: number): void;
  71577. /**
  71578. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71579. * The queries will try to find a solution within those bounds
  71580. * default is (1,1,1)
  71581. * @param extent x,y,z value that define the extent around the queries point of reference
  71582. */
  71583. setDefaultQueryExtent(extent: Vector3): void;
  71584. /**
  71585. * Get the Bounding box extent specified by setDefaultQueryExtent
  71586. * @returns the box extent values
  71587. */
  71588. getDefaultQueryExtent(): Vector3;
  71589. /**
  71590. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71591. * @param result output the box extent values
  71592. */
  71593. getDefaultQueryExtentToRef(result: Vector3): void;
  71594. /**
  71595. * Release all resources
  71596. */
  71597. dispose(): void;
  71598. }
  71599. }
  71600. declare module BABYLON {
  71601. /**
  71602. * Class used to enable access to IndexedDB
  71603. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71604. */
  71605. export class Database implements IOfflineProvider {
  71606. private _callbackManifestChecked;
  71607. private _currentSceneUrl;
  71608. private _db;
  71609. private _enableSceneOffline;
  71610. private _enableTexturesOffline;
  71611. private _manifestVersionFound;
  71612. private _mustUpdateRessources;
  71613. private _hasReachedQuota;
  71614. private _isSupported;
  71615. private _idbFactory;
  71616. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71617. private static IsUASupportingBlobStorage;
  71618. /**
  71619. * Gets a boolean indicating if Database storate is enabled (off by default)
  71620. */
  71621. static IDBStorageEnabled: boolean;
  71622. /**
  71623. * Gets a boolean indicating if scene must be saved in the database
  71624. */
  71625. get enableSceneOffline(): boolean;
  71626. /**
  71627. * Gets a boolean indicating if textures must be saved in the database
  71628. */
  71629. get enableTexturesOffline(): boolean;
  71630. /**
  71631. * Creates a new Database
  71632. * @param urlToScene defines the url to load the scene
  71633. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71634. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71635. */
  71636. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71637. private static _ParseURL;
  71638. private static _ReturnFullUrlLocation;
  71639. private _checkManifestFile;
  71640. /**
  71641. * Open the database and make it available
  71642. * @param successCallback defines the callback to call on success
  71643. * @param errorCallback defines the callback to call on error
  71644. */
  71645. open(successCallback: () => void, errorCallback: () => void): void;
  71646. /**
  71647. * Loads an image from the database
  71648. * @param url defines the url to load from
  71649. * @param image defines the target DOM image
  71650. */
  71651. loadImage(url: string, image: HTMLImageElement): void;
  71652. private _loadImageFromDBAsync;
  71653. private _saveImageIntoDBAsync;
  71654. private _checkVersionFromDB;
  71655. private _loadVersionFromDBAsync;
  71656. private _saveVersionIntoDBAsync;
  71657. /**
  71658. * Loads a file from database
  71659. * @param url defines the URL to load from
  71660. * @param sceneLoaded defines a callback to call on success
  71661. * @param progressCallBack defines a callback to call when progress changed
  71662. * @param errorCallback defines a callback to call on error
  71663. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71664. */
  71665. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71666. private _loadFileAsync;
  71667. private _saveFileAsync;
  71668. /**
  71669. * Validates if xhr data is correct
  71670. * @param xhr defines the request to validate
  71671. * @param dataType defines the expected data type
  71672. * @returns true if data is correct
  71673. */
  71674. private static _ValidateXHRData;
  71675. }
  71676. }
  71677. declare module BABYLON {
  71678. /** @hidden */
  71679. export var gpuUpdateParticlesPixelShader: {
  71680. name: string;
  71681. shader: string;
  71682. };
  71683. }
  71684. declare module BABYLON {
  71685. /** @hidden */
  71686. export var gpuUpdateParticlesVertexShader: {
  71687. name: string;
  71688. shader: string;
  71689. };
  71690. }
  71691. declare module BABYLON {
  71692. /** @hidden */
  71693. export var clipPlaneFragmentDeclaration2: {
  71694. name: string;
  71695. shader: string;
  71696. };
  71697. }
  71698. declare module BABYLON {
  71699. /** @hidden */
  71700. export var gpuRenderParticlesPixelShader: {
  71701. name: string;
  71702. shader: string;
  71703. };
  71704. }
  71705. declare module BABYLON {
  71706. /** @hidden */
  71707. export var clipPlaneVertexDeclaration2: {
  71708. name: string;
  71709. shader: string;
  71710. };
  71711. }
  71712. declare module BABYLON {
  71713. /** @hidden */
  71714. export var gpuRenderParticlesVertexShader: {
  71715. name: string;
  71716. shader: string;
  71717. };
  71718. }
  71719. declare module BABYLON {
  71720. /**
  71721. * This represents a GPU particle system in Babylon
  71722. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71723. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71724. */
  71725. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71726. /**
  71727. * The layer mask we are rendering the particles through.
  71728. */
  71729. layerMask: number;
  71730. private _capacity;
  71731. private _activeCount;
  71732. private _currentActiveCount;
  71733. private _accumulatedCount;
  71734. private _renderEffect;
  71735. private _updateEffect;
  71736. private _buffer0;
  71737. private _buffer1;
  71738. private _spriteBuffer;
  71739. private _updateVAO;
  71740. private _renderVAO;
  71741. private _targetIndex;
  71742. private _sourceBuffer;
  71743. private _targetBuffer;
  71744. private _currentRenderId;
  71745. private _started;
  71746. private _stopped;
  71747. private _timeDelta;
  71748. private _randomTexture;
  71749. private _randomTexture2;
  71750. private _attributesStrideSize;
  71751. private _updateEffectOptions;
  71752. private _randomTextureSize;
  71753. private _actualFrame;
  71754. private _customEffect;
  71755. private readonly _rawTextureWidth;
  71756. /**
  71757. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71758. */
  71759. static get IsSupported(): boolean;
  71760. /**
  71761. * An event triggered when the system is disposed.
  71762. */
  71763. onDisposeObservable: Observable<IParticleSystem>;
  71764. /**
  71765. * An event triggered when the system is stopped
  71766. */
  71767. onStoppedObservable: Observable<IParticleSystem>;
  71768. /**
  71769. * Gets the maximum number of particles active at the same time.
  71770. * @returns The max number of active particles.
  71771. */
  71772. getCapacity(): number;
  71773. /**
  71774. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71775. * to override the particles.
  71776. */
  71777. forceDepthWrite: boolean;
  71778. /**
  71779. * Gets or set the number of active particles
  71780. */
  71781. get activeParticleCount(): number;
  71782. set activeParticleCount(value: number);
  71783. private _preWarmDone;
  71784. /**
  71785. * Specifies if the particles are updated in emitter local space or world space.
  71786. */
  71787. isLocal: boolean;
  71788. /** Gets or sets a matrix to use to compute projection */
  71789. defaultProjectionMatrix: Matrix;
  71790. /**
  71791. * Is this system ready to be used/rendered
  71792. * @return true if the system is ready
  71793. */
  71794. isReady(): boolean;
  71795. /**
  71796. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71797. * @returns True if it has been started, otherwise false.
  71798. */
  71799. isStarted(): boolean;
  71800. /**
  71801. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71802. * @returns True if it has been stopped, otherwise false.
  71803. */
  71804. isStopped(): boolean;
  71805. /**
  71806. * Gets a boolean indicating that the system is stopping
  71807. * @returns true if the system is currently stopping
  71808. */
  71809. isStopping(): boolean;
  71810. /**
  71811. * Gets the number of particles active at the same time.
  71812. * @returns The number of active particles.
  71813. */
  71814. getActiveCount(): number;
  71815. /**
  71816. * Starts the particle system and begins to emit
  71817. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71818. */
  71819. start(delay?: number): void;
  71820. /**
  71821. * Stops the particle system.
  71822. */
  71823. stop(): void;
  71824. /**
  71825. * Remove all active particles
  71826. */
  71827. reset(): void;
  71828. /**
  71829. * Returns the string "GPUParticleSystem"
  71830. * @returns a string containing the class name
  71831. */
  71832. getClassName(): string;
  71833. /**
  71834. * Gets the custom effect used to render the particles
  71835. * @param blendMode Blend mode for which the effect should be retrieved
  71836. * @returns The effect
  71837. */
  71838. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71839. /**
  71840. * Sets the custom effect used to render the particles
  71841. * @param effect The effect to set
  71842. * @param blendMode Blend mode for which the effect should be set
  71843. */
  71844. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71845. /** @hidden */
  71846. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71847. /**
  71848. * Observable that will be called just before the particles are drawn
  71849. */
  71850. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71851. /**
  71852. * Gets the name of the particle vertex shader
  71853. */
  71854. get vertexShaderName(): string;
  71855. private _colorGradientsTexture;
  71856. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71857. /**
  71858. * Adds a new color gradient
  71859. * @param gradient defines the gradient to use (between 0 and 1)
  71860. * @param color1 defines the color to affect to the specified gradient
  71861. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71862. * @returns the current particle system
  71863. */
  71864. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71865. private _refreshColorGradient;
  71866. /** Force the system to rebuild all gradients that need to be resync */
  71867. forceRefreshGradients(): void;
  71868. /**
  71869. * Remove a specific color gradient
  71870. * @param gradient defines the gradient to remove
  71871. * @returns the current particle system
  71872. */
  71873. removeColorGradient(gradient: number): GPUParticleSystem;
  71874. private _angularSpeedGradientsTexture;
  71875. private _sizeGradientsTexture;
  71876. private _velocityGradientsTexture;
  71877. private _limitVelocityGradientsTexture;
  71878. private _dragGradientsTexture;
  71879. private _addFactorGradient;
  71880. /**
  71881. * Adds a new size gradient
  71882. * @param gradient defines the gradient to use (between 0 and 1)
  71883. * @param factor defines the size factor to affect to the specified gradient
  71884. * @returns the current particle system
  71885. */
  71886. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71887. /**
  71888. * Remove a specific size gradient
  71889. * @param gradient defines the gradient to remove
  71890. * @returns the current particle system
  71891. */
  71892. removeSizeGradient(gradient: number): GPUParticleSystem;
  71893. private _refreshFactorGradient;
  71894. /**
  71895. * Adds a new angular speed gradient
  71896. * @param gradient defines the gradient to use (between 0 and 1)
  71897. * @param factor defines the angular speed to affect to the specified gradient
  71898. * @returns the current particle system
  71899. */
  71900. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71901. /**
  71902. * Remove a specific angular speed gradient
  71903. * @param gradient defines the gradient to remove
  71904. * @returns the current particle system
  71905. */
  71906. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71907. /**
  71908. * Adds a new velocity gradient
  71909. * @param gradient defines the gradient to use (between 0 and 1)
  71910. * @param factor defines the velocity to affect to the specified gradient
  71911. * @returns the current particle system
  71912. */
  71913. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71914. /**
  71915. * Remove a specific velocity gradient
  71916. * @param gradient defines the gradient to remove
  71917. * @returns the current particle system
  71918. */
  71919. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71920. /**
  71921. * Adds a new limit velocity gradient
  71922. * @param gradient defines the gradient to use (between 0 and 1)
  71923. * @param factor defines the limit velocity value to affect to the specified gradient
  71924. * @returns the current particle system
  71925. */
  71926. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71927. /**
  71928. * Remove a specific limit velocity gradient
  71929. * @param gradient defines the gradient to remove
  71930. * @returns the current particle system
  71931. */
  71932. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71933. /**
  71934. * Adds a new drag gradient
  71935. * @param gradient defines the gradient to use (between 0 and 1)
  71936. * @param factor defines the drag value to affect to the specified gradient
  71937. * @returns the current particle system
  71938. */
  71939. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71940. /**
  71941. * Remove a specific drag gradient
  71942. * @param gradient defines the gradient to remove
  71943. * @returns the current particle system
  71944. */
  71945. removeDragGradient(gradient: number): GPUParticleSystem;
  71946. /**
  71947. * Not supported by GPUParticleSystem
  71948. * @param gradient defines the gradient to use (between 0 and 1)
  71949. * @param factor defines the emit rate value to affect to the specified gradient
  71950. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71951. * @returns the current particle system
  71952. */
  71953. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71954. /**
  71955. * Not supported by GPUParticleSystem
  71956. * @param gradient defines the gradient to remove
  71957. * @returns the current particle system
  71958. */
  71959. removeEmitRateGradient(gradient: number): IParticleSystem;
  71960. /**
  71961. * Not supported by GPUParticleSystem
  71962. * @param gradient defines the gradient to use (between 0 and 1)
  71963. * @param factor defines the start size value to affect to the specified gradient
  71964. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71965. * @returns the current particle system
  71966. */
  71967. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71968. /**
  71969. * Not supported by GPUParticleSystem
  71970. * @param gradient defines the gradient to remove
  71971. * @returns the current particle system
  71972. */
  71973. removeStartSizeGradient(gradient: number): IParticleSystem;
  71974. /**
  71975. * Not supported by GPUParticleSystem
  71976. * @param gradient defines the gradient to use (between 0 and 1)
  71977. * @param min defines the color remap minimal range
  71978. * @param max defines the color remap maximal range
  71979. * @returns the current particle system
  71980. */
  71981. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71982. /**
  71983. * Not supported by GPUParticleSystem
  71984. * @param gradient defines the gradient to remove
  71985. * @returns the current particle system
  71986. */
  71987. removeColorRemapGradient(): IParticleSystem;
  71988. /**
  71989. * Not supported by GPUParticleSystem
  71990. * @param gradient defines the gradient to use (between 0 and 1)
  71991. * @param min defines the alpha remap minimal range
  71992. * @param max defines the alpha remap maximal range
  71993. * @returns the current particle system
  71994. */
  71995. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71996. /**
  71997. * Not supported by GPUParticleSystem
  71998. * @param gradient defines the gradient to remove
  71999. * @returns the current particle system
  72000. */
  72001. removeAlphaRemapGradient(): IParticleSystem;
  72002. /**
  72003. * Not supported by GPUParticleSystem
  72004. * @param gradient defines the gradient to use (between 0 and 1)
  72005. * @param color defines the color to affect to the specified gradient
  72006. * @returns the current particle system
  72007. */
  72008. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72009. /**
  72010. * Not supported by GPUParticleSystem
  72011. * @param gradient defines the gradient to remove
  72012. * @returns the current particle system
  72013. */
  72014. removeRampGradient(): IParticleSystem;
  72015. /**
  72016. * Not supported by GPUParticleSystem
  72017. * @returns the list of ramp gradients
  72018. */
  72019. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72020. /**
  72021. * Not supported by GPUParticleSystem
  72022. * Gets or sets a boolean indicating that ramp gradients must be used
  72023. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72024. */
  72025. get useRampGradients(): boolean;
  72026. set useRampGradients(value: boolean);
  72027. /**
  72028. * Not supported by GPUParticleSystem
  72029. * @param gradient defines the gradient to use (between 0 and 1)
  72030. * @param factor defines the life time factor to affect to the specified gradient
  72031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72032. * @returns the current particle system
  72033. */
  72034. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72035. /**
  72036. * Not supported by GPUParticleSystem
  72037. * @param gradient defines the gradient to remove
  72038. * @returns the current particle system
  72039. */
  72040. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72041. /**
  72042. * Instantiates a GPU particle system.
  72043. * 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.
  72044. * @param name The name of the particle system
  72045. * @param options The options used to create the system
  72046. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72047. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72048. * @param customEffect a custom effect used to change the way particles are rendered by default
  72049. */
  72050. constructor(name: string, options: Partial<{
  72051. capacity: number;
  72052. randomTextureSize: number;
  72053. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72054. protected _reset(): void;
  72055. private _createUpdateVAO;
  72056. private _createRenderVAO;
  72057. private _initialize;
  72058. /** @hidden */
  72059. _recreateUpdateEffect(): void;
  72060. private _getEffect;
  72061. /**
  72062. * Fill the defines array according to the current settings of the particle system
  72063. * @param defines Array to be updated
  72064. * @param blendMode blend mode to take into account when updating the array
  72065. */
  72066. fillDefines(defines: Array<string>, blendMode?: number): void;
  72067. /**
  72068. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72069. * @param uniforms Uniforms array to fill
  72070. * @param attributes Attributes array to fill
  72071. * @param samplers Samplers array to fill
  72072. */
  72073. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72074. /** @hidden */
  72075. _recreateRenderEffect(): Effect;
  72076. /**
  72077. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72078. * @param preWarm defines if we are in the pre-warmimg phase
  72079. */
  72080. animate(preWarm?: boolean): void;
  72081. private _createFactorGradientTexture;
  72082. private _createSizeGradientTexture;
  72083. private _createAngularSpeedGradientTexture;
  72084. private _createVelocityGradientTexture;
  72085. private _createLimitVelocityGradientTexture;
  72086. private _createDragGradientTexture;
  72087. private _createColorGradientTexture;
  72088. /**
  72089. * Renders the particle system in its current state
  72090. * @param preWarm defines if the system should only update the particles but not render them
  72091. * @returns the current number of particles
  72092. */
  72093. render(preWarm?: boolean): number;
  72094. /**
  72095. * Rebuilds the particle system
  72096. */
  72097. rebuild(): void;
  72098. private _releaseBuffers;
  72099. private _releaseVAOs;
  72100. /**
  72101. * Disposes the particle system and free the associated resources
  72102. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72103. */
  72104. dispose(disposeTexture?: boolean): void;
  72105. /**
  72106. * Clones the particle system.
  72107. * @param name The name of the cloned object
  72108. * @param newEmitter The new emitter to use
  72109. * @returns the cloned particle system
  72110. */
  72111. clone(name: string, newEmitter: any): GPUParticleSystem;
  72112. /**
  72113. * Serializes the particle system to a JSON object
  72114. * @param serializeTexture defines if the texture must be serialized as well
  72115. * @returns the JSON object
  72116. */
  72117. serialize(serializeTexture?: boolean): any;
  72118. /**
  72119. * Parses a JSON object to create a GPU particle system.
  72120. * @param parsedParticleSystem The JSON object to parse
  72121. * @param sceneOrEngine The scene or the engine to create the particle system in
  72122. * @param rootUrl The root url to use to load external dependencies like texture
  72123. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72124. * @returns the parsed GPU particle system
  72125. */
  72126. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72127. }
  72128. }
  72129. declare module BABYLON {
  72130. /**
  72131. * Represents a set of particle systems working together to create a specific effect
  72132. */
  72133. export class ParticleSystemSet implements IDisposable {
  72134. /**
  72135. * Gets or sets base Assets URL
  72136. */
  72137. static BaseAssetsUrl: string;
  72138. private _emitterCreationOptions;
  72139. private _emitterNode;
  72140. /**
  72141. * Gets the particle system list
  72142. */
  72143. systems: IParticleSystem[];
  72144. /**
  72145. * Gets the emitter node used with this set
  72146. */
  72147. get emitterNode(): Nullable<TransformNode>;
  72148. /**
  72149. * Creates a new emitter mesh as a sphere
  72150. * @param options defines the options used to create the sphere
  72151. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72152. * @param scene defines the hosting scene
  72153. */
  72154. setEmitterAsSphere(options: {
  72155. diameter: number;
  72156. segments: number;
  72157. color: Color3;
  72158. }, renderingGroupId: number, scene: Scene): void;
  72159. /**
  72160. * Starts all particle systems of the set
  72161. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72162. */
  72163. start(emitter?: AbstractMesh): void;
  72164. /**
  72165. * Release all associated resources
  72166. */
  72167. dispose(): void;
  72168. /**
  72169. * Serialize the set into a JSON compatible object
  72170. * @param serializeTexture defines if the texture must be serialized as well
  72171. * @returns a JSON compatible representation of the set
  72172. */
  72173. serialize(serializeTexture?: boolean): any;
  72174. /**
  72175. * Parse a new ParticleSystemSet from a serialized source
  72176. * @param data defines a JSON compatible representation of the set
  72177. * @param scene defines the hosting scene
  72178. * @param gpu defines if we want GPU particles or CPU particles
  72179. * @returns a new ParticleSystemSet
  72180. */
  72181. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72182. }
  72183. }
  72184. declare module BABYLON {
  72185. /**
  72186. * This class is made for on one-liner static method to help creating particle system set.
  72187. */
  72188. export class ParticleHelper {
  72189. /**
  72190. * Gets or sets base Assets URL
  72191. */
  72192. static BaseAssetsUrl: string;
  72193. /** Define the Url to load snippets */
  72194. static SnippetUrl: string;
  72195. /**
  72196. * Create a default particle system that you can tweak
  72197. * @param emitter defines the emitter to use
  72198. * @param capacity defines the system capacity (default is 500 particles)
  72199. * @param scene defines the hosting scene
  72200. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72201. * @returns the new Particle system
  72202. */
  72203. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72204. /**
  72205. * This is the main static method (one-liner) of this helper to create different particle systems
  72206. * @param type This string represents the type to the particle system to create
  72207. * @param scene The scene where the particle system should live
  72208. * @param gpu If the system will use gpu
  72209. * @returns the ParticleSystemSet created
  72210. */
  72211. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72212. /**
  72213. * Static function used to export a particle system to a ParticleSystemSet variable.
  72214. * Please note that the emitter shape is not exported
  72215. * @param systems defines the particle systems to export
  72216. * @returns the created particle system set
  72217. */
  72218. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72219. /**
  72220. * Creates a particle system from a snippet saved in a remote file
  72221. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72222. * @param url defines the url to load from
  72223. * @param scene defines the hosting scene
  72224. * @param gpu If the system will use gpu
  72225. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72226. * @returns a promise that will resolve to the new particle system
  72227. */
  72228. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72229. /**
  72230. * Creates a particle system from a snippet saved by the particle system editor
  72231. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72232. * @param scene defines the hosting scene
  72233. * @param gpu If the system will use gpu
  72234. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72235. * @returns a promise that will resolve to the new particle system
  72236. */
  72237. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72238. }
  72239. }
  72240. declare module BABYLON {
  72241. interface Engine {
  72242. /**
  72243. * Create an effect to use with particle systems.
  72244. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72245. * the particle system for which you want to create a custom effect in the last parameter
  72246. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72247. * @param uniformsNames defines a list of attribute names
  72248. * @param samplers defines an array of string used to represent textures
  72249. * @param defines defines the string containing the defines to use to compile the shaders
  72250. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72251. * @param onCompiled defines a function to call when the effect creation is successful
  72252. * @param onError defines a function to call when the effect creation has failed
  72253. * @param particleSystem the particle system you want to create the effect for
  72254. * @returns the new Effect
  72255. */
  72256. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72257. }
  72258. interface Mesh {
  72259. /**
  72260. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72261. * @returns an array of IParticleSystem
  72262. */
  72263. getEmittedParticleSystems(): IParticleSystem[];
  72264. /**
  72265. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72266. * @returns an array of IParticleSystem
  72267. */
  72268. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72269. }
  72270. }
  72271. declare module BABYLON {
  72272. /** Defines the 4 color options */
  72273. export enum PointColor {
  72274. /** color value */
  72275. Color = 2,
  72276. /** uv value */
  72277. UV = 1,
  72278. /** random value */
  72279. Random = 0,
  72280. /** stated value */
  72281. Stated = 3
  72282. }
  72283. /**
  72284. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72285. * 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.
  72286. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72287. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72288. *
  72289. * Full documentation here : TO BE ENTERED
  72290. */
  72291. export class PointsCloudSystem implements IDisposable {
  72292. /**
  72293. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72294. * Example : var p = SPS.particles[i];
  72295. */
  72296. particles: CloudPoint[];
  72297. /**
  72298. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72299. */
  72300. nbParticles: number;
  72301. /**
  72302. * This a counter for your own usage. It's not set by any SPS functions.
  72303. */
  72304. counter: number;
  72305. /**
  72306. * The PCS name. This name is also given to the underlying mesh.
  72307. */
  72308. name: string;
  72309. /**
  72310. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72311. */
  72312. mesh: Mesh;
  72313. /**
  72314. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72315. * Please read :
  72316. */
  72317. vars: any;
  72318. /**
  72319. * @hidden
  72320. */
  72321. _size: number;
  72322. private _scene;
  72323. private _promises;
  72324. private _positions;
  72325. private _indices;
  72326. private _normals;
  72327. private _colors;
  72328. private _uvs;
  72329. private _indices32;
  72330. private _positions32;
  72331. private _colors32;
  72332. private _uvs32;
  72333. private _updatable;
  72334. private _isVisibilityBoxLocked;
  72335. private _alwaysVisible;
  72336. private _groups;
  72337. private _groupCounter;
  72338. private _computeParticleColor;
  72339. private _computeParticleTexture;
  72340. private _computeParticleRotation;
  72341. private _computeBoundingBox;
  72342. private _isReady;
  72343. /**
  72344. * Creates a PCS (Points Cloud System) object
  72345. * @param name (String) is the PCS name, this will be the underlying mesh name
  72346. * @param pointSize (number) is the size for each point
  72347. * @param scene (Scene) is the scene in which the PCS is added
  72348. * @param options defines the options of the PCS e.g.
  72349. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72350. */
  72351. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72352. updatable?: boolean;
  72353. });
  72354. /**
  72355. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72356. * If no points were added to the PCS, the returned mesh is just a single point.
  72357. * @returns a promise for the created mesh
  72358. */
  72359. buildMeshAsync(): Promise<Mesh>;
  72360. /**
  72361. * @hidden
  72362. */
  72363. private _buildMesh;
  72364. private _addParticle;
  72365. private _randomUnitVector;
  72366. private _getColorIndicesForCoord;
  72367. private _setPointsColorOrUV;
  72368. private _colorFromTexture;
  72369. private _calculateDensity;
  72370. /**
  72371. * Adds points to the PCS in random positions within a unit sphere
  72372. * @param nb (positive integer) the number of particles to be created from this model
  72373. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72374. * @returns the number of groups in the system
  72375. */
  72376. addPoints(nb: number, pointFunction?: any): number;
  72377. /**
  72378. * Adds points to the PCS from the surface of the model shape
  72379. * @param mesh is any Mesh object that will be used as a surface model for the points
  72380. * @param nb (positive integer) the number of particles to be created from this model
  72381. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72382. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72383. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72384. * @returns the number of groups in the system
  72385. */
  72386. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72387. /**
  72388. * Adds points to the PCS inside the model shape
  72389. * @param mesh is any Mesh object that will be used as a surface model for the points
  72390. * @param nb (positive integer) the number of particles to be created from this model
  72391. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72392. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72393. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72394. * @returns the number of groups in the system
  72395. */
  72396. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72397. /**
  72398. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72399. * This method calls `updateParticle()` for each particle of the SPS.
  72400. * For an animated SPS, it is usually called within the render loop.
  72401. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72402. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72403. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72404. * @returns the PCS.
  72405. */
  72406. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72407. /**
  72408. * Disposes the PCS.
  72409. */
  72410. dispose(): void;
  72411. /**
  72412. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72413. * doc :
  72414. * @returns the PCS.
  72415. */
  72416. refreshVisibleSize(): PointsCloudSystem;
  72417. /**
  72418. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72419. * @param size the size (float) of the visibility box
  72420. * note : this doesn't lock the PCS mesh bounding box.
  72421. * doc :
  72422. */
  72423. setVisibilityBox(size: number): void;
  72424. /**
  72425. * Gets whether the PCS is always visible or not
  72426. * doc :
  72427. */
  72428. get isAlwaysVisible(): boolean;
  72429. /**
  72430. * Sets the PCS as always visible or not
  72431. * doc :
  72432. */
  72433. set isAlwaysVisible(val: boolean);
  72434. /**
  72435. * Tells to `setParticles()` to compute the particle rotations or not
  72436. * Default value : false. The PCS is faster when it's set to false
  72437. * Note : particle rotations are only applied to parent particles
  72438. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72439. */
  72440. set computeParticleRotation(val: boolean);
  72441. /**
  72442. * Tells to `setParticles()` to compute the particle colors or not.
  72443. * Default value : true. The PCS is faster when it's set to false.
  72444. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72445. */
  72446. set computeParticleColor(val: boolean);
  72447. set computeParticleTexture(val: boolean);
  72448. /**
  72449. * Gets if `setParticles()` computes the particle colors or not.
  72450. * Default value : false. The PCS is faster when it's set to false.
  72451. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72452. */
  72453. get computeParticleColor(): boolean;
  72454. /**
  72455. * Gets if `setParticles()` computes the particle textures or not.
  72456. * Default value : false. The PCS is faster when it's set to false.
  72457. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72458. */
  72459. get computeParticleTexture(): boolean;
  72460. /**
  72461. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72462. */
  72463. set computeBoundingBox(val: boolean);
  72464. /**
  72465. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72466. */
  72467. get computeBoundingBox(): boolean;
  72468. /**
  72469. * This function does nothing. It may be overwritten to set all the particle first values.
  72470. * The PCS doesn't call this function, you may have to call it by your own.
  72471. * doc :
  72472. */
  72473. initParticles(): void;
  72474. /**
  72475. * This function does nothing. It may be overwritten to recycle a particle
  72476. * The PCS doesn't call this function, you can to call it
  72477. * doc :
  72478. * @param particle The particle to recycle
  72479. * @returns the recycled particle
  72480. */
  72481. recycleParticle(particle: CloudPoint): CloudPoint;
  72482. /**
  72483. * Updates a particle : this function should be overwritten by the user.
  72484. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72485. * doc :
  72486. * @example : just set a particle position or velocity and recycle conditions
  72487. * @param particle The particle to update
  72488. * @returns the updated particle
  72489. */
  72490. updateParticle(particle: CloudPoint): CloudPoint;
  72491. /**
  72492. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72493. * This does nothing and may be overwritten by the user.
  72494. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72495. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72496. * @param update the boolean update value actually passed to setParticles()
  72497. */
  72498. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72499. /**
  72500. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72501. * This will be passed three parameters.
  72502. * This does nothing and may be overwritten by the user.
  72503. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72504. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72505. * @param update the boolean update value actually passed to setParticles()
  72506. */
  72507. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72508. }
  72509. }
  72510. declare module BABYLON {
  72511. /**
  72512. * Represents one particle of a points cloud system.
  72513. */
  72514. export class CloudPoint {
  72515. /**
  72516. * particle global index
  72517. */
  72518. idx: number;
  72519. /**
  72520. * The color of the particle
  72521. */
  72522. color: Nullable<Color4>;
  72523. /**
  72524. * The world space position of the particle.
  72525. */
  72526. position: Vector3;
  72527. /**
  72528. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72529. */
  72530. rotation: Vector3;
  72531. /**
  72532. * The world space rotation quaternion of the particle.
  72533. */
  72534. rotationQuaternion: Nullable<Quaternion>;
  72535. /**
  72536. * The uv of the particle.
  72537. */
  72538. uv: Nullable<Vector2>;
  72539. /**
  72540. * The current speed of the particle.
  72541. */
  72542. velocity: Vector3;
  72543. /**
  72544. * The pivot point in the particle local space.
  72545. */
  72546. pivot: Vector3;
  72547. /**
  72548. * Must the particle be translated from its pivot point in its local space ?
  72549. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72550. * Default : false
  72551. */
  72552. translateFromPivot: boolean;
  72553. /**
  72554. * Index of this particle in the global "positions" array (Internal use)
  72555. * @hidden
  72556. */
  72557. _pos: number;
  72558. /**
  72559. * @hidden Index of this particle in the global "indices" array (Internal use)
  72560. */
  72561. _ind: number;
  72562. /**
  72563. * Group this particle belongs to
  72564. */
  72565. _group: PointsGroup;
  72566. /**
  72567. * Group id of this particle
  72568. */
  72569. groupId: number;
  72570. /**
  72571. * Index of the particle in its group id (Internal use)
  72572. */
  72573. idxInGroup: number;
  72574. /**
  72575. * @hidden Particle BoundingInfo object (Internal use)
  72576. */
  72577. _boundingInfo: BoundingInfo;
  72578. /**
  72579. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72580. */
  72581. _pcs: PointsCloudSystem;
  72582. /**
  72583. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72584. */
  72585. _stillInvisible: boolean;
  72586. /**
  72587. * @hidden Last computed particle rotation matrix
  72588. */
  72589. _rotationMatrix: number[];
  72590. /**
  72591. * Parent particle Id, if any.
  72592. * Default null.
  72593. */
  72594. parentId: Nullable<number>;
  72595. /**
  72596. * @hidden Internal global position in the PCS.
  72597. */
  72598. _globalPosition: Vector3;
  72599. /**
  72600. * Creates a Point Cloud object.
  72601. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72602. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72603. * @param group (PointsGroup) is the group the particle belongs to
  72604. * @param groupId (integer) is the group identifier in the PCS.
  72605. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72606. * @param pcs defines the PCS it is associated to
  72607. */
  72608. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72609. /**
  72610. * get point size
  72611. */
  72612. get size(): Vector3;
  72613. /**
  72614. * Set point size
  72615. */
  72616. set size(scale: Vector3);
  72617. /**
  72618. * Legacy support, changed quaternion to rotationQuaternion
  72619. */
  72620. get quaternion(): Nullable<Quaternion>;
  72621. /**
  72622. * Legacy support, changed quaternion to rotationQuaternion
  72623. */
  72624. set quaternion(q: Nullable<Quaternion>);
  72625. /**
  72626. * Returns a boolean. True if the particle intersects a mesh, else false
  72627. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72628. * @param target is the object (point or mesh) what the intersection is computed against
  72629. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72630. * @returns true if it intersects
  72631. */
  72632. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72633. /**
  72634. * get the rotation matrix of the particle
  72635. * @hidden
  72636. */
  72637. getRotationMatrix(m: Matrix): void;
  72638. }
  72639. /**
  72640. * Represents a group of points in a points cloud system
  72641. * * PCS internal tool, don't use it manually.
  72642. */
  72643. export class PointsGroup {
  72644. /**
  72645. * The group id
  72646. * @hidden
  72647. */
  72648. groupID: number;
  72649. /**
  72650. * image data for group (internal use)
  72651. * @hidden
  72652. */
  72653. _groupImageData: Nullable<ArrayBufferView>;
  72654. /**
  72655. * Image Width (internal use)
  72656. * @hidden
  72657. */
  72658. _groupImgWidth: number;
  72659. /**
  72660. * Image Height (internal use)
  72661. * @hidden
  72662. */
  72663. _groupImgHeight: number;
  72664. /**
  72665. * Custom position function (internal use)
  72666. * @hidden
  72667. */
  72668. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72669. /**
  72670. * density per facet for surface points
  72671. * @hidden
  72672. */
  72673. _groupDensity: number[];
  72674. /**
  72675. * Only when points are colored by texture carries pointer to texture list array
  72676. * @hidden
  72677. */
  72678. _textureNb: number;
  72679. /**
  72680. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72681. * PCS internal tool, don't use it manually.
  72682. * @hidden
  72683. */
  72684. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72685. }
  72686. }
  72687. declare module BABYLON {
  72688. interface Scene {
  72689. /** @hidden (Backing field) */
  72690. _physicsEngine: Nullable<IPhysicsEngine>;
  72691. /** @hidden */
  72692. _physicsTimeAccumulator: number;
  72693. /**
  72694. * Gets the current physics engine
  72695. * @returns a IPhysicsEngine or null if none attached
  72696. */
  72697. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72698. /**
  72699. * Enables physics to the current scene
  72700. * @param gravity defines the scene's gravity for the physics engine
  72701. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72702. * @return a boolean indicating if the physics engine was initialized
  72703. */
  72704. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72705. /**
  72706. * Disables and disposes the physics engine associated with the scene
  72707. */
  72708. disablePhysicsEngine(): void;
  72709. /**
  72710. * Gets a boolean indicating if there is an active physics engine
  72711. * @returns a boolean indicating if there is an active physics engine
  72712. */
  72713. isPhysicsEnabled(): boolean;
  72714. /**
  72715. * Deletes a physics compound impostor
  72716. * @param compound defines the compound to delete
  72717. */
  72718. deleteCompoundImpostor(compound: any): void;
  72719. /**
  72720. * An event triggered when physic simulation is about to be run
  72721. */
  72722. onBeforePhysicsObservable: Observable<Scene>;
  72723. /**
  72724. * An event triggered when physic simulation has been done
  72725. */
  72726. onAfterPhysicsObservable: Observable<Scene>;
  72727. }
  72728. interface AbstractMesh {
  72729. /** @hidden */
  72730. _physicsImpostor: Nullable<PhysicsImpostor>;
  72731. /**
  72732. * Gets or sets impostor used for physic simulation
  72733. * @see https://doc.babylonjs.com/features/physics_engine
  72734. */
  72735. physicsImpostor: Nullable<PhysicsImpostor>;
  72736. /**
  72737. * Gets the current physics impostor
  72738. * @see https://doc.babylonjs.com/features/physics_engine
  72739. * @returns a physics impostor or null
  72740. */
  72741. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72742. /** Apply a physic impulse to the mesh
  72743. * @param force defines the force to apply
  72744. * @param contactPoint defines where to apply the force
  72745. * @returns the current mesh
  72746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72747. */
  72748. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72749. /**
  72750. * Creates a physic joint between two meshes
  72751. * @param otherMesh defines the other mesh to use
  72752. * @param pivot1 defines the pivot to use on this mesh
  72753. * @param pivot2 defines the pivot to use on the other mesh
  72754. * @param options defines additional options (can be plugin dependent)
  72755. * @returns the current mesh
  72756. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72757. */
  72758. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72759. /** @hidden */
  72760. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72761. }
  72762. /**
  72763. * Defines the physics engine scene component responsible to manage a physics engine
  72764. */
  72765. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72766. /**
  72767. * The component name helpful to identify the component in the list of scene components.
  72768. */
  72769. readonly name: string;
  72770. /**
  72771. * The scene the component belongs to.
  72772. */
  72773. scene: Scene;
  72774. /**
  72775. * Creates a new instance of the component for the given scene
  72776. * @param scene Defines the scene to register the component in
  72777. */
  72778. constructor(scene: Scene);
  72779. /**
  72780. * Registers the component in a given scene
  72781. */
  72782. register(): void;
  72783. /**
  72784. * Rebuilds the elements related to this component in case of
  72785. * context lost for instance.
  72786. */
  72787. rebuild(): void;
  72788. /**
  72789. * Disposes the component and the associated ressources
  72790. */
  72791. dispose(): void;
  72792. }
  72793. }
  72794. declare module BABYLON {
  72795. /**
  72796. * A helper for physics simulations
  72797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72798. */
  72799. export class PhysicsHelper {
  72800. private _scene;
  72801. private _physicsEngine;
  72802. /**
  72803. * Initializes the Physics helper
  72804. * @param scene Babylon.js scene
  72805. */
  72806. constructor(scene: Scene);
  72807. /**
  72808. * Applies a radial explosion impulse
  72809. * @param origin the origin of the explosion
  72810. * @param radiusOrEventOptions the radius or the options of radial explosion
  72811. * @param strength the explosion strength
  72812. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72813. * @returns A physics radial explosion event, or null
  72814. */
  72815. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72816. /**
  72817. * Applies a radial explosion force
  72818. * @param origin the origin of the explosion
  72819. * @param radiusOrEventOptions the radius or the options of radial explosion
  72820. * @param strength the explosion strength
  72821. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72822. * @returns A physics radial explosion event, or null
  72823. */
  72824. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72825. /**
  72826. * Creates a gravitational field
  72827. * @param origin the origin of the explosion
  72828. * @param radiusOrEventOptions the radius or the options of radial explosion
  72829. * @param strength the explosion strength
  72830. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72831. * @returns A physics gravitational field event, or null
  72832. */
  72833. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72834. /**
  72835. * Creates a physics updraft event
  72836. * @param origin the origin of the updraft
  72837. * @param radiusOrEventOptions the radius or the options of the updraft
  72838. * @param strength the strength of the updraft
  72839. * @param height the height of the updraft
  72840. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72841. * @returns A physics updraft event, or null
  72842. */
  72843. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72844. /**
  72845. * Creates a physics vortex event
  72846. * @param origin the of the vortex
  72847. * @param radiusOrEventOptions the radius or the options of the vortex
  72848. * @param strength the strength of the vortex
  72849. * @param height the height of the vortex
  72850. * @returns a Physics vortex event, or null
  72851. * A physics vortex event or null
  72852. */
  72853. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72854. }
  72855. /**
  72856. * Represents a physics radial explosion event
  72857. */
  72858. class PhysicsRadialExplosionEvent {
  72859. private _scene;
  72860. private _options;
  72861. private _sphere;
  72862. private _dataFetched;
  72863. /**
  72864. * Initializes a radial explosioin event
  72865. * @param _scene BabylonJS scene
  72866. * @param _options The options for the vortex event
  72867. */
  72868. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72869. /**
  72870. * Returns the data related to the radial explosion event (sphere).
  72871. * @returns The radial explosion event data
  72872. */
  72873. getData(): PhysicsRadialExplosionEventData;
  72874. /**
  72875. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72876. * @param impostor A physics imposter
  72877. * @param origin the origin of the explosion
  72878. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72879. */
  72880. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72881. /**
  72882. * Triggers affecterd impostors callbacks
  72883. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72884. */
  72885. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72886. /**
  72887. * Disposes the sphere.
  72888. * @param force Specifies if the sphere should be disposed by force
  72889. */
  72890. dispose(force?: boolean): void;
  72891. /*** Helpers ***/
  72892. private _prepareSphere;
  72893. private _intersectsWithSphere;
  72894. }
  72895. /**
  72896. * Represents a gravitational field event
  72897. */
  72898. class PhysicsGravitationalFieldEvent {
  72899. private _physicsHelper;
  72900. private _scene;
  72901. private _origin;
  72902. private _options;
  72903. private _tickCallback;
  72904. private _sphere;
  72905. private _dataFetched;
  72906. /**
  72907. * Initializes the physics gravitational field event
  72908. * @param _physicsHelper A physics helper
  72909. * @param _scene BabylonJS scene
  72910. * @param _origin The origin position of the gravitational field event
  72911. * @param _options The options for the vortex event
  72912. */
  72913. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72914. /**
  72915. * Returns the data related to the gravitational field event (sphere).
  72916. * @returns A gravitational field event
  72917. */
  72918. getData(): PhysicsGravitationalFieldEventData;
  72919. /**
  72920. * Enables the gravitational field.
  72921. */
  72922. enable(): void;
  72923. /**
  72924. * Disables the gravitational field.
  72925. */
  72926. disable(): void;
  72927. /**
  72928. * Disposes the sphere.
  72929. * @param force The force to dispose from the gravitational field event
  72930. */
  72931. dispose(force?: boolean): void;
  72932. private _tick;
  72933. }
  72934. /**
  72935. * Represents a physics updraft event
  72936. */
  72937. class PhysicsUpdraftEvent {
  72938. private _scene;
  72939. private _origin;
  72940. private _options;
  72941. private _physicsEngine;
  72942. private _originTop;
  72943. private _originDirection;
  72944. private _tickCallback;
  72945. private _cylinder;
  72946. private _cylinderPosition;
  72947. private _dataFetched;
  72948. /**
  72949. * Initializes the physics updraft event
  72950. * @param _scene BabylonJS scene
  72951. * @param _origin The origin position of the updraft
  72952. * @param _options The options for the updraft event
  72953. */
  72954. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72955. /**
  72956. * Returns the data related to the updraft event (cylinder).
  72957. * @returns A physics updraft event
  72958. */
  72959. getData(): PhysicsUpdraftEventData;
  72960. /**
  72961. * Enables the updraft.
  72962. */
  72963. enable(): void;
  72964. /**
  72965. * Disables the updraft.
  72966. */
  72967. disable(): void;
  72968. /**
  72969. * Disposes the cylinder.
  72970. * @param force Specifies if the updraft should be disposed by force
  72971. */
  72972. dispose(force?: boolean): void;
  72973. private getImpostorHitData;
  72974. private _tick;
  72975. /*** Helpers ***/
  72976. private _prepareCylinder;
  72977. private _intersectsWithCylinder;
  72978. }
  72979. /**
  72980. * Represents a physics vortex event
  72981. */
  72982. class PhysicsVortexEvent {
  72983. private _scene;
  72984. private _origin;
  72985. private _options;
  72986. private _physicsEngine;
  72987. private _originTop;
  72988. private _tickCallback;
  72989. private _cylinder;
  72990. private _cylinderPosition;
  72991. private _dataFetched;
  72992. /**
  72993. * Initializes the physics vortex event
  72994. * @param _scene The BabylonJS scene
  72995. * @param _origin The origin position of the vortex
  72996. * @param _options The options for the vortex event
  72997. */
  72998. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72999. /**
  73000. * Returns the data related to the vortex event (cylinder).
  73001. * @returns The physics vortex event data
  73002. */
  73003. getData(): PhysicsVortexEventData;
  73004. /**
  73005. * Enables the vortex.
  73006. */
  73007. enable(): void;
  73008. /**
  73009. * Disables the cortex.
  73010. */
  73011. disable(): void;
  73012. /**
  73013. * Disposes the sphere.
  73014. * @param force
  73015. */
  73016. dispose(force?: boolean): void;
  73017. private getImpostorHitData;
  73018. private _tick;
  73019. /*** Helpers ***/
  73020. private _prepareCylinder;
  73021. private _intersectsWithCylinder;
  73022. }
  73023. /**
  73024. * Options fot the radial explosion event
  73025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73026. */
  73027. export class PhysicsRadialExplosionEventOptions {
  73028. /**
  73029. * The radius of the sphere for the radial explosion.
  73030. */
  73031. radius: number;
  73032. /**
  73033. * The strenth of the explosion.
  73034. */
  73035. strength: number;
  73036. /**
  73037. * The strenght of the force in correspondence to the distance of the affected object
  73038. */
  73039. falloff: PhysicsRadialImpulseFalloff;
  73040. /**
  73041. * Sphere options for the radial explosion.
  73042. */
  73043. sphere: {
  73044. segments: number;
  73045. diameter: number;
  73046. };
  73047. /**
  73048. * Sphere options for the radial explosion.
  73049. */
  73050. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73051. }
  73052. /**
  73053. * Options fot the updraft event
  73054. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73055. */
  73056. export class PhysicsUpdraftEventOptions {
  73057. /**
  73058. * The radius of the cylinder for the vortex
  73059. */
  73060. radius: number;
  73061. /**
  73062. * The strenth of the updraft.
  73063. */
  73064. strength: number;
  73065. /**
  73066. * The height of the cylinder for the updraft.
  73067. */
  73068. height: number;
  73069. /**
  73070. * The mode for the the updraft.
  73071. */
  73072. updraftMode: PhysicsUpdraftMode;
  73073. }
  73074. /**
  73075. * Options fot the vortex event
  73076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73077. */
  73078. export class PhysicsVortexEventOptions {
  73079. /**
  73080. * The radius of the cylinder for the vortex
  73081. */
  73082. radius: number;
  73083. /**
  73084. * The strenth of the vortex.
  73085. */
  73086. strength: number;
  73087. /**
  73088. * The height of the cylinder for the vortex.
  73089. */
  73090. height: number;
  73091. /**
  73092. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73093. */
  73094. centripetalForceThreshold: number;
  73095. /**
  73096. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73097. */
  73098. centripetalForceMultiplier: number;
  73099. /**
  73100. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73101. */
  73102. centrifugalForceMultiplier: number;
  73103. /**
  73104. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73105. */
  73106. updraftForceMultiplier: number;
  73107. }
  73108. /**
  73109. * The strenght of the force in correspondence to the distance of the affected object
  73110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73111. */
  73112. export enum PhysicsRadialImpulseFalloff {
  73113. /** Defines that impulse is constant in strength across it's whole radius */
  73114. Constant = 0,
  73115. /** Defines that impulse gets weaker if it's further from the origin */
  73116. Linear = 1
  73117. }
  73118. /**
  73119. * The strength of the force in correspondence to the distance of the affected object
  73120. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73121. */
  73122. export enum PhysicsUpdraftMode {
  73123. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73124. Center = 0,
  73125. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73126. Perpendicular = 1
  73127. }
  73128. /**
  73129. * Interface for a physics hit data
  73130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73131. */
  73132. export interface PhysicsHitData {
  73133. /**
  73134. * The force applied at the contact point
  73135. */
  73136. force: Vector3;
  73137. /**
  73138. * The contact point
  73139. */
  73140. contactPoint: Vector3;
  73141. /**
  73142. * The distance from the origin to the contact point
  73143. */
  73144. distanceFromOrigin: number;
  73145. }
  73146. /**
  73147. * Interface for radial explosion event data
  73148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73149. */
  73150. export interface PhysicsRadialExplosionEventData {
  73151. /**
  73152. * A sphere used for the radial explosion event
  73153. */
  73154. sphere: Mesh;
  73155. }
  73156. /**
  73157. * Interface for gravitational field event data
  73158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73159. */
  73160. export interface PhysicsGravitationalFieldEventData {
  73161. /**
  73162. * A sphere mesh used for the gravitational field event
  73163. */
  73164. sphere: Mesh;
  73165. }
  73166. /**
  73167. * Interface for updraft event data
  73168. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73169. */
  73170. export interface PhysicsUpdraftEventData {
  73171. /**
  73172. * A cylinder used for the updraft event
  73173. */
  73174. cylinder: Mesh;
  73175. }
  73176. /**
  73177. * Interface for vortex event data
  73178. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73179. */
  73180. export interface PhysicsVortexEventData {
  73181. /**
  73182. * A cylinder used for the vortex event
  73183. */
  73184. cylinder: Mesh;
  73185. }
  73186. /**
  73187. * Interface for an affected physics impostor
  73188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73189. */
  73190. export interface PhysicsAffectedImpostorWithData {
  73191. /**
  73192. * The impostor affected by the effect
  73193. */
  73194. impostor: PhysicsImpostor;
  73195. /**
  73196. * The data about the hit/horce from the explosion
  73197. */
  73198. hitData: PhysicsHitData;
  73199. }
  73200. }
  73201. declare module BABYLON {
  73202. /** @hidden */
  73203. export var blackAndWhitePixelShader: {
  73204. name: string;
  73205. shader: string;
  73206. };
  73207. }
  73208. declare module BABYLON {
  73209. /**
  73210. * Post process used to render in black and white
  73211. */
  73212. export class BlackAndWhitePostProcess extends PostProcess {
  73213. /**
  73214. * Linear about to convert he result to black and white (default: 1)
  73215. */
  73216. degree: number;
  73217. /**
  73218. * Gets a string identifying the name of the class
  73219. * @returns "BlackAndWhitePostProcess" string
  73220. */
  73221. getClassName(): string;
  73222. /**
  73223. * Creates a black and white post process
  73224. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73225. * @param name The name of the effect.
  73226. * @param options The required width/height ratio to downsize to before computing the render pass.
  73227. * @param camera The camera to apply the render pass to.
  73228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73229. * @param engine The engine which the post process will be applied. (default: current engine)
  73230. * @param reusable If the post process can be reused on the same frame. (default: false)
  73231. */
  73232. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73233. /** @hidden */
  73234. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73235. }
  73236. }
  73237. declare module BABYLON {
  73238. /**
  73239. * This represents a set of one or more post processes in Babylon.
  73240. * A post process can be used to apply a shader to a texture after it is rendered.
  73241. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73242. */
  73243. export class PostProcessRenderEffect {
  73244. private _postProcesses;
  73245. private _getPostProcesses;
  73246. private _singleInstance;
  73247. private _cameras;
  73248. private _indicesForCamera;
  73249. /**
  73250. * Name of the effect
  73251. * @hidden
  73252. */
  73253. _name: string;
  73254. /**
  73255. * Instantiates a post process render effect.
  73256. * A post process can be used to apply a shader to a texture after it is rendered.
  73257. * @param engine The engine the effect is tied to
  73258. * @param name The name of the effect
  73259. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73260. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73261. */
  73262. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73263. /**
  73264. * Checks if all the post processes in the effect are supported.
  73265. */
  73266. get isSupported(): boolean;
  73267. /**
  73268. * Updates the current state of the effect
  73269. * @hidden
  73270. */
  73271. _update(): void;
  73272. /**
  73273. * Attaches the effect on cameras
  73274. * @param cameras The camera to attach to.
  73275. * @hidden
  73276. */
  73277. _attachCameras(cameras: Camera): void;
  73278. /**
  73279. * Attaches the effect on cameras
  73280. * @param cameras The camera to attach to.
  73281. * @hidden
  73282. */
  73283. _attachCameras(cameras: Camera[]): void;
  73284. /**
  73285. * Detaches the effect on cameras
  73286. * @param cameras The camera to detatch from.
  73287. * @hidden
  73288. */
  73289. _detachCameras(cameras: Camera): void;
  73290. /**
  73291. * Detatches the effect on cameras
  73292. * @param cameras The camera to detatch from.
  73293. * @hidden
  73294. */
  73295. _detachCameras(cameras: Camera[]): void;
  73296. /**
  73297. * Enables the effect on given cameras
  73298. * @param cameras The camera to enable.
  73299. * @hidden
  73300. */
  73301. _enable(cameras: Camera): void;
  73302. /**
  73303. * Enables the effect on given cameras
  73304. * @param cameras The camera to enable.
  73305. * @hidden
  73306. */
  73307. _enable(cameras: Nullable<Camera[]>): void;
  73308. /**
  73309. * Disables the effect on the given cameras
  73310. * @param cameras The camera to disable.
  73311. * @hidden
  73312. */
  73313. _disable(cameras: Camera): void;
  73314. /**
  73315. * Disables the effect on the given cameras
  73316. * @param cameras The camera to disable.
  73317. * @hidden
  73318. */
  73319. _disable(cameras: Nullable<Camera[]>): void;
  73320. /**
  73321. * Gets a list of the post processes contained in the effect.
  73322. * @param camera The camera to get the post processes on.
  73323. * @returns The list of the post processes in the effect.
  73324. */
  73325. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73326. }
  73327. }
  73328. declare module BABYLON {
  73329. /** @hidden */
  73330. export var extractHighlightsPixelShader: {
  73331. name: string;
  73332. shader: string;
  73333. };
  73334. }
  73335. declare module BABYLON {
  73336. /**
  73337. * 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.
  73338. */
  73339. export class ExtractHighlightsPostProcess extends PostProcess {
  73340. /**
  73341. * The luminance threshold, pixels below this value will be set to black.
  73342. */
  73343. threshold: number;
  73344. /** @hidden */
  73345. _exposure: number;
  73346. /**
  73347. * Post process which has the input texture to be used when performing highlight extraction
  73348. * @hidden
  73349. */
  73350. _inputPostProcess: Nullable<PostProcess>;
  73351. /**
  73352. * Gets a string identifying the name of the class
  73353. * @returns "ExtractHighlightsPostProcess" string
  73354. */
  73355. getClassName(): string;
  73356. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73357. }
  73358. }
  73359. declare module BABYLON {
  73360. /** @hidden */
  73361. export var bloomMergePixelShader: {
  73362. name: string;
  73363. shader: string;
  73364. };
  73365. }
  73366. declare module BABYLON {
  73367. /**
  73368. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73369. */
  73370. export class BloomMergePostProcess extends PostProcess {
  73371. /** Weight of the bloom to be added to the original input. */
  73372. weight: number;
  73373. /**
  73374. * Gets a string identifying the name of the class
  73375. * @returns "BloomMergePostProcess" string
  73376. */
  73377. getClassName(): string;
  73378. /**
  73379. * Creates a new instance of @see BloomMergePostProcess
  73380. * @param name The name of the effect.
  73381. * @param originalFromInput Post process which's input will be used for the merge.
  73382. * @param blurred Blurred highlights post process which's output will be used.
  73383. * @param weight Weight of the bloom to be added to the original input.
  73384. * @param options The required width/height ratio to downsize to before computing the render pass.
  73385. * @param camera The camera to apply the render pass to.
  73386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73387. * @param engine The engine which the post process will be applied. (default: current engine)
  73388. * @param reusable If the post process can be reused on the same frame. (default: false)
  73389. * @param textureType Type of textures used when performing the post process. (default: 0)
  73390. * @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)
  73391. */
  73392. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73393. /** Weight of the bloom to be added to the original input. */
  73394. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73395. }
  73396. }
  73397. declare module BABYLON {
  73398. /**
  73399. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73400. */
  73401. export class BloomEffect extends PostProcessRenderEffect {
  73402. private bloomScale;
  73403. /**
  73404. * @hidden Internal
  73405. */
  73406. _effects: Array<PostProcess>;
  73407. /**
  73408. * @hidden Internal
  73409. */
  73410. _downscale: ExtractHighlightsPostProcess;
  73411. private _blurX;
  73412. private _blurY;
  73413. private _merge;
  73414. /**
  73415. * The luminance threshold to find bright areas of the image to bloom.
  73416. */
  73417. get threshold(): number;
  73418. set threshold(value: number);
  73419. /**
  73420. * The strength of the bloom.
  73421. */
  73422. get weight(): number;
  73423. set weight(value: number);
  73424. /**
  73425. * Specifies the size of the bloom blur kernel, relative to the final output size
  73426. */
  73427. get kernel(): number;
  73428. set kernel(value: number);
  73429. /**
  73430. * Creates a new instance of @see BloomEffect
  73431. * @param scene The scene the effect belongs to.
  73432. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73433. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73434. * @param bloomWeight The the strength of bloom.
  73435. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73436. * @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)
  73437. */
  73438. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73439. /**
  73440. * Disposes each of the internal effects for a given camera.
  73441. * @param camera The camera to dispose the effect on.
  73442. */
  73443. disposeEffects(camera: Camera): void;
  73444. /**
  73445. * @hidden Internal
  73446. */
  73447. _updateEffects(): void;
  73448. /**
  73449. * Internal
  73450. * @returns if all the contained post processes are ready.
  73451. * @hidden
  73452. */
  73453. _isReady(): boolean;
  73454. }
  73455. }
  73456. declare module BABYLON {
  73457. /** @hidden */
  73458. export var chromaticAberrationPixelShader: {
  73459. name: string;
  73460. shader: string;
  73461. };
  73462. }
  73463. declare module BABYLON {
  73464. /**
  73465. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73466. */
  73467. export class ChromaticAberrationPostProcess extends PostProcess {
  73468. /**
  73469. * The amount of seperation of rgb channels (default: 30)
  73470. */
  73471. aberrationAmount: number;
  73472. /**
  73473. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73474. */
  73475. radialIntensity: number;
  73476. /**
  73477. * The normilized direction in which the rgb channels should be seperated. If set to 0,0 radial direction will be used. (default: Vector2(0.707,0.707))
  73478. */
  73479. direction: Vector2;
  73480. /**
  73481. * The center position where the radialIntensity should be around. [0.5,0.5 is center of screen, 1,1 is top right corder] (default: Vector2(0.5 ,0.5))
  73482. */
  73483. centerPosition: Vector2;
  73484. /** The width of the screen to apply the effect on */
  73485. screenWidth: number;
  73486. /** The height of the screen to apply the effect on */
  73487. screenHeight: number;
  73488. /**
  73489. * Gets a string identifying the name of the class
  73490. * @returns "ChromaticAberrationPostProcess" string
  73491. */
  73492. getClassName(): string;
  73493. /**
  73494. * Creates a new instance ChromaticAberrationPostProcess
  73495. * @param name The name of the effect.
  73496. * @param screenWidth The width of the screen to apply the effect on.
  73497. * @param screenHeight The height of the screen to apply the effect on.
  73498. * @param options The required width/height ratio to downsize to before computing the render pass.
  73499. * @param camera The camera to apply the render pass to.
  73500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73501. * @param engine The engine which the post process will be applied. (default: current engine)
  73502. * @param reusable If the post process can be reused on the same frame. (default: false)
  73503. * @param textureType Type of textures used when performing the post process. (default: 0)
  73504. * @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)
  73505. */
  73506. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73507. /** @hidden */
  73508. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73509. }
  73510. }
  73511. declare module BABYLON {
  73512. /** @hidden */
  73513. export var circleOfConfusionPixelShader: {
  73514. name: string;
  73515. shader: string;
  73516. };
  73517. }
  73518. declare module BABYLON {
  73519. /**
  73520. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73521. */
  73522. export class CircleOfConfusionPostProcess extends PostProcess {
  73523. /**
  73524. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  73525. */
  73526. lensSize: number;
  73527. /**
  73528. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73529. */
  73530. fStop: number;
  73531. /**
  73532. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73533. */
  73534. focusDistance: number;
  73535. /**
  73536. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73537. */
  73538. focalLength: number;
  73539. /**
  73540. * Gets a string identifying the name of the class
  73541. * @returns "CircleOfConfusionPostProcess" string
  73542. */
  73543. getClassName(): string;
  73544. private _depthTexture;
  73545. /**
  73546. * Creates a new instance CircleOfConfusionPostProcess
  73547. * @param name The name of the effect.
  73548. * @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.
  73549. * @param options The required width/height ratio to downsize to before computing the render pass.
  73550. * @param camera The camera to apply the render pass to.
  73551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73552. * @param engine The engine which the post process will be applied. (default: current engine)
  73553. * @param reusable If the post process can be reused on the same frame. (default: false)
  73554. * @param textureType Type of textures used when performing the post process. (default: 0)
  73555. * @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)
  73556. */
  73557. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73558. /**
  73559. * 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.
  73560. */
  73561. set depthTexture(value: RenderTargetTexture);
  73562. }
  73563. }
  73564. declare module BABYLON {
  73565. /** @hidden */
  73566. export var colorCorrectionPixelShader: {
  73567. name: string;
  73568. shader: string;
  73569. };
  73570. }
  73571. declare module BABYLON {
  73572. /**
  73573. *
  73574. * This post-process allows the modification of rendered colors by using
  73575. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73576. *
  73577. * The object needs to be provided an url to a texture containing the color
  73578. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73579. * Use an image editing software to tweak the LUT to match your needs.
  73580. *
  73581. * For an example of a color LUT, see here:
  73582. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73583. * For explanations on color grading, see here:
  73584. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73585. *
  73586. */
  73587. export class ColorCorrectionPostProcess extends PostProcess {
  73588. private _colorTableTexture;
  73589. /**
  73590. * Gets the color table url used to create the LUT texture
  73591. */
  73592. colorTableUrl: string;
  73593. /**
  73594. * Gets a string identifying the name of the class
  73595. * @returns "ColorCorrectionPostProcess" string
  73596. */
  73597. getClassName(): string;
  73598. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73599. /** @hidden */
  73600. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73601. }
  73602. }
  73603. declare module BABYLON {
  73604. /** @hidden */
  73605. export var convolutionPixelShader: {
  73606. name: string;
  73607. shader: string;
  73608. };
  73609. }
  73610. declare module BABYLON {
  73611. /**
  73612. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73613. * input texture to perform effects such as edge detection or sharpening
  73614. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73615. */
  73616. export class ConvolutionPostProcess extends PostProcess {
  73617. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73618. kernel: number[];
  73619. /**
  73620. * Gets a string identifying the name of the class
  73621. * @returns "ConvolutionPostProcess" string
  73622. */
  73623. getClassName(): string;
  73624. /**
  73625. * Creates a new instance ConvolutionPostProcess
  73626. * @param name The name of the effect.
  73627. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73628. * @param options The required width/height ratio to downsize to before computing the render pass.
  73629. * @param camera The camera to apply the render pass to.
  73630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73631. * @param engine The engine which the post process will be applied. (default: current engine)
  73632. * @param reusable If the post process can be reused on the same frame. (default: false)
  73633. * @param textureType Type of textures used when performing the post process. (default: 0)
  73634. */
  73635. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73636. /** @hidden */
  73637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73638. /**
  73639. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73640. */
  73641. static EdgeDetect0Kernel: number[];
  73642. /**
  73643. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73644. */
  73645. static EdgeDetect1Kernel: number[];
  73646. /**
  73647. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73648. */
  73649. static EdgeDetect2Kernel: number[];
  73650. /**
  73651. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73652. */
  73653. static SharpenKernel: number[];
  73654. /**
  73655. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73656. */
  73657. static EmbossKernel: number[];
  73658. /**
  73659. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73660. */
  73661. static GaussianKernel: number[];
  73662. }
  73663. }
  73664. declare module BABYLON {
  73665. /**
  73666. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73667. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73668. * based on samples that have a large difference in distance than the center pixel.
  73669. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73670. */
  73671. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73672. /**
  73673. * The direction the blur should be applied
  73674. */
  73675. direction: Vector2;
  73676. /**
  73677. * Gets a string identifying the name of the class
  73678. * @returns "DepthOfFieldBlurPostProcess" string
  73679. */
  73680. getClassName(): string;
  73681. /**
  73682. * Creates a new instance CircleOfConfusionPostProcess
  73683. * @param name The name of the effect.
  73684. * @param scene The scene the effect belongs to.
  73685. * @param direction The direction the blur should be applied.
  73686. * @param kernel The size of the kernel used to blur.
  73687. * @param options The required width/height ratio to downsize to before computing the render pass.
  73688. * @param camera The camera to apply the render pass to.
  73689. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73690. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73691. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73692. * @param engine The engine which the post process will be applied. (default: current engine)
  73693. * @param reusable If the post process can be reused on the same frame. (default: false)
  73694. * @param textureType Type of textures used when performing the post process. (default: 0)
  73695. * @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)
  73696. */
  73697. 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);
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /** @hidden */
  73702. export var depthOfFieldMergePixelShader: {
  73703. name: string;
  73704. shader: string;
  73705. };
  73706. }
  73707. declare module BABYLON {
  73708. /**
  73709. * Options to be set when merging outputs from the default pipeline.
  73710. */
  73711. export class DepthOfFieldMergePostProcessOptions {
  73712. /**
  73713. * The original image to merge on top of
  73714. */
  73715. originalFromInput: PostProcess;
  73716. /**
  73717. * Parameters to perform the merge of the depth of field effect
  73718. */
  73719. depthOfField?: {
  73720. circleOfConfusion: PostProcess;
  73721. blurSteps: Array<PostProcess>;
  73722. };
  73723. /**
  73724. * Parameters to perform the merge of bloom effect
  73725. */
  73726. bloom?: {
  73727. blurred: PostProcess;
  73728. weight: number;
  73729. };
  73730. }
  73731. /**
  73732. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73733. */
  73734. export class DepthOfFieldMergePostProcess extends PostProcess {
  73735. private blurSteps;
  73736. /**
  73737. * Gets a string identifying the name of the class
  73738. * @returns "DepthOfFieldMergePostProcess" string
  73739. */
  73740. getClassName(): string;
  73741. /**
  73742. * Creates a new instance of DepthOfFieldMergePostProcess
  73743. * @param name The name of the effect.
  73744. * @param originalFromInput Post process which's input will be used for the merge.
  73745. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73746. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73747. * @param options The required width/height ratio to downsize to before computing the render pass.
  73748. * @param camera The camera to apply the render pass to.
  73749. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73750. * @param engine The engine which the post process will be applied. (default: current engine)
  73751. * @param reusable If the post process can be reused on the same frame. (default: false)
  73752. * @param textureType Type of textures used when performing the post process. (default: 0)
  73753. * @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)
  73754. */
  73755. 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);
  73756. /**
  73757. * Updates the effect with the current post process compile time values and recompiles the shader.
  73758. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73759. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73760. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73761. * @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
  73762. * @param onCompiled Called when the shader has been compiled.
  73763. * @param onError Called if there is an error when compiling a shader.
  73764. */
  73765. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. /**
  73770. * Specifies the level of max blur that should be applied when using the depth of field effect
  73771. */
  73772. export enum DepthOfFieldEffectBlurLevel {
  73773. /**
  73774. * Subtle blur
  73775. */
  73776. Low = 0,
  73777. /**
  73778. * Medium blur
  73779. */
  73780. Medium = 1,
  73781. /**
  73782. * Large blur
  73783. */
  73784. High = 2
  73785. }
  73786. /**
  73787. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73788. */
  73789. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73790. private _circleOfConfusion;
  73791. /**
  73792. * @hidden Internal, blurs from high to low
  73793. */
  73794. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73795. private _depthOfFieldBlurY;
  73796. private _dofMerge;
  73797. /**
  73798. * @hidden Internal post processes in depth of field effect
  73799. */
  73800. _effects: Array<PostProcess>;
  73801. /**
  73802. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73803. */
  73804. set focalLength(value: number);
  73805. get focalLength(): number;
  73806. /**
  73807. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73808. */
  73809. set fStop(value: number);
  73810. get fStop(): number;
  73811. /**
  73812. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73813. */
  73814. set focusDistance(value: number);
  73815. get focusDistance(): number;
  73816. /**
  73817. * Max lens size in scene units/1000 (eg. millimeter). Standard cameras are 50mm. (default: 50) The diamater of the resulting aperture can be computed by lensSize/fStop.
  73818. */
  73819. set lensSize(value: number);
  73820. get lensSize(): number;
  73821. /**
  73822. * Creates a new instance DepthOfFieldEffect
  73823. * @param scene The scene the effect belongs to.
  73824. * @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.
  73825. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73826. * @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)
  73827. */
  73828. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73829. /**
  73830. * Get the current class name of the current effet
  73831. * @returns "DepthOfFieldEffect"
  73832. */
  73833. getClassName(): string;
  73834. /**
  73835. * 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.
  73836. */
  73837. set depthTexture(value: RenderTargetTexture);
  73838. /**
  73839. * Disposes each of the internal effects for a given camera.
  73840. * @param camera The camera to dispose the effect on.
  73841. */
  73842. disposeEffects(camera: Camera): void;
  73843. /**
  73844. * @hidden Internal
  73845. */
  73846. _updateEffects(): void;
  73847. /**
  73848. * Internal
  73849. * @returns if all the contained post processes are ready.
  73850. * @hidden
  73851. */
  73852. _isReady(): boolean;
  73853. }
  73854. }
  73855. declare module BABYLON {
  73856. /** @hidden */
  73857. export var displayPassPixelShader: {
  73858. name: string;
  73859. shader: string;
  73860. };
  73861. }
  73862. declare module BABYLON {
  73863. /**
  73864. * DisplayPassPostProcess which produces an output the same as it's input
  73865. */
  73866. export class DisplayPassPostProcess extends PostProcess {
  73867. /**
  73868. * Gets a string identifying the name of the class
  73869. * @returns "DisplayPassPostProcess" string
  73870. */
  73871. getClassName(): string;
  73872. /**
  73873. * Creates the DisplayPassPostProcess
  73874. * @param name The name of the effect.
  73875. * @param options The required width/height ratio to downsize to before computing the render pass.
  73876. * @param camera The camera to apply the render pass to.
  73877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73878. * @param engine The engine which the post process will be applied. (default: current engine)
  73879. * @param reusable If the post process can be reused on the same frame. (default: false)
  73880. */
  73881. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73882. /** @hidden */
  73883. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73884. }
  73885. }
  73886. declare module BABYLON {
  73887. /** @hidden */
  73888. export var filterPixelShader: {
  73889. name: string;
  73890. shader: string;
  73891. };
  73892. }
  73893. declare module BABYLON {
  73894. /**
  73895. * Applies a kernel filter to the image
  73896. */
  73897. export class FilterPostProcess extends PostProcess {
  73898. /** The matrix to be applied to the image */
  73899. kernelMatrix: Matrix;
  73900. /**
  73901. * Gets a string identifying the name of the class
  73902. * @returns "FilterPostProcess" string
  73903. */
  73904. getClassName(): string;
  73905. /**
  73906. *
  73907. * @param name The name of the effect.
  73908. * @param kernelMatrix The matrix to be applied to the image
  73909. * @param options The required width/height ratio to downsize to before computing the render pass.
  73910. * @param camera The camera to apply the render pass to.
  73911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73912. * @param engine The engine which the post process will be applied. (default: current engine)
  73913. * @param reusable If the post process can be reused on the same frame. (default: false)
  73914. */
  73915. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73916. /** @hidden */
  73917. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73918. }
  73919. }
  73920. declare module BABYLON {
  73921. /** @hidden */
  73922. export var fxaaPixelShader: {
  73923. name: string;
  73924. shader: string;
  73925. };
  73926. }
  73927. declare module BABYLON {
  73928. /** @hidden */
  73929. export var fxaaVertexShader: {
  73930. name: string;
  73931. shader: string;
  73932. };
  73933. }
  73934. declare module BABYLON {
  73935. /**
  73936. * Fxaa post process
  73937. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73938. */
  73939. export class FxaaPostProcess extends PostProcess {
  73940. /**
  73941. * Gets a string identifying the name of the class
  73942. * @returns "FxaaPostProcess" string
  73943. */
  73944. getClassName(): string;
  73945. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73946. private _getDefines;
  73947. /** @hidden */
  73948. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73949. }
  73950. }
  73951. declare module BABYLON {
  73952. /** @hidden */
  73953. export var grainPixelShader: {
  73954. name: string;
  73955. shader: string;
  73956. };
  73957. }
  73958. declare module BABYLON {
  73959. /**
  73960. * The GrainPostProcess adds noise to the image at mid luminance levels
  73961. */
  73962. export class GrainPostProcess extends PostProcess {
  73963. /**
  73964. * The intensity of the grain added (default: 30)
  73965. */
  73966. intensity: number;
  73967. /**
  73968. * If the grain should be randomized on every frame
  73969. */
  73970. animated: boolean;
  73971. /**
  73972. * Gets a string identifying the name of the class
  73973. * @returns "GrainPostProcess" string
  73974. */
  73975. getClassName(): string;
  73976. /**
  73977. * Creates a new instance of @see GrainPostProcess
  73978. * @param name The name of the effect.
  73979. * @param options The required width/height ratio to downsize to before computing the render pass.
  73980. * @param camera The camera to apply the render pass to.
  73981. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73982. * @param engine The engine which the post process will be applied. (default: current engine)
  73983. * @param reusable If the post process can be reused on the same frame. (default: false)
  73984. * @param textureType Type of textures used when performing the post process. (default: 0)
  73985. * @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)
  73986. */
  73987. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73988. /** @hidden */
  73989. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73990. }
  73991. }
  73992. declare module BABYLON {
  73993. /** @hidden */
  73994. export var highlightsPixelShader: {
  73995. name: string;
  73996. shader: string;
  73997. };
  73998. }
  73999. declare module BABYLON {
  74000. /**
  74001. * Extracts highlights from the image
  74002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74003. */
  74004. export class HighlightsPostProcess extends PostProcess {
  74005. /**
  74006. * Gets a string identifying the name of the class
  74007. * @returns "HighlightsPostProcess" string
  74008. */
  74009. getClassName(): string;
  74010. /**
  74011. * Extracts highlights from the image
  74012. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74013. * @param name The name of the effect.
  74014. * @param options The required width/height ratio to downsize to before computing the render pass.
  74015. * @param camera The camera to apply the render pass to.
  74016. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74017. * @param engine The engine which the post process will be applied. (default: current engine)
  74018. * @param reusable If the post process can be reused on the same frame. (default: false)
  74019. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74020. */
  74021. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74022. }
  74023. }
  74024. declare module BABYLON {
  74025. /**
  74026. * Contains all parameters needed for the prepass to perform
  74027. * motion blur
  74028. */
  74029. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74030. /**
  74031. * Is motion blur enabled
  74032. */
  74033. enabled: boolean;
  74034. /**
  74035. * Name of the configuration
  74036. */
  74037. name: string;
  74038. /**
  74039. * Textures that should be present in the MRT for this effect to work
  74040. */
  74041. readonly texturesRequired: number[];
  74042. }
  74043. }
  74044. declare module BABYLON {
  74045. interface Scene {
  74046. /** @hidden (Backing field) */
  74047. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74048. /**
  74049. * Gets or Sets the current geometry buffer associated to the scene.
  74050. */
  74051. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74052. /**
  74053. * Enables a GeometryBufferRender and associates it with the scene
  74054. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74055. * @returns the GeometryBufferRenderer
  74056. */
  74057. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74058. /**
  74059. * Disables the GeometryBufferRender associated with the scene
  74060. */
  74061. disableGeometryBufferRenderer(): void;
  74062. }
  74063. /**
  74064. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74065. * in several rendering techniques.
  74066. */
  74067. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74068. /**
  74069. * The component name helpful to identify the component in the list of scene components.
  74070. */
  74071. readonly name: string;
  74072. /**
  74073. * The scene the component belongs to.
  74074. */
  74075. scene: Scene;
  74076. /**
  74077. * Creates a new instance of the component for the given scene
  74078. * @param scene Defines the scene to register the component in
  74079. */
  74080. constructor(scene: Scene);
  74081. /**
  74082. * Registers the component in a given scene
  74083. */
  74084. register(): void;
  74085. /**
  74086. * Rebuilds the elements related to this component in case of
  74087. * context lost for instance.
  74088. */
  74089. rebuild(): void;
  74090. /**
  74091. * Disposes the component and the associated ressources
  74092. */
  74093. dispose(): void;
  74094. private _gatherRenderTargets;
  74095. }
  74096. }
  74097. declare module BABYLON {
  74098. /** @hidden */
  74099. export var motionBlurPixelShader: {
  74100. name: string;
  74101. shader: string;
  74102. };
  74103. }
  74104. declare module BABYLON {
  74105. /**
  74106. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74107. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74108. * As an example, all you have to do is to create the post-process:
  74109. * var mb = new BABYLON.MotionBlurPostProcess(
  74110. * 'mb', // The name of the effect.
  74111. * scene, // The scene containing the objects to blur according to their velocity.
  74112. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74113. * camera // The camera to apply the render pass to.
  74114. * );
  74115. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74116. */
  74117. export class MotionBlurPostProcess extends PostProcess {
  74118. /**
  74119. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74120. */
  74121. motionStrength: number;
  74122. /**
  74123. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74124. */
  74125. get motionBlurSamples(): number;
  74126. /**
  74127. * Sets the number of iterations to be used for motion blur quality
  74128. */
  74129. set motionBlurSamples(samples: number);
  74130. private _motionBlurSamples;
  74131. /**
  74132. * Gets wether or not the motion blur post-process is in object based mode.
  74133. */
  74134. get isObjectBased(): boolean;
  74135. /**
  74136. * Sets wether or not the motion blur post-process is in object based mode.
  74137. */
  74138. set isObjectBased(value: boolean);
  74139. private _isObjectBased;
  74140. private _forceGeometryBuffer;
  74141. private _geometryBufferRenderer;
  74142. private _prePassRenderer;
  74143. private _invViewProjection;
  74144. private _previousViewProjection;
  74145. /**
  74146. * Gets a string identifying the name of the class
  74147. * @returns "MotionBlurPostProcess" string
  74148. */
  74149. getClassName(): string;
  74150. /**
  74151. * Creates a new instance MotionBlurPostProcess
  74152. * @param name The name of the effect.
  74153. * @param scene The scene containing the objects to blur according to their velocity.
  74154. * @param options The required width/height ratio to downsize to before computing the render pass.
  74155. * @param camera The camera to apply the render pass to.
  74156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74157. * @param engine The engine which the post process will be applied. (default: current engine)
  74158. * @param reusable If the post process can be reused on the same frame. (default: false)
  74159. * @param textureType Type of textures used when performing the post process. (default: 0)
  74160. * @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)
  74161. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74162. */
  74163. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74164. /**
  74165. * Excludes the given skinned mesh from computing bones velocities.
  74166. * 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.
  74167. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74168. */
  74169. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74170. /**
  74171. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74172. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74173. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74174. */
  74175. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74176. /**
  74177. * Disposes the post process.
  74178. * @param camera The camera to dispose the post process on.
  74179. */
  74180. dispose(camera?: Camera): void;
  74181. /**
  74182. * Called on the mode changed (object based or screen based).
  74183. */
  74184. private _applyMode;
  74185. /**
  74186. * Called on the effect is applied when the motion blur post-process is in object based mode.
  74187. */
  74188. private _onApplyObjectBased;
  74189. /**
  74190. * Called on the effect is applied when the motion blur post-process is in screen based mode.
  74191. */
  74192. private _onApplyScreenBased;
  74193. /**
  74194. * Called on the effect must be updated (changed mode, samples count, etc.).
  74195. */
  74196. private _updateEffect;
  74197. /** @hidden */
  74198. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74199. }
  74200. }
  74201. declare module BABYLON {
  74202. /** @hidden */
  74203. export var refractionPixelShader: {
  74204. name: string;
  74205. shader: string;
  74206. };
  74207. }
  74208. declare module BABYLON {
  74209. /**
  74210. * Post process which applies a refractin texture
  74211. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74212. */
  74213. export class RefractionPostProcess extends PostProcess {
  74214. private _refTexture;
  74215. private _ownRefractionTexture;
  74216. /** the base color of the refraction (used to taint the rendering) */
  74217. color: Color3;
  74218. /** simulated refraction depth */
  74219. depth: number;
  74220. /** the coefficient of the base color (0 to remove base color tainting) */
  74221. colorLevel: number;
  74222. /** Gets the url used to load the refraction texture */
  74223. refractionTextureUrl: string;
  74224. /**
  74225. * Gets or sets the refraction texture
  74226. * Please note that you are responsible for disposing the texture if you set it manually
  74227. */
  74228. get refractionTexture(): Texture;
  74229. set refractionTexture(value: Texture);
  74230. /**
  74231. * Gets a string identifying the name of the class
  74232. * @returns "RefractionPostProcess" string
  74233. */
  74234. getClassName(): string;
  74235. /**
  74236. * Initializes the RefractionPostProcess
  74237. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74238. * @param name The name of the effect.
  74239. * @param refractionTextureUrl Url of the refraction texture to use
  74240. * @param color the base color of the refraction (used to taint the rendering)
  74241. * @param depth simulated refraction depth
  74242. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74243. * @param camera The camera to apply the render pass to.
  74244. * @param options The required width/height ratio to downsize to before computing the render pass.
  74245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74246. * @param engine The engine which the post process will be applied. (default: current engine)
  74247. * @param reusable If the post process can be reused on the same frame. (default: false)
  74248. */
  74249. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74250. /**
  74251. * Disposes of the post process
  74252. * @param camera Camera to dispose post process on
  74253. */
  74254. dispose(camera: Camera): void;
  74255. /** @hidden */
  74256. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74257. }
  74258. }
  74259. declare module BABYLON {
  74260. /** @hidden */
  74261. export var sharpenPixelShader: {
  74262. name: string;
  74263. shader: string;
  74264. };
  74265. }
  74266. declare module BABYLON {
  74267. /**
  74268. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74269. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74270. */
  74271. export class SharpenPostProcess extends PostProcess {
  74272. /**
  74273. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74274. */
  74275. colorAmount: number;
  74276. /**
  74277. * How much sharpness should be applied (default: 0.3)
  74278. */
  74279. edgeAmount: number;
  74280. /**
  74281. * Gets a string identifying the name of the class
  74282. * @returns "SharpenPostProcess" string
  74283. */
  74284. getClassName(): string;
  74285. /**
  74286. * Creates a new instance ConvolutionPostProcess
  74287. * @param name The name of the effect.
  74288. * @param options The required width/height ratio to downsize to before computing the render pass.
  74289. * @param camera The camera to apply the render pass to.
  74290. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74291. * @param engine The engine which the post process will be applied. (default: current engine)
  74292. * @param reusable If the post process can be reused on the same frame. (default: false)
  74293. * @param textureType Type of textures used when performing the post process. (default: 0)
  74294. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  74295. */
  74296. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74297. /** @hidden */
  74298. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /**
  74303. * PostProcessRenderPipeline
  74304. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74305. */
  74306. export class PostProcessRenderPipeline {
  74307. private engine;
  74308. private _renderEffects;
  74309. private _renderEffectsForIsolatedPass;
  74310. /**
  74311. * List of inspectable custom properties (used by the Inspector)
  74312. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74313. */
  74314. inspectableCustomProperties: IInspectable[];
  74315. /**
  74316. * @hidden
  74317. */
  74318. protected _cameras: Camera[];
  74319. /** @hidden */
  74320. _name: string;
  74321. /**
  74322. * Gets pipeline name
  74323. */
  74324. get name(): string;
  74325. /** Gets the list of attached cameras */
  74326. get cameras(): Camera[];
  74327. /**
  74328. * Initializes a PostProcessRenderPipeline
  74329. * @param engine engine to add the pipeline to
  74330. * @param name name of the pipeline
  74331. */
  74332. constructor(engine: Engine, name: string);
  74333. /**
  74334. * Gets the class name
  74335. * @returns "PostProcessRenderPipeline"
  74336. */
  74337. getClassName(): string;
  74338. /**
  74339. * If all the render effects in the pipeline are supported
  74340. */
  74341. get isSupported(): boolean;
  74342. /**
  74343. * Adds an effect to the pipeline
  74344. * @param renderEffect the effect to add
  74345. */
  74346. addEffect(renderEffect: PostProcessRenderEffect): void;
  74347. /** @hidden */
  74348. _rebuild(): void;
  74349. /** @hidden */
  74350. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74351. /** @hidden */
  74352. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74353. /** @hidden */
  74354. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74355. /** @hidden */
  74356. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74357. /** @hidden */
  74358. _attachCameras(cameras: Camera, unique: boolean): void;
  74359. /** @hidden */
  74360. _attachCameras(cameras: Camera[], unique: boolean): void;
  74361. /** @hidden */
  74362. _detachCameras(cameras: Camera): void;
  74363. /** @hidden */
  74364. _detachCameras(cameras: Nullable<Camera[]>): void;
  74365. /** @hidden */
  74366. _update(): void;
  74367. /** @hidden */
  74368. _reset(): void;
  74369. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74370. /**
  74371. * Sets the required values to the prepass renderer.
  74372. * @param prePassRenderer defines the prepass renderer to setup.
  74373. * @returns true if the pre pass is needed.
  74374. */
  74375. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74376. /**
  74377. * Disposes of the pipeline
  74378. */
  74379. dispose(): void;
  74380. }
  74381. }
  74382. declare module BABYLON {
  74383. /**
  74384. * PostProcessRenderPipelineManager class
  74385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74386. */
  74387. export class PostProcessRenderPipelineManager {
  74388. private _renderPipelines;
  74389. /**
  74390. * Initializes a PostProcessRenderPipelineManager
  74391. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74392. */
  74393. constructor();
  74394. /**
  74395. * Gets the list of supported render pipelines
  74396. */
  74397. get supportedPipelines(): PostProcessRenderPipeline[];
  74398. /**
  74399. * Adds a pipeline to the manager
  74400. * @param renderPipeline The pipeline to add
  74401. */
  74402. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74403. /**
  74404. * Attaches a camera to the pipeline
  74405. * @param renderPipelineName The name of the pipeline to attach to
  74406. * @param cameras the camera to attach
  74407. * @param unique if the camera can be attached multiple times to the pipeline
  74408. */
  74409. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74410. /**
  74411. * Detaches a camera from the pipeline
  74412. * @param renderPipelineName The name of the pipeline to detach from
  74413. * @param cameras the camera to detach
  74414. */
  74415. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74416. /**
  74417. * Enables an effect by name on a pipeline
  74418. * @param renderPipelineName the name of the pipeline to enable the effect in
  74419. * @param renderEffectName the name of the effect to enable
  74420. * @param cameras the cameras that the effect should be enabled on
  74421. */
  74422. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74423. /**
  74424. * Disables an effect by name on a pipeline
  74425. * @param renderPipelineName the name of the pipeline to disable the effect in
  74426. * @param renderEffectName the name of the effect to disable
  74427. * @param cameras the cameras that the effect should be disabled on
  74428. */
  74429. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74430. /**
  74431. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74432. */
  74433. update(): void;
  74434. /** @hidden */
  74435. _rebuild(): void;
  74436. /**
  74437. * Disposes of the manager and pipelines
  74438. */
  74439. dispose(): void;
  74440. }
  74441. }
  74442. declare module BABYLON {
  74443. interface Scene {
  74444. /** @hidden (Backing field) */
  74445. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74446. /**
  74447. * Gets the postprocess render pipeline manager
  74448. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74449. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74450. */
  74451. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74452. }
  74453. /**
  74454. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74455. */
  74456. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74457. /**
  74458. * The component name helpfull to identify the component in the list of scene components.
  74459. */
  74460. readonly name: string;
  74461. /**
  74462. * The scene the component belongs to.
  74463. */
  74464. scene: Scene;
  74465. /**
  74466. * Creates a new instance of the component for the given scene
  74467. * @param scene Defines the scene to register the component in
  74468. */
  74469. constructor(scene: Scene);
  74470. /**
  74471. * Registers the component in a given scene
  74472. */
  74473. register(): void;
  74474. /**
  74475. * Rebuilds the elements related to this component in case of
  74476. * context lost for instance.
  74477. */
  74478. rebuild(): void;
  74479. /**
  74480. * Disposes the component and the associated ressources
  74481. */
  74482. dispose(): void;
  74483. private _gatherRenderTargets;
  74484. }
  74485. }
  74486. declare module BABYLON {
  74487. /**
  74488. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74489. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74490. */
  74491. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74492. private _scene;
  74493. private _camerasToBeAttached;
  74494. /**
  74495. * ID of the sharpen post process,
  74496. */
  74497. private readonly SharpenPostProcessId;
  74498. /**
  74499. * @ignore
  74500. * ID of the image processing post process;
  74501. */
  74502. readonly ImageProcessingPostProcessId: string;
  74503. /**
  74504. * @ignore
  74505. * ID of the Fast Approximate Anti-Aliasing post process;
  74506. */
  74507. readonly FxaaPostProcessId: string;
  74508. /**
  74509. * ID of the chromatic aberration post process,
  74510. */
  74511. private readonly ChromaticAberrationPostProcessId;
  74512. /**
  74513. * ID of the grain post process
  74514. */
  74515. private readonly GrainPostProcessId;
  74516. /**
  74517. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74518. */
  74519. sharpen: SharpenPostProcess;
  74520. private _sharpenEffect;
  74521. private bloom;
  74522. /**
  74523. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74524. */
  74525. depthOfField: DepthOfFieldEffect;
  74526. /**
  74527. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74528. */
  74529. fxaa: FxaaPostProcess;
  74530. /**
  74531. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74532. */
  74533. imageProcessing: ImageProcessingPostProcess;
  74534. /**
  74535. * Chromatic aberration post process which will shift rgb colors in the image
  74536. */
  74537. chromaticAberration: ChromaticAberrationPostProcess;
  74538. private _chromaticAberrationEffect;
  74539. /**
  74540. * Grain post process which add noise to the image
  74541. */
  74542. grain: GrainPostProcess;
  74543. private _grainEffect;
  74544. /**
  74545. * Glow post process which adds a glow to emissive areas of the image
  74546. */
  74547. private _glowLayer;
  74548. /**
  74549. * Animations which can be used to tweak settings over a period of time
  74550. */
  74551. animations: Animation[];
  74552. private _imageProcessingConfigurationObserver;
  74553. private _sharpenEnabled;
  74554. private _bloomEnabled;
  74555. private _depthOfFieldEnabled;
  74556. private _depthOfFieldBlurLevel;
  74557. private _fxaaEnabled;
  74558. private _imageProcessingEnabled;
  74559. private _defaultPipelineTextureType;
  74560. private _bloomScale;
  74561. private _chromaticAberrationEnabled;
  74562. private _grainEnabled;
  74563. private _buildAllowed;
  74564. /**
  74565. * This is triggered each time the pipeline has been built.
  74566. */
  74567. onBuildObservable: Observable<DefaultRenderingPipeline>;
  74568. /**
  74569. * Gets active scene
  74570. */
  74571. get scene(): Scene;
  74572. /**
  74573. * Enable or disable the sharpen process from the pipeline
  74574. */
  74575. set sharpenEnabled(enabled: boolean);
  74576. get sharpenEnabled(): boolean;
  74577. private _resizeObserver;
  74578. private _hardwareScaleLevel;
  74579. private _bloomKernel;
  74580. /**
  74581. * Specifies the size of the bloom blur kernel, relative to the final output size
  74582. */
  74583. get bloomKernel(): number;
  74584. set bloomKernel(value: number);
  74585. /**
  74586. * Specifies the weight of the bloom in the final rendering
  74587. */
  74588. private _bloomWeight;
  74589. /**
  74590. * Specifies the luma threshold for the area that will be blurred by the bloom
  74591. */
  74592. private _bloomThreshold;
  74593. private _hdr;
  74594. /**
  74595. * The strength of the bloom.
  74596. */
  74597. set bloomWeight(value: number);
  74598. get bloomWeight(): number;
  74599. /**
  74600. * The strength of the bloom.
  74601. */
  74602. set bloomThreshold(value: number);
  74603. get bloomThreshold(): number;
  74604. /**
  74605. * The scale of the bloom, lower value will provide better performance.
  74606. */
  74607. set bloomScale(value: number);
  74608. get bloomScale(): number;
  74609. /**
  74610. * Enable or disable the bloom from the pipeline
  74611. */
  74612. set bloomEnabled(enabled: boolean);
  74613. get bloomEnabled(): boolean;
  74614. private _rebuildBloom;
  74615. /**
  74616. * If the depth of field is enabled.
  74617. */
  74618. get depthOfFieldEnabled(): boolean;
  74619. set depthOfFieldEnabled(enabled: boolean);
  74620. /**
  74621. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74622. */
  74623. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74624. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74625. /**
  74626. * If the anti aliasing is enabled.
  74627. */
  74628. set fxaaEnabled(enabled: boolean);
  74629. get fxaaEnabled(): boolean;
  74630. private _samples;
  74631. /**
  74632. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74633. */
  74634. set samples(sampleCount: number);
  74635. get samples(): number;
  74636. /**
  74637. * If image processing is enabled.
  74638. */
  74639. set imageProcessingEnabled(enabled: boolean);
  74640. get imageProcessingEnabled(): boolean;
  74641. /**
  74642. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74643. */
  74644. set glowLayerEnabled(enabled: boolean);
  74645. get glowLayerEnabled(): boolean;
  74646. /**
  74647. * Gets the glow layer (or null if not defined)
  74648. */
  74649. get glowLayer(): Nullable<GlowLayer>;
  74650. /**
  74651. * Enable or disable the chromaticAberration process from the pipeline
  74652. */
  74653. set chromaticAberrationEnabled(enabled: boolean);
  74654. get chromaticAberrationEnabled(): boolean;
  74655. /**
  74656. * Enable or disable the grain process from the pipeline
  74657. */
  74658. set grainEnabled(enabled: boolean);
  74659. get grainEnabled(): boolean;
  74660. /**
  74661. * @constructor
  74662. * @param name - The rendering pipeline name (default: "")
  74663. * @param hdr - If high dynamic range textures should be used (default: true)
  74664. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74665. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74666. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74667. */
  74668. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74669. /**
  74670. * Get the class name
  74671. * @returns "DefaultRenderingPipeline"
  74672. */
  74673. getClassName(): string;
  74674. /**
  74675. * Force the compilation of the entire pipeline.
  74676. */
  74677. prepare(): void;
  74678. private _hasCleared;
  74679. private _prevPostProcess;
  74680. private _prevPrevPostProcess;
  74681. private _setAutoClearAndTextureSharing;
  74682. private _depthOfFieldSceneObserver;
  74683. private _buildPipeline;
  74684. private _disposePostProcesses;
  74685. /**
  74686. * Adds a camera to the pipeline
  74687. * @param camera the camera to be added
  74688. */
  74689. addCamera(camera: Camera): void;
  74690. /**
  74691. * Removes a camera from the pipeline
  74692. * @param camera the camera to remove
  74693. */
  74694. removeCamera(camera: Camera): void;
  74695. /**
  74696. * Dispose of the pipeline and stop all post processes
  74697. */
  74698. dispose(): void;
  74699. /**
  74700. * Serialize the rendering pipeline (Used when exporting)
  74701. * @returns the serialized object
  74702. */
  74703. serialize(): any;
  74704. /**
  74705. * Parse the serialized pipeline
  74706. * @param source Source pipeline.
  74707. * @param scene The scene to load the pipeline to.
  74708. * @param rootUrl The URL of the serialized pipeline.
  74709. * @returns An instantiated pipeline from the serialized object.
  74710. */
  74711. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74712. }
  74713. }
  74714. declare module BABYLON {
  74715. /** @hidden */
  74716. export var lensHighlightsPixelShader: {
  74717. name: string;
  74718. shader: string;
  74719. };
  74720. }
  74721. declare module BABYLON {
  74722. /** @hidden */
  74723. export var depthOfFieldPixelShader: {
  74724. name: string;
  74725. shader: string;
  74726. };
  74727. }
  74728. declare module BABYLON {
  74729. /**
  74730. * BABYLON.JS Chromatic Aberration GLSL Shader
  74731. * Author: Olivier Guyot
  74732. * Separates very slightly R, G and B colors on the edges of the screen
  74733. * Inspired by Francois Tarlier & Martins Upitis
  74734. */
  74735. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74736. /**
  74737. * @ignore
  74738. * The chromatic aberration PostProcess id in the pipeline
  74739. */
  74740. LensChromaticAberrationEffect: string;
  74741. /**
  74742. * @ignore
  74743. * The highlights enhancing PostProcess id in the pipeline
  74744. */
  74745. HighlightsEnhancingEffect: string;
  74746. /**
  74747. * @ignore
  74748. * The depth-of-field PostProcess id in the pipeline
  74749. */
  74750. LensDepthOfFieldEffect: string;
  74751. private _scene;
  74752. private _depthTexture;
  74753. private _grainTexture;
  74754. private _chromaticAberrationPostProcess;
  74755. private _highlightsPostProcess;
  74756. private _depthOfFieldPostProcess;
  74757. private _edgeBlur;
  74758. private _grainAmount;
  74759. private _chromaticAberration;
  74760. private _distortion;
  74761. private _highlightsGain;
  74762. private _highlightsThreshold;
  74763. private _dofDistance;
  74764. private _dofAperture;
  74765. private _dofDarken;
  74766. private _dofPentagon;
  74767. private _blurNoise;
  74768. /**
  74769. * @constructor
  74770. *
  74771. * Effect parameters are as follow:
  74772. * {
  74773. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74774. * edge_blur: number; // from 0 to x (1 for realism)
  74775. * distortion: number; // from 0 to x (1 for realism)
  74776. * grain_amount: number; // from 0 to 1
  74777. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74778. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74779. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74780. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74781. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74782. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74783. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74784. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74785. * }
  74786. * Note: if an effect parameter is unset, effect is disabled
  74787. *
  74788. * @param name The rendering pipeline name
  74789. * @param parameters - An object containing all parameters (see above)
  74790. * @param scene The scene linked to this pipeline
  74791. * @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)
  74792. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74793. */
  74794. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74795. /**
  74796. * Get the class name
  74797. * @returns "LensRenderingPipeline"
  74798. */
  74799. getClassName(): string;
  74800. /**
  74801. * Gets associated scene
  74802. */
  74803. get scene(): Scene;
  74804. /**
  74805. * Gets or sets the edge blur
  74806. */
  74807. get edgeBlur(): number;
  74808. set edgeBlur(value: number);
  74809. /**
  74810. * Gets or sets the grain amount
  74811. */
  74812. get grainAmount(): number;
  74813. set grainAmount(value: number);
  74814. /**
  74815. * Gets or sets the chromatic aberration amount
  74816. */
  74817. get chromaticAberration(): number;
  74818. set chromaticAberration(value: number);
  74819. /**
  74820. * Gets or sets the depth of field aperture
  74821. */
  74822. get dofAperture(): number;
  74823. set dofAperture(value: number);
  74824. /**
  74825. * Gets or sets the edge distortion
  74826. */
  74827. get edgeDistortion(): number;
  74828. set edgeDistortion(value: number);
  74829. /**
  74830. * Gets or sets the depth of field distortion
  74831. */
  74832. get dofDistortion(): number;
  74833. set dofDistortion(value: number);
  74834. /**
  74835. * Gets or sets the darken out of focus amount
  74836. */
  74837. get darkenOutOfFocus(): number;
  74838. set darkenOutOfFocus(value: number);
  74839. /**
  74840. * Gets or sets a boolean indicating if blur noise is enabled
  74841. */
  74842. get blurNoise(): boolean;
  74843. set blurNoise(value: boolean);
  74844. /**
  74845. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74846. */
  74847. get pentagonBokeh(): boolean;
  74848. set pentagonBokeh(value: boolean);
  74849. /**
  74850. * Gets or sets the highlight grain amount
  74851. */
  74852. get highlightsGain(): number;
  74853. set highlightsGain(value: number);
  74854. /**
  74855. * Gets or sets the highlight threshold
  74856. */
  74857. get highlightsThreshold(): number;
  74858. set highlightsThreshold(value: number);
  74859. /**
  74860. * Sets the amount of blur at the edges
  74861. * @param amount blur amount
  74862. */
  74863. setEdgeBlur(amount: number): void;
  74864. /**
  74865. * Sets edge blur to 0
  74866. */
  74867. disableEdgeBlur(): void;
  74868. /**
  74869. * Sets the amout of grain
  74870. * @param amount Amount of grain
  74871. */
  74872. setGrainAmount(amount: number): void;
  74873. /**
  74874. * Set grain amount to 0
  74875. */
  74876. disableGrain(): void;
  74877. /**
  74878. * Sets the chromatic aberration amount
  74879. * @param amount amount of chromatic aberration
  74880. */
  74881. setChromaticAberration(amount: number): void;
  74882. /**
  74883. * Sets chromatic aberration amount to 0
  74884. */
  74885. disableChromaticAberration(): void;
  74886. /**
  74887. * Sets the EdgeDistortion amount
  74888. * @param amount amount of EdgeDistortion
  74889. */
  74890. setEdgeDistortion(amount: number): void;
  74891. /**
  74892. * Sets edge distortion to 0
  74893. */
  74894. disableEdgeDistortion(): void;
  74895. /**
  74896. * Sets the FocusDistance amount
  74897. * @param amount amount of FocusDistance
  74898. */
  74899. setFocusDistance(amount: number): void;
  74900. /**
  74901. * Disables depth of field
  74902. */
  74903. disableDepthOfField(): void;
  74904. /**
  74905. * Sets the Aperture amount
  74906. * @param amount amount of Aperture
  74907. */
  74908. setAperture(amount: number): void;
  74909. /**
  74910. * Sets the DarkenOutOfFocus amount
  74911. * @param amount amount of DarkenOutOfFocus
  74912. */
  74913. setDarkenOutOfFocus(amount: number): void;
  74914. private _pentagonBokehIsEnabled;
  74915. /**
  74916. * Creates a pentagon bokeh effect
  74917. */
  74918. enablePentagonBokeh(): void;
  74919. /**
  74920. * Disables the pentagon bokeh effect
  74921. */
  74922. disablePentagonBokeh(): void;
  74923. /**
  74924. * Enables noise blur
  74925. */
  74926. enableNoiseBlur(): void;
  74927. /**
  74928. * Disables noise blur
  74929. */
  74930. disableNoiseBlur(): void;
  74931. /**
  74932. * Sets the HighlightsGain amount
  74933. * @param amount amount of HighlightsGain
  74934. */
  74935. setHighlightsGain(amount: number): void;
  74936. /**
  74937. * Sets the HighlightsThreshold amount
  74938. * @param amount amount of HighlightsThreshold
  74939. */
  74940. setHighlightsThreshold(amount: number): void;
  74941. /**
  74942. * Disables highlights
  74943. */
  74944. disableHighlights(): void;
  74945. /**
  74946. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74947. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74948. */
  74949. dispose(disableDepthRender?: boolean): void;
  74950. private _createChromaticAberrationPostProcess;
  74951. private _createHighlightsPostProcess;
  74952. private _createDepthOfFieldPostProcess;
  74953. private _createGrainTexture;
  74954. }
  74955. }
  74956. declare module BABYLON {
  74957. /**
  74958. * Contains all parameters needed for the prepass to perform
  74959. * screen space subsurface scattering
  74960. */
  74961. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74962. /**
  74963. * Is subsurface enabled
  74964. */
  74965. enabled: boolean;
  74966. /**
  74967. * Name of the configuration
  74968. */
  74969. name: string;
  74970. /**
  74971. * Textures that should be present in the MRT for this effect to work
  74972. */
  74973. readonly texturesRequired: number[];
  74974. }
  74975. }
  74976. declare module BABYLON {
  74977. /** @hidden */
  74978. export var ssao2PixelShader: {
  74979. name: string;
  74980. shader: string;
  74981. };
  74982. }
  74983. declare module BABYLON {
  74984. /** @hidden */
  74985. export var ssaoCombinePixelShader: {
  74986. name: string;
  74987. shader: string;
  74988. };
  74989. }
  74990. declare module BABYLON {
  74991. /**
  74992. * Render pipeline to produce ssao effect
  74993. */
  74994. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74995. /**
  74996. * @ignore
  74997. * The PassPostProcess id in the pipeline that contains the original scene color
  74998. */
  74999. SSAOOriginalSceneColorEffect: string;
  75000. /**
  75001. * @ignore
  75002. * The SSAO PostProcess id in the pipeline
  75003. */
  75004. SSAORenderEffect: string;
  75005. /**
  75006. * @ignore
  75007. * The horizontal blur PostProcess id in the pipeline
  75008. */
  75009. SSAOBlurHRenderEffect: string;
  75010. /**
  75011. * @ignore
  75012. * The vertical blur PostProcess id in the pipeline
  75013. */
  75014. SSAOBlurVRenderEffect: string;
  75015. /**
  75016. * @ignore
  75017. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75018. */
  75019. SSAOCombineRenderEffect: string;
  75020. /**
  75021. * The output strength of the SSAO post-process. Default value is 1.0.
  75022. */
  75023. totalStrength: number;
  75024. /**
  75025. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75026. */
  75027. maxZ: number;
  75028. /**
  75029. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75030. */
  75031. minZAspect: number;
  75032. private _samples;
  75033. /**
  75034. * Number of samples used for the SSAO calculations. Default value is 8
  75035. */
  75036. set samples(n: number);
  75037. get samples(): number;
  75038. private _textureSamples;
  75039. /**
  75040. * Number of samples to use for antialiasing
  75041. */
  75042. set textureSamples(n: number);
  75043. get textureSamples(): number;
  75044. /**
  75045. * Force rendering the geometry through geometry buffer
  75046. */
  75047. private _forceGeometryBuffer;
  75048. /**
  75049. * Ratio object used for SSAO ratio and blur ratio
  75050. */
  75051. private _ratio;
  75052. /**
  75053. * Dynamically generated sphere sampler.
  75054. */
  75055. private _sampleSphere;
  75056. /**
  75057. * Blur filter offsets
  75058. */
  75059. private _samplerOffsets;
  75060. private _expensiveBlur;
  75061. /**
  75062. * If bilateral blur should be used
  75063. */
  75064. set expensiveBlur(b: boolean);
  75065. get expensiveBlur(): boolean;
  75066. /**
  75067. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75068. */
  75069. radius: number;
  75070. /**
  75071. * The base color of the SSAO post-process
  75072. * The final result is "base + ssao" between [0, 1]
  75073. */
  75074. base: number;
  75075. /**
  75076. * Support test.
  75077. */
  75078. static get IsSupported(): boolean;
  75079. private _scene;
  75080. private _randomTexture;
  75081. private _originalColorPostProcess;
  75082. private _ssaoPostProcess;
  75083. private _blurHPostProcess;
  75084. private _blurVPostProcess;
  75085. private _ssaoCombinePostProcess;
  75086. private _prePassRenderer;
  75087. /**
  75088. * Gets active scene
  75089. */
  75090. get scene(): Scene;
  75091. /**
  75092. * @constructor
  75093. * @param name The rendering pipeline name
  75094. * @param scene The scene linked to this pipeline
  75095. * @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 }
  75096. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75097. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75098. */
  75099. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75100. /**
  75101. * Get the class name
  75102. * @returns "SSAO2RenderingPipeline"
  75103. */
  75104. getClassName(): string;
  75105. /**
  75106. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75107. */
  75108. dispose(disableGeometryBufferRenderer?: boolean): void;
  75109. private _createBlurPostProcess;
  75110. /** @hidden */
  75111. _rebuild(): void;
  75112. private _bits;
  75113. private _radicalInverse_VdC;
  75114. private _hammersley;
  75115. private _hemisphereSample_uniform;
  75116. private _generateHemisphere;
  75117. private _getDefinesForSSAO;
  75118. private static readonly ORTHO_DEPTH_PROJECTION;
  75119. private static readonly PERSPECTIVE_DEPTH_PROJECTION;
  75120. private _createSSAOPostProcess;
  75121. private _createSSAOCombinePostProcess;
  75122. private _createRandomTexture;
  75123. /**
  75124. * Serialize the rendering pipeline (Used when exporting)
  75125. * @returns the serialized object
  75126. */
  75127. serialize(): any;
  75128. /**
  75129. * Parse the serialized pipeline
  75130. * @param source Source pipeline.
  75131. * @param scene The scene to load the pipeline to.
  75132. * @param rootUrl The URL of the serialized pipeline.
  75133. * @returns An instantiated pipeline from the serialized object.
  75134. */
  75135. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75136. }
  75137. }
  75138. declare module BABYLON {
  75139. /** @hidden */
  75140. export var ssaoPixelShader: {
  75141. name: string;
  75142. shader: string;
  75143. };
  75144. }
  75145. declare module BABYLON {
  75146. /**
  75147. * Render pipeline to produce ssao effect
  75148. */
  75149. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75150. /**
  75151. * @ignore
  75152. * The PassPostProcess id in the pipeline that contains the original scene color
  75153. */
  75154. SSAOOriginalSceneColorEffect: string;
  75155. /**
  75156. * @ignore
  75157. * The SSAO PostProcess id in the pipeline
  75158. */
  75159. SSAORenderEffect: string;
  75160. /**
  75161. * @ignore
  75162. * The horizontal blur PostProcess id in the pipeline
  75163. */
  75164. SSAOBlurHRenderEffect: string;
  75165. /**
  75166. * @ignore
  75167. * The vertical blur PostProcess id in the pipeline
  75168. */
  75169. SSAOBlurVRenderEffect: string;
  75170. /**
  75171. * @ignore
  75172. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75173. */
  75174. SSAOCombineRenderEffect: string;
  75175. /**
  75176. * The output strength of the SSAO post-process. Default value is 1.0.
  75177. */
  75178. totalStrength: number;
  75179. /**
  75180. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75181. */
  75182. radius: number;
  75183. /**
  75184. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75185. * Must not be equal to fallOff and superior to fallOff.
  75186. * Default value is 0.0075
  75187. */
  75188. area: number;
  75189. /**
  75190. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75191. * Must not be equal to area and inferior to area.
  75192. * Default value is 0.000001
  75193. */
  75194. fallOff: number;
  75195. /**
  75196. * The base color of the SSAO post-process
  75197. * The final result is "base + ssao" between [0, 1]
  75198. */
  75199. base: number;
  75200. private _scene;
  75201. private _depthTexture;
  75202. private _randomTexture;
  75203. private _originalColorPostProcess;
  75204. private _ssaoPostProcess;
  75205. private _blurHPostProcess;
  75206. private _blurVPostProcess;
  75207. private _ssaoCombinePostProcess;
  75208. private _firstUpdate;
  75209. /**
  75210. * Gets active scene
  75211. */
  75212. get scene(): Scene;
  75213. /**
  75214. * @constructor
  75215. * @param name - The rendering pipeline name
  75216. * @param scene - The scene linked to this pipeline
  75217. * @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 }
  75218. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75219. */
  75220. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75221. /**
  75222. * Get the class name
  75223. * @returns "SSAORenderingPipeline"
  75224. */
  75225. getClassName(): string;
  75226. /**
  75227. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75228. */
  75229. dispose(disableDepthRender?: boolean): void;
  75230. private _createBlurPostProcess;
  75231. /** @hidden */
  75232. _rebuild(): void;
  75233. private _createSSAOPostProcess;
  75234. private _createSSAOCombinePostProcess;
  75235. private _createRandomTexture;
  75236. }
  75237. }
  75238. declare module BABYLON {
  75239. /**
  75240. * Contains all parameters needed for the prepass to perform
  75241. * screen space reflections
  75242. */
  75243. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75244. /**
  75245. * Is ssr enabled
  75246. */
  75247. enabled: boolean;
  75248. /**
  75249. * Name of the configuration
  75250. */
  75251. name: string;
  75252. /**
  75253. * Textures that should be present in the MRT for this effect to work
  75254. */
  75255. readonly texturesRequired: number[];
  75256. }
  75257. }
  75258. declare module BABYLON {
  75259. /** @hidden */
  75260. export var screenSpaceReflectionPixelShader: {
  75261. name: string;
  75262. shader: string;
  75263. };
  75264. }
  75265. declare module BABYLON {
  75266. /**
  75267. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75268. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75269. */
  75270. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75271. /**
  75272. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75273. */
  75274. threshold: number;
  75275. /**
  75276. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75277. */
  75278. strength: number;
  75279. /**
  75280. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75281. */
  75282. reflectionSpecularFalloffExponent: number;
  75283. /**
  75284. * 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]
  75285. */
  75286. step: number;
  75287. /**
  75288. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75289. */
  75290. roughnessFactor: number;
  75291. private _forceGeometryBuffer;
  75292. private _geometryBufferRenderer;
  75293. private _prePassRenderer;
  75294. private _enableSmoothReflections;
  75295. private _reflectionSamples;
  75296. private _smoothSteps;
  75297. /**
  75298. * Gets a string identifying the name of the class
  75299. * @returns "ScreenSpaceReflectionPostProcess" string
  75300. */
  75301. getClassName(): string;
  75302. /**
  75303. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75304. * @param name The name of the effect.
  75305. * @param scene The scene containing the objects to calculate reflections.
  75306. * @param options The required width/height ratio to downsize to before computing the render pass.
  75307. * @param camera The camera to apply the render pass to.
  75308. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75309. * @param engine The engine which the post process will be applied. (default: current engine)
  75310. * @param reusable If the post process can be reused on the same frame. (default: false)
  75311. * @param textureType Type of textures used when performing the post process. (default: 0)
  75312. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: true)
  75313. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75314. */
  75315. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75316. /**
  75317. * Gets wether or not smoothing reflections is enabled.
  75318. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75319. */
  75320. get enableSmoothReflections(): boolean;
  75321. /**
  75322. * Sets wether or not smoothing reflections is enabled.
  75323. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75324. */
  75325. set enableSmoothReflections(enabled: boolean);
  75326. /**
  75327. * Gets the number of samples taken while computing reflections. More samples count is high,
  75328. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75329. */
  75330. get reflectionSamples(): number;
  75331. /**
  75332. * Sets the number of samples taken while computing reflections. More samples count is high,
  75333. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75334. */
  75335. set reflectionSamples(samples: number);
  75336. /**
  75337. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75338. * more the post-process will require GPU power and can generate a drop in FPS.
  75339. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75340. */
  75341. get smoothSteps(): number;
  75342. set smoothSteps(steps: number);
  75343. private _updateEffectDefines;
  75344. /** @hidden */
  75345. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75346. }
  75347. }
  75348. declare module BABYLON {
  75349. /** @hidden */
  75350. export var standardPixelShader: {
  75351. name: string;
  75352. shader: string;
  75353. };
  75354. }
  75355. declare module BABYLON {
  75356. /**
  75357. * Standard rendering pipeline
  75358. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75359. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75360. */
  75361. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75362. /**
  75363. * Public members
  75364. */
  75365. /**
  75366. * Post-process which contains the original scene color before the pipeline applies all the effects
  75367. */
  75368. originalPostProcess: Nullable<PostProcess>;
  75369. /**
  75370. * Post-process used to down scale an image x4
  75371. */
  75372. downSampleX4PostProcess: Nullable<PostProcess>;
  75373. /**
  75374. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75375. */
  75376. brightPassPostProcess: Nullable<PostProcess>;
  75377. /**
  75378. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75379. */
  75380. blurHPostProcesses: PostProcess[];
  75381. /**
  75382. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75383. */
  75384. blurVPostProcesses: PostProcess[];
  75385. /**
  75386. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75387. */
  75388. textureAdderPostProcess: Nullable<PostProcess>;
  75389. /**
  75390. * Post-process used to create volumetric lighting effect
  75391. */
  75392. volumetricLightPostProcess: Nullable<PostProcess>;
  75393. /**
  75394. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75395. */
  75396. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75397. /**
  75398. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75399. */
  75400. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75401. /**
  75402. * Post-process used to merge the volumetric light effect and the real scene color
  75403. */
  75404. volumetricLightMergePostProces: Nullable<PostProcess>;
  75405. /**
  75406. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75407. */
  75408. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75409. /**
  75410. * Base post-process used to calculate the average luminance of the final image for HDR
  75411. */
  75412. luminancePostProcess: Nullable<PostProcess>;
  75413. /**
  75414. * Post-processes used to create down sample post-processes in order to get
  75415. * the average luminance of the final image for HDR
  75416. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75417. */
  75418. luminanceDownSamplePostProcesses: PostProcess[];
  75419. /**
  75420. * Post-process used to create a HDR effect (light adaptation)
  75421. */
  75422. hdrPostProcess: Nullable<PostProcess>;
  75423. /**
  75424. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75425. */
  75426. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75427. /**
  75428. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75429. */
  75430. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75431. /**
  75432. * Post-process used to merge the final HDR post-process and the real scene color
  75433. */
  75434. hdrFinalPostProcess: Nullable<PostProcess>;
  75435. /**
  75436. * Post-process used to create a lens flare effect
  75437. */
  75438. lensFlarePostProcess: Nullable<PostProcess>;
  75439. /**
  75440. * Post-process that merges the result of the lens flare post-process and the real scene color
  75441. */
  75442. lensFlareComposePostProcess: Nullable<PostProcess>;
  75443. /**
  75444. * Post-process used to create a motion blur effect
  75445. */
  75446. motionBlurPostProcess: Nullable<PostProcess>;
  75447. /**
  75448. * Post-process used to create a depth of field effect
  75449. */
  75450. depthOfFieldPostProcess: Nullable<PostProcess>;
  75451. /**
  75452. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75453. */
  75454. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75455. /**
  75456. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75457. */
  75458. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75459. /**
  75460. * Represents the brightness threshold in order to configure the illuminated surfaces
  75461. */
  75462. brightThreshold: number;
  75463. /**
  75464. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75465. */
  75466. blurWidth: number;
  75467. /**
  75468. * Sets if the blur for highlighted surfaces must be only horizontal
  75469. */
  75470. horizontalBlur: boolean;
  75471. /**
  75472. * Gets the overall exposure used by the pipeline
  75473. */
  75474. get exposure(): number;
  75475. /**
  75476. * Sets the overall exposure used by the pipeline
  75477. */
  75478. set exposure(value: number);
  75479. /**
  75480. * Texture used typically to simulate "dirty" on camera lens
  75481. */
  75482. lensTexture: Nullable<Texture>;
  75483. /**
  75484. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75485. */
  75486. volumetricLightCoefficient: number;
  75487. /**
  75488. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75489. */
  75490. volumetricLightPower: number;
  75491. /**
  75492. * Used the set the blur intensity to smooth the volumetric lights
  75493. */
  75494. volumetricLightBlurScale: number;
  75495. /**
  75496. * Light (spot or directional) used to generate the volumetric lights rays
  75497. * The source light must have a shadow generate so the pipeline can get its
  75498. * depth map
  75499. */
  75500. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75501. /**
  75502. * For eye adaptation, represents the minimum luminance the eye can see
  75503. */
  75504. hdrMinimumLuminance: number;
  75505. /**
  75506. * For eye adaptation, represents the decrease luminance speed
  75507. */
  75508. hdrDecreaseRate: number;
  75509. /**
  75510. * For eye adaptation, represents the increase luminance speed
  75511. */
  75512. hdrIncreaseRate: number;
  75513. /**
  75514. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75515. */
  75516. get hdrAutoExposure(): boolean;
  75517. /**
  75518. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75519. */
  75520. set hdrAutoExposure(value: boolean);
  75521. /**
  75522. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75523. */
  75524. lensColorTexture: Nullable<Texture>;
  75525. /**
  75526. * The overall strengh for the lens flare effect
  75527. */
  75528. lensFlareStrength: number;
  75529. /**
  75530. * Dispersion coefficient for lens flare ghosts
  75531. */
  75532. lensFlareGhostDispersal: number;
  75533. /**
  75534. * Main lens flare halo width
  75535. */
  75536. lensFlareHaloWidth: number;
  75537. /**
  75538. * Based on the lens distortion effect, defines how much the lens flare result
  75539. * is distorted
  75540. */
  75541. lensFlareDistortionStrength: number;
  75542. /**
  75543. * Configures the blur intensity used for for lens flare (halo)
  75544. */
  75545. lensFlareBlurWidth: number;
  75546. /**
  75547. * Lens star texture must be used to simulate rays on the flares and is available
  75548. * in the documentation
  75549. */
  75550. lensStarTexture: Nullable<Texture>;
  75551. /**
  75552. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75553. * flare effect by taking account of the dirt texture
  75554. */
  75555. lensFlareDirtTexture: Nullable<Texture>;
  75556. /**
  75557. * Represents the focal length for the depth of field effect
  75558. */
  75559. depthOfFieldDistance: number;
  75560. /**
  75561. * Represents the blur intensity for the blurred part of the depth of field effect
  75562. */
  75563. depthOfFieldBlurWidth: number;
  75564. /**
  75565. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75566. */
  75567. get motionStrength(): number;
  75568. /**
  75569. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75570. */
  75571. set motionStrength(strength: number);
  75572. /**
  75573. * Gets wether or not the motion blur post-process is object based or screen based.
  75574. */
  75575. get objectBasedMotionBlur(): boolean;
  75576. /**
  75577. * Sets wether or not the motion blur post-process should be object based or screen based
  75578. */
  75579. set objectBasedMotionBlur(value: boolean);
  75580. /**
  75581. * List of animations for the pipeline (IAnimatable implementation)
  75582. */
  75583. animations: Animation[];
  75584. /**
  75585. * Private members
  75586. */
  75587. private _scene;
  75588. private _currentDepthOfFieldSource;
  75589. private _basePostProcess;
  75590. private _fixedExposure;
  75591. private _currentExposure;
  75592. private _hdrAutoExposure;
  75593. private _hdrCurrentLuminance;
  75594. private _motionStrength;
  75595. private _isObjectBasedMotionBlur;
  75596. private _floatTextureType;
  75597. private _camerasToBeAttached;
  75598. private _ratio;
  75599. private _bloomEnabled;
  75600. private _depthOfFieldEnabled;
  75601. private _vlsEnabled;
  75602. private _lensFlareEnabled;
  75603. private _hdrEnabled;
  75604. private _motionBlurEnabled;
  75605. private _fxaaEnabled;
  75606. private _screenSpaceReflectionsEnabled;
  75607. private _motionBlurSamples;
  75608. private _volumetricLightStepsCount;
  75609. private _samples;
  75610. /**
  75611. * @ignore
  75612. * Specifies if the bloom pipeline is enabled
  75613. */
  75614. get BloomEnabled(): boolean;
  75615. set BloomEnabled(enabled: boolean);
  75616. /**
  75617. * @ignore
  75618. * Specifies if the depth of field pipeline is enabed
  75619. */
  75620. get DepthOfFieldEnabled(): boolean;
  75621. set DepthOfFieldEnabled(enabled: boolean);
  75622. /**
  75623. * @ignore
  75624. * Specifies if the lens flare pipeline is enabed
  75625. */
  75626. get LensFlareEnabled(): boolean;
  75627. set LensFlareEnabled(enabled: boolean);
  75628. /**
  75629. * @ignore
  75630. * Specifies if the HDR pipeline is enabled
  75631. */
  75632. get HDREnabled(): boolean;
  75633. set HDREnabled(enabled: boolean);
  75634. /**
  75635. * @ignore
  75636. * Specifies if the volumetric lights scattering effect is enabled
  75637. */
  75638. get VLSEnabled(): boolean;
  75639. set VLSEnabled(enabled: boolean);
  75640. /**
  75641. * @ignore
  75642. * Specifies if the motion blur effect is enabled
  75643. */
  75644. get MotionBlurEnabled(): boolean;
  75645. set MotionBlurEnabled(enabled: boolean);
  75646. /**
  75647. * Specifies if anti-aliasing is enabled
  75648. */
  75649. get fxaaEnabled(): boolean;
  75650. set fxaaEnabled(enabled: boolean);
  75651. /**
  75652. * Specifies if screen space reflections are enabled.
  75653. */
  75654. get screenSpaceReflectionsEnabled(): boolean;
  75655. set screenSpaceReflectionsEnabled(enabled: boolean);
  75656. /**
  75657. * Specifies the number of steps used to calculate the volumetric lights
  75658. * Typically in interval [50, 200]
  75659. */
  75660. get volumetricLightStepsCount(): number;
  75661. set volumetricLightStepsCount(count: number);
  75662. /**
  75663. * Specifies the number of samples used for the motion blur effect
  75664. * Typically in interval [16, 64]
  75665. */
  75666. get motionBlurSamples(): number;
  75667. set motionBlurSamples(samples: number);
  75668. /**
  75669. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75670. */
  75671. get samples(): number;
  75672. set samples(sampleCount: number);
  75673. /**
  75674. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75675. * @constructor
  75676. * @param name The rendering pipeline name
  75677. * @param scene The scene linked to this pipeline
  75678. * @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)
  75679. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75680. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75681. */
  75682. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75683. private _buildPipeline;
  75684. private _createDownSampleX4PostProcess;
  75685. private _createBrightPassPostProcess;
  75686. private _createBlurPostProcesses;
  75687. private _createTextureAdderPostProcess;
  75688. private _createVolumetricLightPostProcess;
  75689. private _createLuminancePostProcesses;
  75690. private _createHdrPostProcess;
  75691. private _createLensFlarePostProcess;
  75692. private _createDepthOfFieldPostProcess;
  75693. private _createMotionBlurPostProcess;
  75694. private _getDepthTexture;
  75695. private _disposePostProcesses;
  75696. /**
  75697. * Dispose of the pipeline and stop all post processes
  75698. */
  75699. dispose(): void;
  75700. /**
  75701. * Serialize the rendering pipeline (Used when exporting)
  75702. * @returns the serialized object
  75703. */
  75704. serialize(): any;
  75705. /**
  75706. * Parse the serialized pipeline
  75707. * @param source Source pipeline.
  75708. * @param scene The scene to load the pipeline to.
  75709. * @param rootUrl The URL of the serialized pipeline.
  75710. * @returns An instantiated pipeline from the serialized object.
  75711. */
  75712. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75713. /**
  75714. * Luminance steps
  75715. */
  75716. static LuminanceSteps: number;
  75717. }
  75718. }
  75719. declare module BABYLON {
  75720. /** @hidden */
  75721. export var tonemapPixelShader: {
  75722. name: string;
  75723. shader: string;
  75724. };
  75725. }
  75726. declare module BABYLON {
  75727. /** Defines operator used for tonemapping */
  75728. export enum TonemappingOperator {
  75729. /** Hable */
  75730. Hable = 0,
  75731. /** Reinhard */
  75732. Reinhard = 1,
  75733. /** HejiDawson */
  75734. HejiDawson = 2,
  75735. /** Photographic */
  75736. Photographic = 3
  75737. }
  75738. /**
  75739. * Defines a post process to apply tone mapping
  75740. */
  75741. export class TonemapPostProcess extends PostProcess {
  75742. private _operator;
  75743. /** Defines the required exposure adjustement */
  75744. exposureAdjustment: number;
  75745. /**
  75746. * Gets a string identifying the name of the class
  75747. * @returns "TonemapPostProcess" string
  75748. */
  75749. getClassName(): string;
  75750. /**
  75751. * Creates a new TonemapPostProcess
  75752. * @param name defines the name of the postprocess
  75753. * @param _operator defines the operator to use
  75754. * @param exposureAdjustment defines the required exposure adjustement
  75755. * @param camera defines the camera to use (can be null)
  75756. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75757. * @param engine defines the hosting engine (can be ignore if camera is set)
  75758. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75759. */
  75760. constructor(name: string, _operator: TonemappingOperator,
  75761. /** Defines the required exposure adjustement */
  75762. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75763. }
  75764. }
  75765. declare module BABYLON {
  75766. /** @hidden */
  75767. export var volumetricLightScatteringPixelShader: {
  75768. name: string;
  75769. shader: string;
  75770. };
  75771. }
  75772. declare module BABYLON {
  75773. /** @hidden */
  75774. export var volumetricLightScatteringPassVertexShader: {
  75775. name: string;
  75776. shader: string;
  75777. };
  75778. }
  75779. declare module BABYLON {
  75780. /** @hidden */
  75781. export var volumetricLightScatteringPassPixelShader: {
  75782. name: string;
  75783. shader: string;
  75784. };
  75785. }
  75786. declare module BABYLON {
  75787. /**
  75788. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75789. */
  75790. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75791. private _volumetricLightScatteringPass;
  75792. private _volumetricLightScatteringRTT;
  75793. private _viewPort;
  75794. private _screenCoordinates;
  75795. private _cachedDefines;
  75796. /**
  75797. * If not undefined, the mesh position is computed from the attached node position
  75798. */
  75799. attachedNode: {
  75800. position: Vector3;
  75801. };
  75802. /**
  75803. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75804. */
  75805. customMeshPosition: Vector3;
  75806. /**
  75807. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75808. */
  75809. useCustomMeshPosition: boolean;
  75810. /**
  75811. * If the post-process should inverse the light scattering direction
  75812. */
  75813. invert: boolean;
  75814. /**
  75815. * The internal mesh used by the post-process
  75816. */
  75817. mesh: Mesh;
  75818. /**
  75819. * @hidden
  75820. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75821. */
  75822. get useDiffuseColor(): boolean;
  75823. set useDiffuseColor(useDiffuseColor: boolean);
  75824. /**
  75825. * Array containing the excluded meshes not rendered in the internal pass
  75826. */
  75827. excludedMeshes: AbstractMesh[];
  75828. /**
  75829. * Controls the overall intensity of the post-process
  75830. */
  75831. exposure: number;
  75832. /**
  75833. * Dissipates each sample's contribution in range [0, 1]
  75834. */
  75835. decay: number;
  75836. /**
  75837. * Controls the overall intensity of each sample
  75838. */
  75839. weight: number;
  75840. /**
  75841. * Controls the density of each sample
  75842. */
  75843. density: number;
  75844. /**
  75845. * @constructor
  75846. * @param name The post-process name
  75847. * @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)
  75848. * @param camera The camera that the post-process will be attached to
  75849. * @param mesh The mesh used to create the light scattering
  75850. * @param samples The post-process quality, default 100
  75851. * @param samplingModeThe post-process filtering mode
  75852. * @param engine The babylon engine
  75853. * @param reusable If the post-process is reusable
  75854. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75855. */
  75856. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75857. /**
  75858. * Returns the string "VolumetricLightScatteringPostProcess"
  75859. * @returns "VolumetricLightScatteringPostProcess"
  75860. */
  75861. getClassName(): string;
  75862. private _isReady;
  75863. /**
  75864. * Sets the new light position for light scattering effect
  75865. * @param position The new custom light position
  75866. */
  75867. setCustomMeshPosition(position: Vector3): void;
  75868. /**
  75869. * Returns the light position for light scattering effect
  75870. * @return Vector3 The custom light position
  75871. */
  75872. getCustomMeshPosition(): Vector3;
  75873. /**
  75874. * Disposes the internal assets and detaches the post-process from the camera
  75875. */
  75876. dispose(camera: Camera): void;
  75877. /**
  75878. * Returns the render target texture used by the post-process
  75879. * @return the render target texture used by the post-process
  75880. */
  75881. getPass(): RenderTargetTexture;
  75882. private _meshExcluded;
  75883. private _createPass;
  75884. private _updateMeshScreenCoordinates;
  75885. /**
  75886. * Creates a default mesh for the Volumeric Light Scattering post-process
  75887. * @param name The mesh name
  75888. * @param scene The scene where to create the mesh
  75889. * @return the default mesh
  75890. */
  75891. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75892. }
  75893. }
  75894. declare module BABYLON {
  75895. /** @hidden */
  75896. export var screenSpaceCurvaturePixelShader: {
  75897. name: string;
  75898. shader: string;
  75899. };
  75900. }
  75901. declare module BABYLON {
  75902. /**
  75903. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75904. */
  75905. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75906. /**
  75907. * Defines how much ridge the curvature effect displays.
  75908. */
  75909. ridge: number;
  75910. /**
  75911. * Defines how much valley the curvature effect displays.
  75912. */
  75913. valley: number;
  75914. private _geometryBufferRenderer;
  75915. /**
  75916. * Gets a string identifying the name of the class
  75917. * @returns "ScreenSpaceCurvaturePostProcess" string
  75918. */
  75919. getClassName(): string;
  75920. /**
  75921. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75922. * @param name The name of the effect.
  75923. * @param scene The scene containing the objects to blur according to their velocity.
  75924. * @param options The required width/height ratio to downsize to before computing the render pass.
  75925. * @param camera The camera to apply the render pass to.
  75926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75927. * @param engine The engine which the post process will be applied. (default: current engine)
  75928. * @param reusable If the post process can be reused on the same frame. (default: false)
  75929. * @param textureType Type of textures used when performing the post process. (default: 0)
  75930. * @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)
  75931. */
  75932. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75933. /**
  75934. * Support test.
  75935. */
  75936. static get IsSupported(): boolean;
  75937. /** @hidden */
  75938. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75939. }
  75940. }
  75941. declare module BABYLON {
  75942. interface Scene {
  75943. /** @hidden (Backing field) */
  75944. _boundingBoxRenderer: BoundingBoxRenderer;
  75945. /** @hidden (Backing field) */
  75946. _forceShowBoundingBoxes: boolean;
  75947. /**
  75948. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75949. */
  75950. forceShowBoundingBoxes: boolean;
  75951. /**
  75952. * Gets the bounding box renderer associated with the scene
  75953. * @returns a BoundingBoxRenderer
  75954. */
  75955. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75956. }
  75957. interface AbstractMesh {
  75958. /** @hidden (Backing field) */
  75959. _showBoundingBox: boolean;
  75960. /**
  75961. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75962. */
  75963. showBoundingBox: boolean;
  75964. }
  75965. /**
  75966. * Component responsible of rendering the bounding box of the meshes in a scene.
  75967. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75968. */
  75969. export class BoundingBoxRenderer implements ISceneComponent {
  75970. /**
  75971. * The component name helpfull to identify the component in the list of scene components.
  75972. */
  75973. readonly name: string;
  75974. /**
  75975. * The scene the component belongs to.
  75976. */
  75977. scene: Scene;
  75978. /**
  75979. * Color of the bounding box lines placed in front of an object
  75980. */
  75981. frontColor: Color3;
  75982. /**
  75983. * Color of the bounding box lines placed behind an object
  75984. */
  75985. backColor: Color3;
  75986. /**
  75987. * Defines if the renderer should show the back lines or not
  75988. */
  75989. showBackLines: boolean;
  75990. /**
  75991. * Observable raised before rendering a bounding box
  75992. */
  75993. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75994. /**
  75995. * Observable raised after rendering a bounding box
  75996. */
  75997. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75998. /**
  75999. * Observable raised after resources are created
  76000. */
  76001. onResourcesReadyObservable: Observable<BoundingBoxRenderer>;
  76002. /**
  76003. * When false, no bounding boxes will be rendered
  76004. */
  76005. enabled: boolean;
  76006. /**
  76007. * @hidden
  76008. */
  76009. renderList: SmartArray<BoundingBox>;
  76010. private _colorShader;
  76011. private _vertexBuffers;
  76012. private _indexBuffer;
  76013. private _fillIndexBuffer;
  76014. private _fillIndexData;
  76015. /**
  76016. * Instantiates a new bounding box renderer in a scene.
  76017. * @param scene the scene the renderer renders in
  76018. */
  76019. constructor(scene: Scene);
  76020. /**
  76021. * Registers the component in a given scene
  76022. */
  76023. register(): void;
  76024. private _evaluateSubMesh;
  76025. private _preActiveMesh;
  76026. private _prepareResources;
  76027. private _createIndexBuffer;
  76028. /**
  76029. * Rebuilds the elements related to this component in case of
  76030. * context lost for instance.
  76031. */
  76032. rebuild(): void;
  76033. /**
  76034. * @hidden
  76035. */
  76036. reset(): void;
  76037. /**
  76038. * Render the bounding boxes of a specific rendering group
  76039. * @param renderingGroupId defines the rendering group to render
  76040. */
  76041. render(renderingGroupId: number): void;
  76042. /**
  76043. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76044. * @param mesh Define the mesh to render the occlusion bounding box for
  76045. */
  76046. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76047. /**
  76048. * Dispose and release the resources attached to this renderer.
  76049. */
  76050. dispose(): void;
  76051. }
  76052. }
  76053. declare module BABYLON {
  76054. interface Scene {
  76055. /** @hidden (Backing field) */
  76056. _depthRenderer: {
  76057. [id: string]: DepthRenderer;
  76058. };
  76059. /**
  76060. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76061. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76062. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76063. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76064. * @returns the created depth renderer
  76065. */
  76066. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76067. /**
  76068. * Disables a depth renderer for a given camera
  76069. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76070. */
  76071. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76072. }
  76073. /**
  76074. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76075. * in several rendering techniques.
  76076. */
  76077. export class DepthRendererSceneComponent implements ISceneComponent {
  76078. /**
  76079. * The component name helpfull to identify the component in the list of scene components.
  76080. */
  76081. readonly name: string;
  76082. /**
  76083. * The scene the component belongs to.
  76084. */
  76085. scene: Scene;
  76086. /**
  76087. * Creates a new instance of the component for the given scene
  76088. * @param scene Defines the scene to register the component in
  76089. */
  76090. constructor(scene: Scene);
  76091. /**
  76092. * Registers the component in a given scene
  76093. */
  76094. register(): void;
  76095. /**
  76096. * Rebuilds the elements related to this component in case of
  76097. * context lost for instance.
  76098. */
  76099. rebuild(): void;
  76100. /**
  76101. * Disposes the component and the associated ressources
  76102. */
  76103. dispose(): void;
  76104. private _gatherRenderTargets;
  76105. private _gatherActiveCameraRenderTargets;
  76106. }
  76107. }
  76108. declare module BABYLON {
  76109. interface AbstractScene {
  76110. /** @hidden (Backing field) */
  76111. _prePassRenderer: Nullable<PrePassRenderer>;
  76112. /**
  76113. * Gets or Sets the current prepass renderer associated to the scene.
  76114. */
  76115. prePassRenderer: Nullable<PrePassRenderer>;
  76116. /**
  76117. * Enables the prepass and associates it with the scene
  76118. * @returns the PrePassRenderer
  76119. */
  76120. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76121. /**
  76122. * Disables the prepass associated with the scene
  76123. */
  76124. disablePrePassRenderer(): void;
  76125. }
  76126. /**
  76127. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76128. * in several rendering techniques.
  76129. */
  76130. export class PrePassRendererSceneComponent implements ISceneComponent {
  76131. /**
  76132. * The component name helpful to identify the component in the list of scene components.
  76133. */
  76134. readonly name: string;
  76135. /**
  76136. * The scene the component belongs to.
  76137. */
  76138. scene: Scene;
  76139. /**
  76140. * Creates a new instance of the component for the given scene
  76141. * @param scene Defines the scene to register the component in
  76142. */
  76143. constructor(scene: Scene);
  76144. /**
  76145. * Registers the component in a given scene
  76146. */
  76147. register(): void;
  76148. private _beforeCameraDraw;
  76149. private _afterCameraDraw;
  76150. private _beforeClearStage;
  76151. private _beforeRenderingMeshStage;
  76152. private _afterRenderingMeshStage;
  76153. /**
  76154. * Rebuilds the elements related to this component in case of
  76155. * context lost for instance.
  76156. */
  76157. rebuild(): void;
  76158. /**
  76159. * Disposes the component and the associated ressources
  76160. */
  76161. dispose(): void;
  76162. }
  76163. }
  76164. declare module BABYLON {
  76165. /** @hidden */
  76166. export var fibonacci: {
  76167. name: string;
  76168. shader: string;
  76169. };
  76170. }
  76171. declare module BABYLON {
  76172. /** @hidden */
  76173. export var diffusionProfile: {
  76174. name: string;
  76175. shader: string;
  76176. };
  76177. }
  76178. declare module BABYLON {
  76179. /** @hidden */
  76180. export var subSurfaceScatteringPixelShader: {
  76181. name: string;
  76182. shader: string;
  76183. };
  76184. }
  76185. declare module BABYLON {
  76186. /**
  76187. * Sub surface scattering post process
  76188. */
  76189. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76190. /**
  76191. * Gets a string identifying the name of the class
  76192. * @returns "SubSurfaceScatteringPostProcess" string
  76193. */
  76194. getClassName(): string;
  76195. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76196. }
  76197. }
  76198. declare module BABYLON {
  76199. /**
  76200. * Contains all parameters needed for the prepass to perform
  76201. * screen space subsurface scattering
  76202. */
  76203. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76204. /** @hidden */
  76205. static _SceneComponentInitialization: (scene: Scene) => void;
  76206. private _ssDiffusionS;
  76207. private _ssFilterRadii;
  76208. private _ssDiffusionD;
  76209. /**
  76210. * Post process to attach for screen space subsurface scattering
  76211. */
  76212. postProcess: SubSurfaceScatteringPostProcess;
  76213. /**
  76214. * Diffusion profile color for subsurface scattering
  76215. */
  76216. get ssDiffusionS(): number[];
  76217. /**
  76218. * Diffusion profile max color channel value for subsurface scattering
  76219. */
  76220. get ssDiffusionD(): number[];
  76221. /**
  76222. * Diffusion profile filter radius for subsurface scattering
  76223. */
  76224. get ssFilterRadii(): number[];
  76225. /**
  76226. * Is subsurface enabled
  76227. */
  76228. enabled: boolean;
  76229. /**
  76230. * Name of the configuration
  76231. */
  76232. name: string;
  76233. /**
  76234. * Diffusion profile colors for subsurface scattering
  76235. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76236. * See ...
  76237. * Note that you can only store up to 5 of them
  76238. */
  76239. ssDiffusionProfileColors: Color3[];
  76240. /**
  76241. * Defines the ratio real world => scene units.
  76242. * Used for subsurface scattering
  76243. */
  76244. metersPerUnit: number;
  76245. /**
  76246. * Textures that should be present in the MRT for this effect to work
  76247. */
  76248. readonly texturesRequired: number[];
  76249. private _scene;
  76250. /**
  76251. * Builds a subsurface configuration object
  76252. * @param scene The scene
  76253. */
  76254. constructor(scene: Scene);
  76255. /**
  76256. * Adds a new diffusion profile.
  76257. * Useful for more realistic subsurface scattering on diverse materials.
  76258. * @param color The color of the diffusion profile. Should be the average color of the material.
  76259. * @return The index of the diffusion profile for the material subsurface configuration
  76260. */
  76261. addDiffusionProfile(color: Color3): number;
  76262. /**
  76263. * Creates the sss post process
  76264. * @return The created post process
  76265. */
  76266. createPostProcess(): SubSurfaceScatteringPostProcess;
  76267. /**
  76268. * Deletes all diffusion profiles.
  76269. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76270. */
  76271. clearAllDiffusionProfiles(): void;
  76272. /**
  76273. * Disposes this object
  76274. */
  76275. dispose(): void;
  76276. /**
  76277. * @hidden
  76278. * https://zero-radiance.github.io/post/sampling-diffusion/
  76279. *
  76280. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76281. * ------------------------------------------------------------------------------------
  76282. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76283. * PDF[r, phi, s] = r * R[r, phi, s]
  76284. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76285. * ------------------------------------------------------------------------------------
  76286. * We importance sample the color channel with the widest scattering distance.
  76287. */
  76288. getDiffusionProfileParameters(color: Color3): number;
  76289. /**
  76290. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76291. * 'u' is the random number (the value of the CDF): [0, 1).
  76292. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76293. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76294. */
  76295. private _sampleBurleyDiffusionProfile;
  76296. }
  76297. }
  76298. declare module BABYLON {
  76299. interface AbstractScene {
  76300. /** @hidden (Backing field) */
  76301. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76302. /**
  76303. * Gets or Sets the current prepass renderer associated to the scene.
  76304. */
  76305. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76306. /**
  76307. * Enables the subsurface effect for prepass
  76308. * @returns the SubSurfaceConfiguration
  76309. */
  76310. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76311. /**
  76312. * Disables the subsurface effect for prepass
  76313. */
  76314. disableSubSurfaceForPrePass(): void;
  76315. }
  76316. /**
  76317. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76318. * in several rendering techniques.
  76319. */
  76320. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76321. /**
  76322. * The component name helpful to identify the component in the list of scene components.
  76323. */
  76324. readonly name: string;
  76325. /**
  76326. * The scene the component belongs to.
  76327. */
  76328. scene: Scene;
  76329. /**
  76330. * Creates a new instance of the component for the given scene
  76331. * @param scene Defines the scene to register the component in
  76332. */
  76333. constructor(scene: Scene);
  76334. /**
  76335. * Registers the component in a given scene
  76336. */
  76337. register(): void;
  76338. /**
  76339. * Serializes the component data to the specified json object
  76340. * @param serializationObject The object to serialize to
  76341. */
  76342. serialize(serializationObject: any): void;
  76343. /**
  76344. * Adds all the elements from the container to the scene
  76345. * @param container the container holding the elements
  76346. */
  76347. addFromContainer(container: AbstractScene): void;
  76348. /**
  76349. * Removes all the elements in the container from the scene
  76350. * @param container contains the elements to remove
  76351. * @param dispose if the removed element should be disposed (default: false)
  76352. */
  76353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76354. /**
  76355. * Rebuilds the elements related to this component in case of
  76356. * context lost for instance.
  76357. */
  76358. rebuild(): void;
  76359. /**
  76360. * Disposes the component and the associated ressources
  76361. */
  76362. dispose(): void;
  76363. }
  76364. }
  76365. declare module BABYLON {
  76366. /** @hidden */
  76367. export var outlinePixelShader: {
  76368. name: string;
  76369. shader: string;
  76370. };
  76371. }
  76372. declare module BABYLON {
  76373. /** @hidden */
  76374. export var outlineVertexShader: {
  76375. name: string;
  76376. shader: string;
  76377. };
  76378. }
  76379. declare module BABYLON {
  76380. interface Scene {
  76381. /** @hidden */
  76382. _outlineRenderer: OutlineRenderer;
  76383. /**
  76384. * Gets the outline renderer associated with the scene
  76385. * @returns a OutlineRenderer
  76386. */
  76387. getOutlineRenderer(): OutlineRenderer;
  76388. }
  76389. interface AbstractMesh {
  76390. /** @hidden (Backing field) */
  76391. _renderOutline: boolean;
  76392. /**
  76393. * Gets or sets a boolean indicating if the outline must be rendered as well
  76394. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76395. */
  76396. renderOutline: boolean;
  76397. /** @hidden (Backing field) */
  76398. _renderOverlay: boolean;
  76399. /**
  76400. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76401. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76402. */
  76403. renderOverlay: boolean;
  76404. }
  76405. /**
  76406. * This class is responsible to draw bothe outline/overlay of meshes.
  76407. * It should not be used directly but through the available method on mesh.
  76408. */
  76409. export class OutlineRenderer implements ISceneComponent {
  76410. /**
  76411. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76412. */
  76413. private static _StencilReference;
  76414. /**
  76415. * The name of the component. Each component must have a unique name.
  76416. */
  76417. name: string;
  76418. /**
  76419. * The scene the component belongs to.
  76420. */
  76421. scene: Scene;
  76422. /**
  76423. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76424. */
  76425. zOffset: number;
  76426. private _engine;
  76427. private _effect;
  76428. private _cachedDefines;
  76429. private _savedDepthWrite;
  76430. /**
  76431. * Instantiates a new outline renderer. (There could be only one per scene).
  76432. * @param scene Defines the scene it belongs to
  76433. */
  76434. constructor(scene: Scene);
  76435. /**
  76436. * Register the component to one instance of a scene.
  76437. */
  76438. register(): void;
  76439. /**
  76440. * Rebuilds the elements related to this component in case of
  76441. * context lost for instance.
  76442. */
  76443. rebuild(): void;
  76444. /**
  76445. * Disposes the component and the associated ressources.
  76446. */
  76447. dispose(): void;
  76448. /**
  76449. * Renders the outline in the canvas.
  76450. * @param subMesh Defines the sumesh to render
  76451. * @param batch Defines the batch of meshes in case of instances
  76452. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76453. */
  76454. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76455. /**
  76456. * Returns whether or not the outline renderer is ready for a given submesh.
  76457. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76458. * @param subMesh Defines the submesh to check readyness for
  76459. * @param useInstances Defines wheter wee are trying to render instances or not
  76460. * @returns true if ready otherwise false
  76461. */
  76462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76463. private _beforeRenderingMesh;
  76464. private _afterRenderingMesh;
  76465. }
  76466. }
  76467. declare module BABYLON {
  76468. /**
  76469. * Defines the basic options interface of a Sprite Frame Source Size.
  76470. */
  76471. export interface ISpriteJSONSpriteSourceSize {
  76472. /**
  76473. * number of the original width of the Frame
  76474. */
  76475. w: number;
  76476. /**
  76477. * number of the original height of the Frame
  76478. */
  76479. h: number;
  76480. }
  76481. /**
  76482. * Defines the basic options interface of a Sprite Frame Data.
  76483. */
  76484. export interface ISpriteJSONSpriteFrameData {
  76485. /**
  76486. * number of the x offset of the Frame
  76487. */
  76488. x: number;
  76489. /**
  76490. * number of the y offset of the Frame
  76491. */
  76492. y: number;
  76493. /**
  76494. * number of the width of the Frame
  76495. */
  76496. w: number;
  76497. /**
  76498. * number of the height of the Frame
  76499. */
  76500. h: number;
  76501. }
  76502. /**
  76503. * Defines the basic options interface of a JSON Sprite.
  76504. */
  76505. export interface ISpriteJSONSprite {
  76506. /**
  76507. * string name of the Frame
  76508. */
  76509. filename: string;
  76510. /**
  76511. * ISpriteJSONSpriteFrame basic object of the frame data
  76512. */
  76513. frame: ISpriteJSONSpriteFrameData;
  76514. /**
  76515. * boolean to flag is the frame was rotated.
  76516. */
  76517. rotated: boolean;
  76518. /**
  76519. * boolean to flag is the frame was trimmed.
  76520. */
  76521. trimmed: boolean;
  76522. /**
  76523. * ISpriteJSONSpriteFrame basic object of the source data
  76524. */
  76525. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76526. /**
  76527. * ISpriteJSONSpriteFrame basic object of the source data
  76528. */
  76529. sourceSize: ISpriteJSONSpriteSourceSize;
  76530. }
  76531. /**
  76532. * Defines the basic options interface of a JSON atlas.
  76533. */
  76534. export interface ISpriteJSONAtlas {
  76535. /**
  76536. * Array of objects that contain the frame data.
  76537. */
  76538. frames: Array<ISpriteJSONSprite>;
  76539. /**
  76540. * object basic object containing the sprite meta data.
  76541. */
  76542. meta?: object;
  76543. }
  76544. }
  76545. declare module BABYLON {
  76546. /** @hidden */
  76547. export var spriteMapPixelShader: {
  76548. name: string;
  76549. shader: string;
  76550. };
  76551. }
  76552. declare module BABYLON {
  76553. /** @hidden */
  76554. export var spriteMapVertexShader: {
  76555. name: string;
  76556. shader: string;
  76557. };
  76558. }
  76559. declare module BABYLON {
  76560. /**
  76561. * Defines the basic options interface of a SpriteMap
  76562. */
  76563. export interface ISpriteMapOptions {
  76564. /**
  76565. * Vector2 of the number of cells in the grid.
  76566. */
  76567. stageSize?: Vector2;
  76568. /**
  76569. * Vector2 of the size of the output plane in World Units.
  76570. */
  76571. outputSize?: Vector2;
  76572. /**
  76573. * Vector3 of the position of the output plane in World Units.
  76574. */
  76575. outputPosition?: Vector3;
  76576. /**
  76577. * Vector3 of the rotation of the output plane.
  76578. */
  76579. outputRotation?: Vector3;
  76580. /**
  76581. * number of layers that the system will reserve in resources.
  76582. */
  76583. layerCount?: number;
  76584. /**
  76585. * number of max animation frames a single cell will reserve in resources.
  76586. */
  76587. maxAnimationFrames?: number;
  76588. /**
  76589. * number cell index of the base tile when the system compiles.
  76590. */
  76591. baseTile?: number;
  76592. /**
  76593. * boolean flip the sprite after its been repositioned by the framing data.
  76594. */
  76595. flipU?: boolean;
  76596. /**
  76597. * Vector3 scalar of the global RGB values of the SpriteMap.
  76598. */
  76599. colorMultiply?: Vector3;
  76600. }
  76601. /**
  76602. * Defines the IDisposable interface in order to be cleanable from resources.
  76603. */
  76604. export interface ISpriteMap extends IDisposable {
  76605. /**
  76606. * String name of the SpriteMap.
  76607. */
  76608. name: string;
  76609. /**
  76610. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76611. */
  76612. atlasJSON: ISpriteJSONAtlas;
  76613. /**
  76614. * Texture of the SpriteMap.
  76615. */
  76616. spriteSheet: Texture;
  76617. /**
  76618. * The parameters to initialize the SpriteMap with.
  76619. */
  76620. options: ISpriteMapOptions;
  76621. }
  76622. /**
  76623. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76624. */
  76625. export class SpriteMap implements ISpriteMap {
  76626. /** The Name of the spriteMap */
  76627. name: string;
  76628. /** The JSON file with the frame and meta data */
  76629. atlasJSON: ISpriteJSONAtlas;
  76630. /** The systems Sprite Sheet Texture */
  76631. spriteSheet: Texture;
  76632. /** Arguments passed with the Constructor */
  76633. options: ISpriteMapOptions;
  76634. /** Public Sprite Storage array, parsed from atlasJSON */
  76635. sprites: Array<ISpriteJSONSprite>;
  76636. /** Returns the Number of Sprites in the System */
  76637. get spriteCount(): number;
  76638. /** Returns the Position of Output Plane*/
  76639. get position(): Vector3;
  76640. /** Returns the Position of Output Plane*/
  76641. set position(v: Vector3);
  76642. /** Returns the Rotation of Output Plane*/
  76643. get rotation(): Vector3;
  76644. /** Returns the Rotation of Output Plane*/
  76645. set rotation(v: Vector3);
  76646. /** Sets the AnimationMap*/
  76647. get animationMap(): RawTexture;
  76648. /** Sets the AnimationMap*/
  76649. set animationMap(v: RawTexture);
  76650. /** Scene that the SpriteMap was created in */
  76651. private _scene;
  76652. /** Texture Buffer of Float32 that holds tile frame data*/
  76653. private _frameMap;
  76654. /** Texture Buffers of Float32 that holds tileMap data*/
  76655. private _tileMaps;
  76656. /** Texture Buffer of Float32 that holds Animation Data*/
  76657. private _animationMap;
  76658. /** Custom ShaderMaterial Central to the System*/
  76659. private _material;
  76660. /** Custom ShaderMaterial Central to the System*/
  76661. private _output;
  76662. /** Systems Time Ticker*/
  76663. private _time;
  76664. /**
  76665. * Creates a new SpriteMap
  76666. * @param name defines the SpriteMaps Name
  76667. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76668. * @param spriteSheet is the Texture that the Sprites are on.
  76669. * @param options a basic deployment configuration
  76670. * @param scene The Scene that the map is deployed on
  76671. */
  76672. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76673. /**
  76674. * Returns tileID location
  76675. * @returns Vector2 the cell position ID
  76676. */
  76677. getTileID(): Vector2;
  76678. /**
  76679. * Gets the UV location of the mouse over the SpriteMap.
  76680. * @returns Vector2 the UV position of the mouse interaction
  76681. */
  76682. getMousePosition(): Vector2;
  76683. /**
  76684. * Creates the "frame" texture Buffer
  76685. * -------------------------------------
  76686. * Structure of frames
  76687. * "filename": "Falling-Water-2.png",
  76688. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76689. * "rotated": true,
  76690. * "trimmed": true,
  76691. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76692. * "sourceSize": {"w":32,"h":32}
  76693. * @returns RawTexture of the frameMap
  76694. */
  76695. private _createFrameBuffer;
  76696. /**
  76697. * Creates the tileMap texture Buffer
  76698. * @param buffer normally and array of numbers, or a false to generate from scratch
  76699. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76700. * @returns RawTexture of the tileMap
  76701. */
  76702. private _createTileBuffer;
  76703. /**
  76704. * Modifies the data of the tileMaps
  76705. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76706. * @param pos is the iVector2 Coordinates of the Tile
  76707. * @param tile The SpriteIndex of the new Tile
  76708. */
  76709. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76710. /**
  76711. * Creates the animationMap texture Buffer
  76712. * @param buffer normally and array of numbers, or a false to generate from scratch
  76713. * @returns RawTexture of the animationMap
  76714. */
  76715. private _createTileAnimationBuffer;
  76716. /**
  76717. * Modifies the data of the animationMap
  76718. * @param cellID is the Index of the Sprite
  76719. * @param _frame is the target Animation frame
  76720. * @param toCell is the Target Index of the next frame of the animation
  76721. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76722. * @param speed is a global scalar of the time variable on the map.
  76723. */
  76724. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76725. /**
  76726. * Exports the .tilemaps file
  76727. */
  76728. saveTileMaps(): void;
  76729. /**
  76730. * Imports the .tilemaps file
  76731. * @param url of the .tilemaps file
  76732. */
  76733. loadTileMaps(url: string): void;
  76734. /**
  76735. * Release associated resources
  76736. */
  76737. dispose(): void;
  76738. }
  76739. }
  76740. declare module BABYLON {
  76741. /**
  76742. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76743. * @see https://doc.babylonjs.com/babylon101/sprites
  76744. */
  76745. export class SpritePackedManager extends SpriteManager {
  76746. /** defines the packed manager's name */
  76747. name: string;
  76748. /**
  76749. * Creates a new sprite manager from a packed sprite sheet
  76750. * @param name defines the manager's name
  76751. * @param imgUrl defines the sprite sheet url
  76752. * @param capacity defines the maximum allowed number of sprites
  76753. * @param scene defines the hosting scene
  76754. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76755. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76756. * @param samplingMode defines the smapling mode to use with spritesheet
  76757. * @param fromPacked set to true; do not alter
  76758. */
  76759. constructor(
  76760. /** defines the packed manager's name */
  76761. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76762. }
  76763. }
  76764. declare module BABYLON {
  76765. /**
  76766. * Defines the list of states available for a task inside a AssetsManager
  76767. */
  76768. export enum AssetTaskState {
  76769. /**
  76770. * Initialization
  76771. */
  76772. INIT = 0,
  76773. /**
  76774. * Running
  76775. */
  76776. RUNNING = 1,
  76777. /**
  76778. * Done
  76779. */
  76780. DONE = 2,
  76781. /**
  76782. * Error
  76783. */
  76784. ERROR = 3
  76785. }
  76786. /**
  76787. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76788. */
  76789. export abstract class AbstractAssetTask {
  76790. /**
  76791. * Task name
  76792. */ name: string;
  76793. /**
  76794. * Callback called when the task is successful
  76795. */
  76796. onSuccess: (task: any) => void;
  76797. /**
  76798. * Callback called when the task is not successful
  76799. */
  76800. onError: (task: any, message?: string, exception?: any) => void;
  76801. /**
  76802. * Creates a new AssetsManager
  76803. * @param name defines the name of the task
  76804. */
  76805. constructor(
  76806. /**
  76807. * Task name
  76808. */ name: string);
  76809. private _isCompleted;
  76810. private _taskState;
  76811. private _errorObject;
  76812. /**
  76813. * Get if the task is completed
  76814. */
  76815. get isCompleted(): boolean;
  76816. /**
  76817. * Gets the current state of the task
  76818. */
  76819. get taskState(): AssetTaskState;
  76820. /**
  76821. * Gets the current error object (if task is in error)
  76822. */
  76823. get errorObject(): {
  76824. message?: string;
  76825. exception?: any;
  76826. };
  76827. /**
  76828. * Internal only
  76829. * @hidden
  76830. */
  76831. _setErrorObject(message?: string, exception?: any): void;
  76832. /**
  76833. * Execute the current task
  76834. * @param scene defines the scene where you want your assets to be loaded
  76835. * @param onSuccess is a callback called when the task is successfully executed
  76836. * @param onError is a callback called if an error occurs
  76837. */
  76838. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76839. /**
  76840. * Execute the current task
  76841. * @param scene defines the scene where you want your assets to be loaded
  76842. * @param onSuccess is a callback called when the task is successfully executed
  76843. * @param onError is a callback called if an error occurs
  76844. */
  76845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76846. /**
  76847. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76848. * This can be used with failed tasks that have the reason for failure fixed.
  76849. */
  76850. reset(): void;
  76851. private onErrorCallback;
  76852. private onDoneCallback;
  76853. }
  76854. /**
  76855. * Define the interface used by progress events raised during assets loading
  76856. */
  76857. export interface IAssetsProgressEvent {
  76858. /**
  76859. * Defines the number of remaining tasks to process
  76860. */
  76861. remainingCount: number;
  76862. /**
  76863. * Defines the total number of tasks
  76864. */
  76865. totalCount: number;
  76866. /**
  76867. * Defines the task that was just processed
  76868. */
  76869. task: AbstractAssetTask;
  76870. }
  76871. /**
  76872. * Class used to share progress information about assets loading
  76873. */
  76874. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76875. /**
  76876. * Defines the number of remaining tasks to process
  76877. */
  76878. remainingCount: number;
  76879. /**
  76880. * Defines the total number of tasks
  76881. */
  76882. totalCount: number;
  76883. /**
  76884. * Defines the task that was just processed
  76885. */
  76886. task: AbstractAssetTask;
  76887. /**
  76888. * Creates a AssetsProgressEvent
  76889. * @param remainingCount defines the number of remaining tasks to process
  76890. * @param totalCount defines the total number of tasks
  76891. * @param task defines the task that was just processed
  76892. */
  76893. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76894. }
  76895. /**
  76896. * Define a task used by AssetsManager to load assets into a container
  76897. */
  76898. export class ContainerAssetTask extends AbstractAssetTask {
  76899. /**
  76900. * Defines the name of the task
  76901. */
  76902. name: string;
  76903. /**
  76904. * Defines the list of mesh's names you want to load
  76905. */
  76906. meshesNames: any;
  76907. /**
  76908. * Defines the root url to use as a base to load your meshes and associated resources
  76909. */
  76910. rootUrl: string;
  76911. /**
  76912. * Defines the filename or File of the scene to load from
  76913. */
  76914. sceneFilename: string | File;
  76915. /**
  76916. * Get the loaded asset container
  76917. */
  76918. loadedContainer: AssetContainer;
  76919. /**
  76920. * Gets the list of loaded meshes
  76921. */
  76922. loadedMeshes: Array<AbstractMesh>;
  76923. /**
  76924. * Gets the list of loaded particle systems
  76925. */
  76926. loadedParticleSystems: Array<IParticleSystem>;
  76927. /**
  76928. * Gets the list of loaded skeletons
  76929. */
  76930. loadedSkeletons: Array<Skeleton>;
  76931. /**
  76932. * Gets the list of loaded animation groups
  76933. */
  76934. loadedAnimationGroups: Array<AnimationGroup>;
  76935. /**
  76936. * Callback called when the task is successful
  76937. */
  76938. onSuccess: (task: ContainerAssetTask) => void;
  76939. /**
  76940. * Callback called when the task is successful
  76941. */
  76942. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  76943. /**
  76944. * Creates a new ContainerAssetTask
  76945. * @param name defines the name of the task
  76946. * @param meshesNames defines the list of mesh's names you want to load
  76947. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  76948. * @param sceneFilename defines the filename or File of the scene to load from
  76949. */
  76950. constructor(
  76951. /**
  76952. * Defines the name of the task
  76953. */
  76954. name: string,
  76955. /**
  76956. * Defines the list of mesh's names you want to load
  76957. */
  76958. meshesNames: any,
  76959. /**
  76960. * Defines the root url to use as a base to load your meshes and associated resources
  76961. */
  76962. rootUrl: string,
  76963. /**
  76964. * Defines the filename or File of the scene to load from
  76965. */
  76966. sceneFilename: string | File);
  76967. /**
  76968. * Execute the current task
  76969. * @param scene defines the scene where you want your assets to be loaded
  76970. * @param onSuccess is a callback called when the task is successfully executed
  76971. * @param onError is a callback called if an error occurs
  76972. */
  76973. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76974. }
  76975. /**
  76976. * Define a task used by AssetsManager to load meshes
  76977. */
  76978. export class MeshAssetTask extends AbstractAssetTask {
  76979. /**
  76980. * Defines the name of the task
  76981. */
  76982. name: string;
  76983. /**
  76984. * Defines the list of mesh's names you want to load
  76985. */
  76986. meshesNames: any;
  76987. /**
  76988. * Defines the root url to use as a base to load your meshes and associated resources
  76989. */
  76990. rootUrl: string;
  76991. /**
  76992. * Defines the filename or File of the scene to load from
  76993. */
  76994. sceneFilename: string | File;
  76995. /**
  76996. * Gets the list of loaded meshes
  76997. */
  76998. loadedMeshes: Array<AbstractMesh>;
  76999. /**
  77000. * Gets the list of loaded particle systems
  77001. */
  77002. loadedParticleSystems: Array<IParticleSystem>;
  77003. /**
  77004. * Gets the list of loaded skeletons
  77005. */
  77006. loadedSkeletons: Array<Skeleton>;
  77007. /**
  77008. * Gets the list of loaded animation groups
  77009. */
  77010. loadedAnimationGroups: Array<AnimationGroup>;
  77011. /**
  77012. * Callback called when the task is successful
  77013. */
  77014. onSuccess: (task: MeshAssetTask) => void;
  77015. /**
  77016. * Callback called when the task is successful
  77017. */
  77018. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77019. /**
  77020. * Creates a new MeshAssetTask
  77021. * @param name defines the name of the task
  77022. * @param meshesNames defines the list of mesh's names you want to load
  77023. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77024. * @param sceneFilename defines the filename or File of the scene to load from
  77025. */
  77026. constructor(
  77027. /**
  77028. * Defines the name of the task
  77029. */
  77030. name: string,
  77031. /**
  77032. * Defines the list of mesh's names you want to load
  77033. */
  77034. meshesNames: any,
  77035. /**
  77036. * Defines the root url to use as a base to load your meshes and associated resources
  77037. */
  77038. rootUrl: string,
  77039. /**
  77040. * Defines the filename or File of the scene to load from
  77041. */
  77042. sceneFilename: string | File);
  77043. /**
  77044. * Execute the current task
  77045. * @param scene defines the scene where you want your assets to be loaded
  77046. * @param onSuccess is a callback called when the task is successfully executed
  77047. * @param onError is a callback called if an error occurs
  77048. */
  77049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77050. }
  77051. /**
  77052. * Define a task used by AssetsManager to load text content
  77053. */
  77054. export class TextFileAssetTask extends AbstractAssetTask {
  77055. /**
  77056. * Defines the name of the task
  77057. */
  77058. name: string;
  77059. /**
  77060. * Defines the location of the file to load
  77061. */
  77062. url: string;
  77063. /**
  77064. * Gets the loaded text string
  77065. */
  77066. text: string;
  77067. /**
  77068. * Callback called when the task is successful
  77069. */
  77070. onSuccess: (task: TextFileAssetTask) => void;
  77071. /**
  77072. * Callback called when the task is successful
  77073. */
  77074. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77075. /**
  77076. * Creates a new TextFileAssetTask object
  77077. * @param name defines the name of the task
  77078. * @param url defines the location of the file to load
  77079. */
  77080. constructor(
  77081. /**
  77082. * Defines the name of the task
  77083. */
  77084. name: string,
  77085. /**
  77086. * Defines the location of the file to load
  77087. */
  77088. url: string);
  77089. /**
  77090. * Execute the current task
  77091. * @param scene defines the scene where you want your assets to be loaded
  77092. * @param onSuccess is a callback called when the task is successfully executed
  77093. * @param onError is a callback called if an error occurs
  77094. */
  77095. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77096. }
  77097. /**
  77098. * Define a task used by AssetsManager to load binary data
  77099. */
  77100. export class BinaryFileAssetTask extends AbstractAssetTask {
  77101. /**
  77102. * Defines the name of the task
  77103. */
  77104. name: string;
  77105. /**
  77106. * Defines the location of the file to load
  77107. */
  77108. url: string;
  77109. /**
  77110. * Gets the lodaded data (as an array buffer)
  77111. */
  77112. data: ArrayBuffer;
  77113. /**
  77114. * Callback called when the task is successful
  77115. */
  77116. onSuccess: (task: BinaryFileAssetTask) => void;
  77117. /**
  77118. * Callback called when the task is successful
  77119. */
  77120. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77121. /**
  77122. * Creates a new BinaryFileAssetTask object
  77123. * @param name defines the name of the new task
  77124. * @param url defines the location of the file to load
  77125. */
  77126. constructor(
  77127. /**
  77128. * Defines the name of the task
  77129. */
  77130. name: string,
  77131. /**
  77132. * Defines the location of the file to load
  77133. */
  77134. url: string);
  77135. /**
  77136. * Execute the current task
  77137. * @param scene defines the scene where you want your assets to be loaded
  77138. * @param onSuccess is a callback called when the task is successfully executed
  77139. * @param onError is a callback called if an error occurs
  77140. */
  77141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77142. }
  77143. /**
  77144. * Define a task used by AssetsManager to load images
  77145. */
  77146. export class ImageAssetTask extends AbstractAssetTask {
  77147. /**
  77148. * Defines the name of the task
  77149. */
  77150. name: string;
  77151. /**
  77152. * Defines the location of the image to load
  77153. */
  77154. url: string;
  77155. /**
  77156. * Gets the loaded images
  77157. */
  77158. image: HTMLImageElement;
  77159. /**
  77160. * Callback called when the task is successful
  77161. */
  77162. onSuccess: (task: ImageAssetTask) => void;
  77163. /**
  77164. * Callback called when the task is successful
  77165. */
  77166. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77167. /**
  77168. * Creates a new ImageAssetTask
  77169. * @param name defines the name of the task
  77170. * @param url defines the location of the image to load
  77171. */
  77172. constructor(
  77173. /**
  77174. * Defines the name of the task
  77175. */
  77176. name: string,
  77177. /**
  77178. * Defines the location of the image to load
  77179. */
  77180. url: string);
  77181. /**
  77182. * Execute the current task
  77183. * @param scene defines the scene where you want your assets to be loaded
  77184. * @param onSuccess is a callback called when the task is successfully executed
  77185. * @param onError is a callback called if an error occurs
  77186. */
  77187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77188. }
  77189. /**
  77190. * Defines the interface used by texture loading tasks
  77191. */
  77192. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77193. /**
  77194. * Gets the loaded texture
  77195. */
  77196. texture: TEX;
  77197. }
  77198. /**
  77199. * Define a task used by AssetsManager to load 2D textures
  77200. */
  77201. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77202. /**
  77203. * Defines the name of the task
  77204. */
  77205. name: string;
  77206. /**
  77207. * Defines the location of the file to load
  77208. */
  77209. url: string;
  77210. /**
  77211. * Defines if mipmap should not be generated (default is false)
  77212. */
  77213. noMipmap?: boolean | undefined;
  77214. /**
  77215. * Defines if texture must be inverted on Y axis (default is true)
  77216. */
  77217. invertY: boolean;
  77218. /**
  77219. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77220. */
  77221. samplingMode: number;
  77222. /**
  77223. * Gets the loaded texture
  77224. */
  77225. texture: Texture;
  77226. /**
  77227. * Callback called when the task is successful
  77228. */
  77229. onSuccess: (task: TextureAssetTask) => void;
  77230. /**
  77231. * Callback called when the task is successful
  77232. */
  77233. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77234. /**
  77235. * Creates a new TextureAssetTask object
  77236. * @param name defines the name of the task
  77237. * @param url defines the location of the file to load
  77238. * @param noMipmap defines if mipmap should not be generated (default is false)
  77239. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77240. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77241. */
  77242. constructor(
  77243. /**
  77244. * Defines the name of the task
  77245. */
  77246. name: string,
  77247. /**
  77248. * Defines the location of the file to load
  77249. */
  77250. url: string,
  77251. /**
  77252. * Defines if mipmap should not be generated (default is false)
  77253. */
  77254. noMipmap?: boolean | undefined,
  77255. /**
  77256. * Defines if texture must be inverted on Y axis (default is true)
  77257. */
  77258. invertY?: boolean,
  77259. /**
  77260. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77261. */
  77262. samplingMode?: number);
  77263. /**
  77264. * Execute the current task
  77265. * @param scene defines the scene where you want your assets to be loaded
  77266. * @param onSuccess is a callback called when the task is successfully executed
  77267. * @param onError is a callback called if an error occurs
  77268. */
  77269. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77270. }
  77271. /**
  77272. * Define a task used by AssetsManager to load cube textures
  77273. */
  77274. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77275. /**
  77276. * Defines the name of the task
  77277. */
  77278. name: string;
  77279. /**
  77280. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77281. */
  77282. url: string;
  77283. /**
  77284. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77285. */
  77286. extensions?: string[] | undefined;
  77287. /**
  77288. * Defines if mipmaps should not be generated (default is false)
  77289. */
  77290. noMipmap?: boolean | undefined;
  77291. /**
  77292. * Defines the explicit list of files (undefined by default)
  77293. */
  77294. files?: string[] | undefined;
  77295. /**
  77296. * Gets the loaded texture
  77297. */
  77298. texture: CubeTexture;
  77299. /**
  77300. * Callback called when the task is successful
  77301. */
  77302. onSuccess: (task: CubeTextureAssetTask) => void;
  77303. /**
  77304. * Callback called when the task is successful
  77305. */
  77306. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77307. /**
  77308. * Creates a new CubeTextureAssetTask
  77309. * @param name defines the name of the task
  77310. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77311. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77312. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77313. * @param files defines the explicit list of files (undefined by default)
  77314. */
  77315. constructor(
  77316. /**
  77317. * Defines the name of the task
  77318. */
  77319. name: string,
  77320. /**
  77321. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77322. */
  77323. url: string,
  77324. /**
  77325. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77326. */
  77327. extensions?: string[] | undefined,
  77328. /**
  77329. * Defines if mipmaps should not be generated (default is false)
  77330. */
  77331. noMipmap?: boolean | undefined,
  77332. /**
  77333. * Defines the explicit list of files (undefined by default)
  77334. */
  77335. files?: string[] | undefined);
  77336. /**
  77337. * Execute the current task
  77338. * @param scene defines the scene where you want your assets to be loaded
  77339. * @param onSuccess is a callback called when the task is successfully executed
  77340. * @param onError is a callback called if an error occurs
  77341. */
  77342. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77343. }
  77344. /**
  77345. * Define a task used by AssetsManager to load HDR cube textures
  77346. */
  77347. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77348. /**
  77349. * Defines the name of the task
  77350. */
  77351. name: string;
  77352. /**
  77353. * Defines the location of the file to load
  77354. */
  77355. url: string;
  77356. /**
  77357. * Defines the desired size (the more it increases the longer the generation will be)
  77358. */
  77359. size: number;
  77360. /**
  77361. * Defines if mipmaps should not be generated (default is false)
  77362. */
  77363. noMipmap: boolean;
  77364. /**
  77365. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77366. */
  77367. generateHarmonics: boolean;
  77368. /**
  77369. * 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)
  77370. */
  77371. gammaSpace: boolean;
  77372. /**
  77373. * Internal Use Only
  77374. */
  77375. reserved: boolean;
  77376. /**
  77377. * Gets the loaded texture
  77378. */
  77379. texture: HDRCubeTexture;
  77380. /**
  77381. * Callback called when the task is successful
  77382. */
  77383. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77384. /**
  77385. * Callback called when the task is successful
  77386. */
  77387. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77388. /**
  77389. * Creates a new HDRCubeTextureAssetTask object
  77390. * @param name defines the name of the task
  77391. * @param url defines the location of the file to load
  77392. * @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.
  77393. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77394. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77395. * @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)
  77396. * @param reserved Internal use only
  77397. */
  77398. constructor(
  77399. /**
  77400. * Defines the name of the task
  77401. */
  77402. name: string,
  77403. /**
  77404. * Defines the location of the file to load
  77405. */
  77406. url: string,
  77407. /**
  77408. * Defines the desired size (the more it increases the longer the generation will be)
  77409. */
  77410. size: number,
  77411. /**
  77412. * Defines if mipmaps should not be generated (default is false)
  77413. */
  77414. noMipmap?: boolean,
  77415. /**
  77416. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77417. */
  77418. generateHarmonics?: boolean,
  77419. /**
  77420. * 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)
  77421. */
  77422. gammaSpace?: boolean,
  77423. /**
  77424. * Internal Use Only
  77425. */
  77426. reserved?: boolean);
  77427. /**
  77428. * Execute the current task
  77429. * @param scene defines the scene where you want your assets to be loaded
  77430. * @param onSuccess is a callback called when the task is successfully executed
  77431. * @param onError is a callback called if an error occurs
  77432. */
  77433. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77434. }
  77435. /**
  77436. * Define a task used by AssetsManager to load Equirectangular cube textures
  77437. */
  77438. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77439. /**
  77440. * Defines the name of the task
  77441. */
  77442. name: string;
  77443. /**
  77444. * Defines the location of the file to load
  77445. */
  77446. url: string;
  77447. /**
  77448. * Defines the desired size (the more it increases the longer the generation will be)
  77449. */
  77450. size: number;
  77451. /**
  77452. * Defines if mipmaps should not be generated (default is false)
  77453. */
  77454. noMipmap: boolean;
  77455. /**
  77456. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77457. * but the standard material would require them in Gamma space) (default is true)
  77458. */
  77459. gammaSpace: boolean;
  77460. /**
  77461. * Gets the loaded texture
  77462. */
  77463. texture: EquiRectangularCubeTexture;
  77464. /**
  77465. * Callback called when the task is successful
  77466. */
  77467. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77468. /**
  77469. * Callback called when the task is successful
  77470. */
  77471. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77472. /**
  77473. * Creates a new EquiRectangularCubeTextureAssetTask object
  77474. * @param name defines the name of the task
  77475. * @param url defines the location of the file to load
  77476. * @param size defines the desired size (the more it increases the longer the generation will be)
  77477. * If the size is omitted this implies you are using a preprocessed cubemap.
  77478. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77479. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77480. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77481. * (default is true)
  77482. */
  77483. constructor(
  77484. /**
  77485. * Defines the name of the task
  77486. */
  77487. name: string,
  77488. /**
  77489. * Defines the location of the file to load
  77490. */
  77491. url: string,
  77492. /**
  77493. * Defines the desired size (the more it increases the longer the generation will be)
  77494. */
  77495. size: number,
  77496. /**
  77497. * Defines if mipmaps should not be generated (default is false)
  77498. */
  77499. noMipmap?: boolean,
  77500. /**
  77501. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77502. * but the standard material would require them in Gamma space) (default is true)
  77503. */
  77504. gammaSpace?: boolean);
  77505. /**
  77506. * Execute the current task
  77507. * @param scene defines the scene where you want your assets to be loaded
  77508. * @param onSuccess is a callback called when the task is successfully executed
  77509. * @param onError is a callback called if an error occurs
  77510. */
  77511. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77512. }
  77513. /**
  77514. * This class can be used to easily import assets into a scene
  77515. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77516. */
  77517. export class AssetsManager {
  77518. private _scene;
  77519. private _isLoading;
  77520. protected _tasks: AbstractAssetTask[];
  77521. protected _waitingTasksCount: number;
  77522. protected _totalTasksCount: number;
  77523. /**
  77524. * Callback called when all tasks are processed
  77525. */
  77526. onFinish: (tasks: AbstractAssetTask[]) => void;
  77527. /**
  77528. * Callback called when a task is successful
  77529. */
  77530. onTaskSuccess: (task: AbstractAssetTask) => void;
  77531. /**
  77532. * Callback called when a task had an error
  77533. */
  77534. onTaskError: (task: AbstractAssetTask) => void;
  77535. /**
  77536. * Callback called when a task is done (whatever the result is)
  77537. */
  77538. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77539. /**
  77540. * Observable called when all tasks are processed
  77541. */
  77542. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77543. /**
  77544. * Observable called when a task had an error
  77545. */
  77546. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77547. /**
  77548. * Observable called when all tasks were executed
  77549. */
  77550. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77551. /**
  77552. * Observable called when a task is done (whatever the result is)
  77553. */
  77554. onProgressObservable: Observable<IAssetsProgressEvent>;
  77555. /**
  77556. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77557. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77558. */
  77559. useDefaultLoadingScreen: boolean;
  77560. /**
  77561. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77562. * when all assets have been downloaded.
  77563. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77564. */
  77565. autoHideLoadingUI: boolean;
  77566. /**
  77567. * Creates a new AssetsManager
  77568. * @param scene defines the scene to work on
  77569. */
  77570. constructor(scene: Scene);
  77571. /**
  77572. * Add a ContainerAssetTask to the list of active tasks
  77573. * @param taskName defines the name of the new task
  77574. * @param meshesNames defines the name of meshes to load
  77575. * @param rootUrl defines the root url to use to locate files
  77576. * @param sceneFilename defines the filename of the scene file
  77577. * @returns a new ContainerAssetTask object
  77578. */
  77579. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77580. /**
  77581. * Add a MeshAssetTask to the list of active tasks
  77582. * @param taskName defines the name of the new task
  77583. * @param meshesNames defines the name of meshes to load
  77584. * @param rootUrl defines the root url to use to locate files
  77585. * @param sceneFilename defines the filename of the scene file
  77586. * @returns a new MeshAssetTask object
  77587. */
  77588. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77589. /**
  77590. * Add a TextFileAssetTask to the list of active tasks
  77591. * @param taskName defines the name of the new task
  77592. * @param url defines the url of the file to load
  77593. * @returns a new TextFileAssetTask object
  77594. */
  77595. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77596. /**
  77597. * Add a BinaryFileAssetTask to the list of active tasks
  77598. * @param taskName defines the name of the new task
  77599. * @param url defines the url of the file to load
  77600. * @returns a new BinaryFileAssetTask object
  77601. */
  77602. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77603. /**
  77604. * Add a ImageAssetTask to the list of active tasks
  77605. * @param taskName defines the name of the new task
  77606. * @param url defines the url of the file to load
  77607. * @returns a new ImageAssetTask object
  77608. */
  77609. addImageTask(taskName: string, url: string): ImageAssetTask;
  77610. /**
  77611. * Add a TextureAssetTask to the list of active tasks
  77612. * @param taskName defines the name of the new task
  77613. * @param url defines the url of the file to load
  77614. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77615. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77616. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77617. * @returns a new TextureAssetTask object
  77618. */
  77619. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77620. /**
  77621. * Add a CubeTextureAssetTask to the list of active tasks
  77622. * @param taskName defines the name of the new task
  77623. * @param url defines the url of the file to load
  77624. * @param extensions defines the extension to use to load the cube map (can be null)
  77625. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77626. * @param files defines the list of files to load (can be null)
  77627. * @returns a new CubeTextureAssetTask object
  77628. */
  77629. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77630. /**
  77631. *
  77632. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77633. * @param taskName defines the name of the new task
  77634. * @param url defines the url of the file to load
  77635. * @param size defines the size you want for the cubemap (can be null)
  77636. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77637. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77638. * @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)
  77639. * @param reserved Internal use only
  77640. * @returns a new HDRCubeTextureAssetTask object
  77641. */
  77642. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77643. /**
  77644. *
  77645. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77646. * @param taskName defines the name of the new task
  77647. * @param url defines the url of the file to load
  77648. * @param size defines the size you want for the cubemap (can be null)
  77649. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77650. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77651. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77652. * @returns a new EquiRectangularCubeTextureAssetTask object
  77653. */
  77654. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77655. /**
  77656. * Remove a task from the assets manager.
  77657. * @param task the task to remove
  77658. */
  77659. removeTask(task: AbstractAssetTask): void;
  77660. private _decreaseWaitingTasksCount;
  77661. private _runTask;
  77662. /**
  77663. * Reset the AssetsManager and remove all tasks
  77664. * @return the current instance of the AssetsManager
  77665. */
  77666. reset(): AssetsManager;
  77667. /**
  77668. * Start the loading process
  77669. * @return the current instance of the AssetsManager
  77670. */
  77671. load(): AssetsManager;
  77672. /**
  77673. * Start the loading process as an async operation
  77674. * @return a promise returning the list of failed tasks
  77675. */
  77676. loadAsync(): Promise<void>;
  77677. }
  77678. }
  77679. declare module BABYLON {
  77680. /**
  77681. * Wrapper class for promise with external resolve and reject.
  77682. */
  77683. export class Deferred<T> {
  77684. /**
  77685. * The promise associated with this deferred object.
  77686. */
  77687. readonly promise: Promise<T>;
  77688. private _resolve;
  77689. private _reject;
  77690. /**
  77691. * The resolve method of the promise associated with this deferred object.
  77692. */
  77693. get resolve(): (value: T | PromiseLike<T>) => void;
  77694. /**
  77695. * The reject method of the promise associated with this deferred object.
  77696. */
  77697. get reject(): (reason?: any) => void;
  77698. /**
  77699. * Constructor for this deferred object.
  77700. */
  77701. constructor();
  77702. }
  77703. }
  77704. declare module BABYLON {
  77705. /**
  77706. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77707. */
  77708. export class MeshExploder {
  77709. private _centerMesh;
  77710. private _meshes;
  77711. private _meshesOrigins;
  77712. private _toCenterVectors;
  77713. private _scaledDirection;
  77714. private _newPosition;
  77715. private _centerPosition;
  77716. /**
  77717. * Explodes meshes from a center mesh.
  77718. * @param meshes The meshes to explode.
  77719. * @param centerMesh The mesh to be center of explosion.
  77720. */
  77721. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77722. private _setCenterMesh;
  77723. /**
  77724. * Get class name
  77725. * @returns "MeshExploder"
  77726. */
  77727. getClassName(): string;
  77728. /**
  77729. * "Exploded meshes"
  77730. * @returns Array of meshes with the centerMesh at index 0.
  77731. */
  77732. getMeshes(): Array<Mesh>;
  77733. /**
  77734. * Explodes meshes giving a specific direction
  77735. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77736. */
  77737. explode(direction?: number): void;
  77738. }
  77739. }
  77740. declare module BABYLON {
  77741. /**
  77742. * Class used to help managing file picking and drag'n'drop
  77743. */
  77744. export class FilesInput {
  77745. /**
  77746. * List of files ready to be loaded
  77747. */
  77748. static get FilesToLoad(): {
  77749. [key: string]: File;
  77750. };
  77751. /**
  77752. * Callback called when a file is processed
  77753. */
  77754. onProcessFileCallback: (file: File, name: string, extension: string, setSceneFileToLoad: (sceneFile: File) => void) => boolean;
  77755. /**
  77756. * Function used when loading the scene file
  77757. */
  77758. loadAsync: (sceneFile: File, onProgress: Nullable<(event: ISceneLoaderProgressEvent) => void>) => Promise<Scene>;
  77759. private _engine;
  77760. private _currentScene;
  77761. private _sceneLoadedCallback;
  77762. private _progressCallback;
  77763. private _additionalRenderLoopLogicCallback;
  77764. private _textureLoadingCallback;
  77765. private _startingProcessingFilesCallback;
  77766. private _onReloadCallback;
  77767. private _errorCallback;
  77768. private _elementToMonitor;
  77769. private _sceneFileToLoad;
  77770. private _filesToLoad;
  77771. /**
  77772. * Creates a new FilesInput
  77773. * @param engine defines the rendering engine
  77774. * @param scene defines the hosting scene
  77775. * @param sceneLoadedCallback callback called when scene is loaded
  77776. * @param progressCallback callback called to track progress
  77777. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77778. * @param textureLoadingCallback callback called when a texture is loading
  77779. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77780. * @param onReloadCallback callback called when a reload is requested
  77781. * @param errorCallback callback call if an error occurs
  77782. */
  77783. 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>);
  77784. private _dragEnterHandler;
  77785. private _dragOverHandler;
  77786. private _dropHandler;
  77787. /**
  77788. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77789. * @param elementToMonitor defines the DOM element to track
  77790. */
  77791. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77792. /** Gets the current list of files to load */
  77793. get filesToLoad(): File[];
  77794. /**
  77795. * Release all associated resources
  77796. */
  77797. dispose(): void;
  77798. private renderFunction;
  77799. private drag;
  77800. private drop;
  77801. private _traverseFolder;
  77802. private _processFiles;
  77803. /**
  77804. * Load files from a drop event
  77805. * @param event defines the drop event to use as source
  77806. */
  77807. loadFiles(event: any): void;
  77808. private _processReload;
  77809. /**
  77810. * Reload the current scene from the loaded files
  77811. */
  77812. reload(): void;
  77813. }
  77814. }
  77815. declare module BABYLON {
  77816. /**
  77817. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77819. */
  77820. export class SceneOptimization {
  77821. /**
  77822. * Defines the priority of this optimization (0 by default which means first in the list)
  77823. */
  77824. priority: number;
  77825. /**
  77826. * Gets a string describing the action executed by the current optimization
  77827. * @returns description string
  77828. */
  77829. getDescription(): string;
  77830. /**
  77831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77832. * @param scene defines the current scene where to apply this optimization
  77833. * @param optimizer defines the current optimizer
  77834. * @returns true if everything that can be done was applied
  77835. */
  77836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77837. /**
  77838. * Creates the SceneOptimization object
  77839. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77840. * @param desc defines the description associated with the optimization
  77841. */
  77842. constructor(
  77843. /**
  77844. * Defines the priority of this optimization (0 by default which means first in the list)
  77845. */
  77846. priority?: number);
  77847. }
  77848. /**
  77849. * Defines an optimization used to reduce the size of render target textures
  77850. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77851. */
  77852. export class TextureOptimization extends SceneOptimization {
  77853. /**
  77854. * Defines the priority of this optimization (0 by default which means first in the list)
  77855. */
  77856. priority: number;
  77857. /**
  77858. * 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
  77859. */
  77860. maximumSize: number;
  77861. /**
  77862. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77863. */
  77864. step: number;
  77865. /**
  77866. * Gets a string describing the action executed by the current optimization
  77867. * @returns description string
  77868. */
  77869. getDescription(): string;
  77870. /**
  77871. * Creates the TextureOptimization object
  77872. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77873. * @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
  77874. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77875. */
  77876. constructor(
  77877. /**
  77878. * Defines the priority of this optimization (0 by default which means first in the list)
  77879. */
  77880. priority?: number,
  77881. /**
  77882. * 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
  77883. */
  77884. maximumSize?: number,
  77885. /**
  77886. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77887. */
  77888. step?: number);
  77889. /**
  77890. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77891. * @param scene defines the current scene where to apply this optimization
  77892. * @param optimizer defines the current optimizer
  77893. * @returns true if everything that can be done was applied
  77894. */
  77895. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77896. }
  77897. /**
  77898. * Defines an optimization used to increase or decrease the rendering resolution
  77899. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77900. */
  77901. export class HardwareScalingOptimization extends SceneOptimization {
  77902. /**
  77903. * Defines the priority of this optimization (0 by default which means first in the list)
  77904. */
  77905. priority: number;
  77906. /**
  77907. * Defines the maximum scale to use (2 by default)
  77908. */
  77909. maximumScale: number;
  77910. /**
  77911. * Defines the step to use between two passes (0.5 by default)
  77912. */
  77913. step: number;
  77914. private _currentScale;
  77915. private _directionOffset;
  77916. /**
  77917. * Gets a string describing the action executed by the current optimization
  77918. * @return description string
  77919. */
  77920. getDescription(): string;
  77921. /**
  77922. * Creates the HardwareScalingOptimization object
  77923. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77924. * @param maximumScale defines the maximum scale to use (2 by default)
  77925. * @param step defines the step to use between two passes (0.5 by default)
  77926. */
  77927. constructor(
  77928. /**
  77929. * Defines the priority of this optimization (0 by default which means first in the list)
  77930. */
  77931. priority?: number,
  77932. /**
  77933. * Defines the maximum scale to use (2 by default)
  77934. */
  77935. maximumScale?: number,
  77936. /**
  77937. * Defines the step to use between two passes (0.5 by default)
  77938. */
  77939. step?: number);
  77940. /**
  77941. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77942. * @param scene defines the current scene where to apply this optimization
  77943. * @param optimizer defines the current optimizer
  77944. * @returns true if everything that can be done was applied
  77945. */
  77946. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77947. }
  77948. /**
  77949. * Defines an optimization used to remove shadows
  77950. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77951. */
  77952. export class ShadowsOptimization extends SceneOptimization {
  77953. /**
  77954. * Gets a string describing the action executed by the current optimization
  77955. * @return description string
  77956. */
  77957. getDescription(): string;
  77958. /**
  77959. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77960. * @param scene defines the current scene where to apply this optimization
  77961. * @param optimizer defines the current optimizer
  77962. * @returns true if everything that can be done was applied
  77963. */
  77964. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77965. }
  77966. /**
  77967. * Defines an optimization used to turn post-processes off
  77968. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77969. */
  77970. export class PostProcessesOptimization extends SceneOptimization {
  77971. /**
  77972. * Gets a string describing the action executed by the current optimization
  77973. * @return description string
  77974. */
  77975. getDescription(): string;
  77976. /**
  77977. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77978. * @param scene defines the current scene where to apply this optimization
  77979. * @param optimizer defines the current optimizer
  77980. * @returns true if everything that can be done was applied
  77981. */
  77982. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77983. }
  77984. /**
  77985. * Defines an optimization used to turn lens flares off
  77986. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77987. */
  77988. export class LensFlaresOptimization extends SceneOptimization {
  77989. /**
  77990. * Gets a string describing the action executed by the current optimization
  77991. * @return description string
  77992. */
  77993. getDescription(): string;
  77994. /**
  77995. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77996. * @param scene defines the current scene where to apply this optimization
  77997. * @param optimizer defines the current optimizer
  77998. * @returns true if everything that can be done was applied
  77999. */
  78000. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78001. }
  78002. /**
  78003. * Defines an optimization based on user defined callback.
  78004. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78005. */
  78006. export class CustomOptimization extends SceneOptimization {
  78007. /**
  78008. * Callback called to apply the custom optimization.
  78009. */
  78010. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78011. /**
  78012. * Callback called to get custom description
  78013. */
  78014. onGetDescription: () => string;
  78015. /**
  78016. * Gets a string describing the action executed by the current optimization
  78017. * @returns description string
  78018. */
  78019. getDescription(): string;
  78020. /**
  78021. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78022. * @param scene defines the current scene where to apply this optimization
  78023. * @param optimizer defines the current optimizer
  78024. * @returns true if everything that can be done was applied
  78025. */
  78026. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78027. }
  78028. /**
  78029. * Defines an optimization used to turn particles off
  78030. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78031. */
  78032. export class ParticlesOptimization extends SceneOptimization {
  78033. /**
  78034. * Gets a string describing the action executed by the current optimization
  78035. * @return description string
  78036. */
  78037. getDescription(): string;
  78038. /**
  78039. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78040. * @param scene defines the current scene where to apply this optimization
  78041. * @param optimizer defines the current optimizer
  78042. * @returns true if everything that can be done was applied
  78043. */
  78044. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78045. }
  78046. /**
  78047. * Defines an optimization used to turn render targets off
  78048. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78049. */
  78050. export class RenderTargetsOptimization extends SceneOptimization {
  78051. /**
  78052. * Gets a string describing the action executed by the current optimization
  78053. * @return description string
  78054. */
  78055. getDescription(): string;
  78056. /**
  78057. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78058. * @param scene defines the current scene where to apply this optimization
  78059. * @param optimizer defines the current optimizer
  78060. * @returns true if everything that can be done was applied
  78061. */
  78062. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78063. }
  78064. /**
  78065. * Defines an optimization used to merge meshes with compatible materials
  78066. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78067. */
  78068. export class MergeMeshesOptimization extends SceneOptimization {
  78069. private static _UpdateSelectionTree;
  78070. /**
  78071. * Gets or sets a boolean which defines if optimization octree has to be updated
  78072. */
  78073. static get UpdateSelectionTree(): boolean;
  78074. /**
  78075. * Gets or sets a boolean which defines if optimization octree has to be updated
  78076. */
  78077. static set UpdateSelectionTree(value: boolean);
  78078. /**
  78079. * Gets a string describing the action executed by the current optimization
  78080. * @return description string
  78081. */
  78082. getDescription(): string;
  78083. private _canBeMerged;
  78084. /**
  78085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78086. * @param scene defines the current scene where to apply this optimization
  78087. * @param optimizer defines the current optimizer
  78088. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78089. * @returns true if everything that can be done was applied
  78090. */
  78091. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78092. }
  78093. /**
  78094. * Defines a list of options used by SceneOptimizer
  78095. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78096. */
  78097. export class SceneOptimizerOptions {
  78098. /**
  78099. * Defines the target frame rate to reach (60 by default)
  78100. */
  78101. targetFrameRate: number;
  78102. /**
  78103. * Defines the interval between two checkes (2000ms by default)
  78104. */
  78105. trackerDuration: number;
  78106. /**
  78107. * Gets the list of optimizations to apply
  78108. */
  78109. optimizations: SceneOptimization[];
  78110. /**
  78111. * Creates a new list of options used by SceneOptimizer
  78112. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78113. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78114. */
  78115. constructor(
  78116. /**
  78117. * Defines the target frame rate to reach (60 by default)
  78118. */
  78119. targetFrameRate?: number,
  78120. /**
  78121. * Defines the interval between two checkes (2000ms by default)
  78122. */
  78123. trackerDuration?: number);
  78124. /**
  78125. * Add a new optimization
  78126. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78127. * @returns the current SceneOptimizerOptions
  78128. */
  78129. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78130. /**
  78131. * Add a new custom optimization
  78132. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78133. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78134. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78135. * @returns the current SceneOptimizerOptions
  78136. */
  78137. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78138. /**
  78139. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78140. * @param targetFrameRate defines the target frame rate (60 by default)
  78141. * @returns a SceneOptimizerOptions object
  78142. */
  78143. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78144. /**
  78145. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78146. * @param targetFrameRate defines the target frame rate (60 by default)
  78147. * @returns a SceneOptimizerOptions object
  78148. */
  78149. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78150. /**
  78151. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78152. * @param targetFrameRate defines the target frame rate (60 by default)
  78153. * @returns a SceneOptimizerOptions object
  78154. */
  78155. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78156. }
  78157. /**
  78158. * Class used to run optimizations in order to reach a target frame rate
  78159. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78160. */
  78161. export class SceneOptimizer implements IDisposable {
  78162. private _isRunning;
  78163. private _options;
  78164. private _scene;
  78165. private _currentPriorityLevel;
  78166. private _targetFrameRate;
  78167. private _trackerDuration;
  78168. private _currentFrameRate;
  78169. private _sceneDisposeObserver;
  78170. private _improvementMode;
  78171. /**
  78172. * Defines an observable called when the optimizer reaches the target frame rate
  78173. */
  78174. onSuccessObservable: Observable<SceneOptimizer>;
  78175. /**
  78176. * Defines an observable called when the optimizer enables an optimization
  78177. */
  78178. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78179. /**
  78180. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78181. */
  78182. onFailureObservable: Observable<SceneOptimizer>;
  78183. /**
  78184. * Gets a boolean indicating if the optimizer is in improvement mode
  78185. */
  78186. get isInImprovementMode(): boolean;
  78187. /**
  78188. * Gets the current priority level (0 at start)
  78189. */
  78190. get currentPriorityLevel(): number;
  78191. /**
  78192. * Gets the current frame rate checked by the SceneOptimizer
  78193. */
  78194. get currentFrameRate(): number;
  78195. /**
  78196. * Gets or sets the current target frame rate (60 by default)
  78197. */
  78198. get targetFrameRate(): number;
  78199. /**
  78200. * Gets or sets the current target frame rate (60 by default)
  78201. */
  78202. set targetFrameRate(value: number);
  78203. /**
  78204. * Gets or sets the current interval between two checks (every 2000ms by default)
  78205. */
  78206. get trackerDuration(): number;
  78207. /**
  78208. * Gets or sets the current interval between two checks (every 2000ms by default)
  78209. */
  78210. set trackerDuration(value: number);
  78211. /**
  78212. * Gets the list of active optimizations
  78213. */
  78214. get optimizations(): SceneOptimization[];
  78215. /**
  78216. * Creates a new SceneOptimizer
  78217. * @param scene defines the scene to work on
  78218. * @param options defines the options to use with the SceneOptimizer
  78219. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78220. * @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)
  78221. */
  78222. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78223. /**
  78224. * Stops the current optimizer
  78225. */
  78226. stop(): void;
  78227. /**
  78228. * Reset the optimizer to initial step (current priority level = 0)
  78229. */
  78230. reset(): void;
  78231. /**
  78232. * Start the optimizer. By default it will try to reach a specific framerate
  78233. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78234. */
  78235. start(): void;
  78236. private _checkCurrentState;
  78237. /**
  78238. * Release all resources
  78239. */
  78240. dispose(): void;
  78241. /**
  78242. * Helper function to create a SceneOptimizer with one single line of code
  78243. * @param scene defines the scene to work on
  78244. * @param options defines the options to use with the SceneOptimizer
  78245. * @param onSuccess defines a callback to call on success
  78246. * @param onFailure defines a callback to call on failure
  78247. * @returns the new SceneOptimizer object
  78248. */
  78249. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78250. }
  78251. }
  78252. declare module BABYLON {
  78253. /**
  78254. * Class used to serialize a scene into a string
  78255. */
  78256. export class SceneSerializer {
  78257. /**
  78258. * Clear cache used by a previous serialization
  78259. */
  78260. static ClearCache(): void;
  78261. /**
  78262. * Serialize a scene into a JSON compatible object
  78263. * @param scene defines the scene to serialize
  78264. * @returns a JSON compatible object
  78265. */
  78266. static Serialize(scene: Scene): any;
  78267. /**
  78268. * Serialize a mesh into a JSON compatible object
  78269. * @param toSerialize defines the mesh to serialize
  78270. * @param withParents defines if parents must be serialized as well
  78271. * @param withChildren defines if children must be serialized as well
  78272. * @returns a JSON compatible object
  78273. */
  78274. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78275. }
  78276. }
  78277. declare module BABYLON {
  78278. /**
  78279. * This represents the different options available for the video capture.
  78280. */
  78281. export interface VideoRecorderOptions {
  78282. /** Defines the mime type of the video. */
  78283. mimeType: string;
  78284. /** Defines the FPS the video should be recorded at. */
  78285. fps: number;
  78286. /** Defines the chunk size for the recording data. */
  78287. recordChunckSize: number;
  78288. /** The audio tracks to attach to the recording. */
  78289. audioTracks?: MediaStreamTrack[];
  78290. }
  78291. /**
  78292. * This can help with recording videos from BabylonJS.
  78293. * This is based on the available WebRTC functionalities of the browser.
  78294. *
  78295. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78296. */
  78297. export class VideoRecorder {
  78298. private static readonly _defaultOptions;
  78299. /**
  78300. * Returns whether or not the VideoRecorder is available in your browser.
  78301. * @param engine Defines the Babylon Engine.
  78302. * @returns true if supported otherwise false.
  78303. */
  78304. static IsSupported(engine: Engine): boolean;
  78305. private readonly _options;
  78306. private _canvas;
  78307. private _mediaRecorder;
  78308. private _recordedChunks;
  78309. private _fileName;
  78310. private _resolve;
  78311. private _reject;
  78312. /**
  78313. * True when a recording is already in progress.
  78314. */
  78315. get isRecording(): boolean;
  78316. /**
  78317. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78318. * @param engine Defines the BabylonJS Engine you wish to record.
  78319. * @param options Defines options that can be used to customize the capture.
  78320. */
  78321. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78322. /**
  78323. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78324. */
  78325. stopRecording(): void;
  78326. /**
  78327. * Starts recording the canvas for a max duration specified in parameters.
  78328. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78329. * If null no automatic download will start and you can rely on the promise to get the data back.
  78330. * @param maxDuration Defines the maximum recording time in seconds.
  78331. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78332. * @return A promise callback at the end of the recording with the video data in Blob.
  78333. */
  78334. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78335. /**
  78336. * Releases internal resources used during the recording.
  78337. */
  78338. dispose(): void;
  78339. private _handleDataAvailable;
  78340. private _handleError;
  78341. private _handleStop;
  78342. }
  78343. }
  78344. declare module BABYLON {
  78345. /**
  78346. * Class containing a set of static utilities functions for screenshots
  78347. */
  78348. export class ScreenshotTools {
  78349. /**
  78350. * Captures a screenshot of the current rendering
  78351. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78352. * @param engine defines the rendering engine
  78353. * @param camera defines the source camera
  78354. * @param size This parameter can be set to a single number or to an object with the
  78355. * following (optional) properties: precision, width, height. If a single number is passed,
  78356. * it will be used for both width and height. If an object is passed, the screenshot size
  78357. * will be derived from the parameters. The precision property is a multiplier allowing
  78358. * rendering at a higher or lower resolution
  78359. * @param successCallback defines the callback receives a single parameter which contains the
  78360. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78361. * src parameter of an <img> to display it
  78362. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78363. * Check your browser for supported MIME types
  78364. * @param forceDownload force the system to download the image even if a successCallback is provided
  78365. */
  78366. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, forceDownload?: boolean): void;
  78367. /**
  78368. * Captures a screenshot of the current rendering
  78369. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78370. * @param engine defines the rendering engine
  78371. * @param camera defines the source camera
  78372. * @param size This parameter can be set to a single number or to an object with the
  78373. * following (optional) properties: precision, width, height. If a single number is passed,
  78374. * it will be used for both width and height. If an object is passed, the screenshot size
  78375. * will be derived from the parameters. The precision property is a multiplier allowing
  78376. * rendering at a higher or lower resolution
  78377. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78378. * Check your browser for supported MIME types
  78379. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78380. * to the src parameter of an <img> to display it
  78381. */
  78382. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78383. /**
  78384. * 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)
  78385. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78386. * @param engine defines the rendering engine
  78387. * @param camera defines the source camera
  78388. * @param width defines the expected width
  78389. * @param height defines the expected height
  78390. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78391. * Check your browser for supported MIME types
  78392. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78393. * to the src parameter of an <img> to display it
  78394. */
  78395. static CreateScreenshotWithResizeAsync(engine: Engine, camera: Camera, width: number, height: number, mimeType?: string): Promise<void>;
  78396. /**
  78397. * Generates an image screenshot from the specified camera.
  78398. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78399. * @param engine The engine to use for rendering
  78400. * @param camera The camera to use for rendering
  78401. * @param size This parameter can be set to a single number or to an object with the
  78402. * following (optional) properties: precision, width, height. If a single number is passed,
  78403. * it will be used for both width and height. If an object is passed, the screenshot size
  78404. * will be derived from the parameters. The precision property is a multiplier allowing
  78405. * rendering at a higher or lower resolution
  78406. * @param successCallback The callback receives a single parameter which contains the
  78407. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78408. * src parameter of an <img> to display it
  78409. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78410. * Check your browser for supported MIME types
  78411. * @param samples Texture samples (default: 1)
  78412. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78413. * @param fileName A name for for the downloaded file.
  78414. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78415. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78416. */
  78417. 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;
  78418. /**
  78419. * Generates an image screenshot from the specified camera.
  78420. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78421. * @param engine The engine to use for rendering
  78422. * @param camera The camera to use for rendering
  78423. * @param size This parameter can be set to a single number or to an object with the
  78424. * following (optional) properties: precision, width, height. If a single number is passed,
  78425. * it will be used for both width and height. If an object is passed, the screenshot size
  78426. * will be derived from the parameters. The precision property is a multiplier allowing
  78427. * rendering at a higher or lower resolution
  78428. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78429. * Check your browser for supported MIME types
  78430. * @param samples Texture samples (default: 1)
  78431. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78432. * @param fileName A name for for the downloaded file.
  78433. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78434. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78435. * to the src parameter of an <img> to display it
  78436. */
  78437. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78438. /**
  78439. * Gets height and width for screenshot size
  78440. * @private
  78441. */
  78442. private static _getScreenshotSize;
  78443. }
  78444. }
  78445. declare module BABYLON {
  78446. /**
  78447. * Interface for a data buffer
  78448. */
  78449. export interface IDataBuffer {
  78450. /**
  78451. * Reads bytes from the data buffer.
  78452. * @param byteOffset The byte offset to read
  78453. * @param byteLength The byte length to read
  78454. * @returns A promise that resolves when the bytes are read
  78455. */
  78456. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78457. /**
  78458. * The byte length of the buffer.
  78459. */
  78460. readonly byteLength: number;
  78461. }
  78462. /**
  78463. * Utility class for reading from a data buffer
  78464. */
  78465. export class DataReader {
  78466. /**
  78467. * The data buffer associated with this data reader.
  78468. */
  78469. readonly buffer: IDataBuffer;
  78470. /**
  78471. * The current byte offset from the beginning of the data buffer.
  78472. */
  78473. byteOffset: number;
  78474. private _dataView;
  78475. private _dataByteOffset;
  78476. /**
  78477. * Constructor
  78478. * @param buffer The buffer to read
  78479. */
  78480. constructor(buffer: IDataBuffer);
  78481. /**
  78482. * Loads the given byte length.
  78483. * @param byteLength The byte length to load
  78484. * @returns A promise that resolves when the load is complete
  78485. */
  78486. loadAsync(byteLength: number): Promise<void>;
  78487. /**
  78488. * Read a unsigned 32-bit integer from the currently loaded data range.
  78489. * @returns The 32-bit integer read
  78490. */
  78491. readUint32(): number;
  78492. /**
  78493. * Read a byte array from the currently loaded data range.
  78494. * @param byteLength The byte length to read
  78495. * @returns The byte array read
  78496. */
  78497. readUint8Array(byteLength: number): Uint8Array;
  78498. /**
  78499. * Read a string from the currently loaded data range.
  78500. * @param byteLength The byte length to read
  78501. * @returns The string read
  78502. */
  78503. readString(byteLength: number): string;
  78504. /**
  78505. * Skips the given byte length the currently loaded data range.
  78506. * @param byteLength The byte length to skip
  78507. */
  78508. skipBytes(byteLength: number): void;
  78509. }
  78510. }
  78511. declare module BABYLON {
  78512. /**
  78513. * Class for storing data to local storage if available or in-memory storage otherwise
  78514. */
  78515. export class DataStorage {
  78516. private static _Storage;
  78517. private static _GetStorage;
  78518. /**
  78519. * Reads a string from the data storage
  78520. * @param key The key to read
  78521. * @param defaultValue The value if the key doesn't exist
  78522. * @returns The string value
  78523. */
  78524. static ReadString(key: string, defaultValue: string): string;
  78525. /**
  78526. * Writes a string to the data storage
  78527. * @param key The key to write
  78528. * @param value The value to write
  78529. */
  78530. static WriteString(key: string, value: string): void;
  78531. /**
  78532. * Reads a boolean from the data storage
  78533. * @param key The key to read
  78534. * @param defaultValue The value if the key doesn't exist
  78535. * @returns The boolean value
  78536. */
  78537. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78538. /**
  78539. * Writes a boolean to the data storage
  78540. * @param key The key to write
  78541. * @param value The value to write
  78542. */
  78543. static WriteBoolean(key: string, value: boolean): void;
  78544. /**
  78545. * Reads a number from the data storage
  78546. * @param key The key to read
  78547. * @param defaultValue The value if the key doesn't exist
  78548. * @returns The number value
  78549. */
  78550. static ReadNumber(key: string, defaultValue: number): number;
  78551. /**
  78552. * Writes a number to the data storage
  78553. * @param key The key to write
  78554. * @param value The value to write
  78555. */
  78556. static WriteNumber(key: string, value: number): void;
  78557. }
  78558. }
  78559. declare module BABYLON {
  78560. /**
  78561. * Class used to record delta files between 2 scene states
  78562. */
  78563. export class SceneRecorder {
  78564. private _trackedScene;
  78565. private _savedJSON;
  78566. /**
  78567. * Track a given scene. This means the current scene state will be considered the original state
  78568. * @param scene defines the scene to track
  78569. */
  78570. track(scene: Scene): void;
  78571. /**
  78572. * Get the delta between current state and original state
  78573. * @returns a string containing the delta
  78574. */
  78575. getDelta(): any;
  78576. private _compareArray;
  78577. private _compareObjects;
  78578. private _compareCollections;
  78579. private static GetShadowGeneratorById;
  78580. /**
  78581. * Apply a given delta to a given scene
  78582. * @param deltaJSON defines the JSON containing the delta
  78583. * @param scene defines the scene to apply the delta to
  78584. */
  78585. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78586. private static _ApplyPropertiesToEntity;
  78587. private static _ApplyDeltaForEntity;
  78588. }
  78589. }
  78590. declare module BABYLON {
  78591. /**
  78592. * A 3D trajectory consisting of an order list of vectors describing a
  78593. * path of motion through 3D space.
  78594. */
  78595. export class Trajectory {
  78596. private _points;
  78597. private readonly _segmentLength;
  78598. /**
  78599. * Serialize to JSON.
  78600. * @returns serialized JSON string
  78601. */
  78602. serialize(): string;
  78603. /**
  78604. * Deserialize from JSON.
  78605. * @param json serialized JSON string
  78606. * @returns deserialized Trajectory
  78607. */
  78608. static Deserialize(json: string): Trajectory;
  78609. /**
  78610. * Create a new empty Trajectory.
  78611. * @param segmentLength radius of discretization for Trajectory points
  78612. */
  78613. constructor(segmentLength?: number);
  78614. /**
  78615. * Get the length of the Trajectory.
  78616. * @returns length of the Trajectory
  78617. */
  78618. getLength(): number;
  78619. /**
  78620. * Append a new point to the Trajectory.
  78621. * NOTE: This implementation has many allocations.
  78622. * @param point point to append to the Trajectory
  78623. */
  78624. add(point: DeepImmutable<Vector3>): void;
  78625. /**
  78626. * Create a new Trajectory with a segment length chosen to make it
  78627. * probable that the new Trajectory will have a specified number of
  78628. * segments. This operation is imprecise.
  78629. * @param targetResolution number of segments desired
  78630. * @returns new Trajectory with approximately the requested number of segments
  78631. */
  78632. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78633. /**
  78634. * Convert Trajectory segments into tokenized representation. This
  78635. * representation is an array of numbers where each nth number is the
  78636. * index of the token which is most similar to the nth segment of the
  78637. * Trajectory.
  78638. * @param tokens list of vectors which serve as discrete tokens
  78639. * @returns list of indices of most similar token per segment
  78640. */
  78641. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78642. private static _forwardDir;
  78643. private static _inverseFromVec;
  78644. private static _upDir;
  78645. private static _fromToVec;
  78646. private static _lookMatrix;
  78647. /**
  78648. * Transform the rotation (i.e., direction) of a segment to isolate
  78649. * the relative transformation represented by the segment. This operation
  78650. * may or may not succeed due to singularities in the equations that define
  78651. * motion relativity in this context.
  78652. * @param priorVec the origin of the prior segment
  78653. * @param fromVec the origin of the current segment
  78654. * @param toVec the destination of the current segment
  78655. * @param result reference to output variable
  78656. * @returns whether or not transformation was successful
  78657. */
  78658. private static _transformSegmentDirToRef;
  78659. private static _bestMatch;
  78660. private static _score;
  78661. private static _bestScore;
  78662. /**
  78663. * Determine which token vector is most similar to the
  78664. * segment vector.
  78665. * @param segment segment vector
  78666. * @param tokens token vector list
  78667. * @returns index of the most similar token to the segment
  78668. */
  78669. private static _tokenizeSegment;
  78670. }
  78671. /**
  78672. * Class representing a set of known, named trajectories to which Trajectories can be
  78673. * added and using which Trajectories can be recognized.
  78674. */
  78675. export class TrajectoryClassifier {
  78676. private _maximumAllowableMatchCost;
  78677. private _vector3Alphabet;
  78678. private _levenshteinAlphabet;
  78679. private _nameToDescribedTrajectory;
  78680. /**
  78681. * Serialize to JSON.
  78682. * @returns JSON serialization
  78683. */
  78684. serialize(): string;
  78685. /**
  78686. * Deserialize from JSON.
  78687. * @param json JSON serialization
  78688. * @returns deserialized TrajectorySet
  78689. */
  78690. static Deserialize(json: string): TrajectoryClassifier;
  78691. /**
  78692. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78693. * VERY naive, need to be generating these things from known
  78694. * sets. Better version later, probably eliminating this one.
  78695. * @returns auto-generated TrajectorySet
  78696. */
  78697. static Generate(): TrajectoryClassifier;
  78698. private constructor();
  78699. /**
  78700. * Add a new Trajectory to the set with a given name.
  78701. * @param trajectory new Trajectory to be added
  78702. * @param classification name to which to add the Trajectory
  78703. */
  78704. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78705. /**
  78706. * Remove a known named trajectory and all Trajectories associated with it.
  78707. * @param classification name to remove
  78708. * @returns whether anything was removed
  78709. */
  78710. deleteClassification(classification: string): boolean;
  78711. /**
  78712. * Attempt to recognize a Trajectory from among all the classifications
  78713. * already known to the classifier.
  78714. * @param trajectory Trajectory to be recognized
  78715. * @returns classification of Trajectory if recognized, null otherwise
  78716. */
  78717. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78718. }
  78719. }
  78720. declare module BABYLON {
  78721. /**
  78722. * An interface for all Hit test features
  78723. */
  78724. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78725. /**
  78726. * Triggered when new babylon (transformed) hit test results are available
  78727. */
  78728. onHitTestResultObservable: Observable<T[]>;
  78729. }
  78730. /**
  78731. * Options used for hit testing
  78732. */
  78733. export interface IWebXRLegacyHitTestOptions {
  78734. /**
  78735. * Only test when user interacted with the scene. Default - hit test every frame
  78736. */
  78737. testOnPointerDownOnly?: boolean;
  78738. /**
  78739. * The node to use to transform the local results to world coordinates
  78740. */
  78741. worldParentNode?: TransformNode;
  78742. }
  78743. /**
  78744. * Interface defining the babylon result of raycasting/hit-test
  78745. */
  78746. export interface IWebXRLegacyHitResult {
  78747. /**
  78748. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78749. */
  78750. transformationMatrix: Matrix;
  78751. /**
  78752. * The native hit test result
  78753. */
  78754. xrHitResult: XRHitResult | XRHitTestResult;
  78755. }
  78756. /**
  78757. * The currently-working hit-test module.
  78758. * Hit test (or Ray-casting) is used to interact with the real world.
  78759. * For further information read here - https://github.com/immersive-web/hit-test
  78760. */
  78761. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78762. /**
  78763. * options to use when constructing this feature
  78764. */
  78765. readonly options: IWebXRLegacyHitTestOptions;
  78766. private _direction;
  78767. private _mat;
  78768. private _onSelectEnabled;
  78769. private _origin;
  78770. /**
  78771. * The module's name
  78772. */
  78773. static readonly Name: string;
  78774. /**
  78775. * The (Babylon) version of this module.
  78776. * This is an integer representing the implementation version.
  78777. * This number does not correspond to the WebXR specs version
  78778. */
  78779. static readonly Version: number;
  78780. /**
  78781. * Populated with the last native XR Hit Results
  78782. */
  78783. lastNativeXRHitResults: XRHitResult[];
  78784. /**
  78785. * Triggered when new babylon (transformed) hit test results are available
  78786. */
  78787. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78788. /**
  78789. * Creates a new instance of the (legacy version) hit test feature
  78790. * @param _xrSessionManager an instance of WebXRSessionManager
  78791. * @param options options to use when constructing this feature
  78792. */
  78793. constructor(_xrSessionManager: WebXRSessionManager,
  78794. /**
  78795. * options to use when constructing this feature
  78796. */
  78797. options?: IWebXRLegacyHitTestOptions);
  78798. /**
  78799. * execute a hit test with an XR Ray
  78800. *
  78801. * @param xrSession a native xrSession that will execute this hit test
  78802. * @param xrRay the ray (position and direction) to use for ray-casting
  78803. * @param referenceSpace native XR reference space to use for the hit-test
  78804. * @param filter filter function that will filter the results
  78805. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78806. */
  78807. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78808. /**
  78809. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78810. * @param event the (select) event to use to select with
  78811. * @param referenceSpace the reference space to use for this hit test
  78812. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78813. */
  78814. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78815. /**
  78816. * attach this feature
  78817. * Will usually be called by the features manager
  78818. *
  78819. * @returns true if successful.
  78820. */
  78821. attach(): boolean;
  78822. /**
  78823. * detach this feature.
  78824. * Will usually be called by the features manager
  78825. *
  78826. * @returns true if successful.
  78827. */
  78828. detach(): boolean;
  78829. /**
  78830. * Dispose this feature and all of the resources attached
  78831. */
  78832. dispose(): void;
  78833. protected _onXRFrame(frame: XRFrame): void;
  78834. private _onHitTestResults;
  78835. private _onSelect;
  78836. }
  78837. }
  78838. declare module BABYLON {
  78839. /**
  78840. * Options used for hit testing (version 2)
  78841. */
  78842. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  78843. /**
  78844. * Do not create a permanent hit test. Will usually be used when only
  78845. * transient inputs are needed.
  78846. */
  78847. disablePermanentHitTest?: boolean;
  78848. /**
  78849. * Enable transient (for example touch-based) hit test inspections
  78850. */
  78851. enableTransientHitTest?: boolean;
  78852. /**
  78853. * Offset ray for the permanent hit test
  78854. */
  78855. offsetRay?: Vector3;
  78856. /**
  78857. * Offset ray for the transient hit test
  78858. */
  78859. transientOffsetRay?: Vector3;
  78860. /**
  78861. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  78862. */
  78863. useReferenceSpace?: boolean;
  78864. /**
  78865. * Override the default entity type(s) of the hit-test result
  78866. */
  78867. entityTypes?: XRHitTestTrackableType[];
  78868. }
  78869. /**
  78870. * Interface defining the babylon result of hit-test
  78871. */
  78872. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  78873. /**
  78874. * The input source that generated this hit test (if transient)
  78875. */
  78876. inputSource?: XRInputSource;
  78877. /**
  78878. * Is this a transient hit test
  78879. */
  78880. isTransient?: boolean;
  78881. /**
  78882. * Position of the hit test result
  78883. */
  78884. position: Vector3;
  78885. /**
  78886. * Rotation of the hit test result
  78887. */
  78888. rotationQuaternion: Quaternion;
  78889. /**
  78890. * The native hit test result
  78891. */
  78892. xrHitResult: XRHitTestResult;
  78893. }
  78894. /**
  78895. * The currently-working hit-test module.
  78896. * Hit test (or Ray-casting) is used to interact with the real world.
  78897. * For further information read here - https://github.com/immersive-web/hit-test
  78898. *
  78899. * Tested on chrome (mobile) 80.
  78900. */
  78901. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  78902. /**
  78903. * options to use when constructing this feature
  78904. */
  78905. readonly options: IWebXRHitTestOptions;
  78906. private _tmpMat;
  78907. private _tmpPos;
  78908. private _tmpQuat;
  78909. private _transientXrHitTestSource;
  78910. private _xrHitTestSource;
  78911. private initHitTestSource;
  78912. /**
  78913. * The module's name
  78914. */
  78915. static readonly Name: string;
  78916. /**
  78917. * The (Babylon) version of this module.
  78918. * This is an integer representing the implementation version.
  78919. * This number does not correspond to the WebXR specs version
  78920. */
  78921. static readonly Version: number;
  78922. /**
  78923. * When set to true, each hit test will have its own position/rotation objects
  78924. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  78925. * the developers will clone them or copy them as they see fit.
  78926. */
  78927. autoCloneTransformation: boolean;
  78928. /**
  78929. * Triggered when new babylon (transformed) hit test results are available
  78930. * Note - this will be called when results come back from the device. It can be an empty array!!
  78931. */
  78932. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  78933. /**
  78934. * Use this to temporarily pause hit test checks.
  78935. */
  78936. paused: boolean;
  78937. /**
  78938. * Creates a new instance of the hit test feature
  78939. * @param _xrSessionManager an instance of WebXRSessionManager
  78940. * @param options options to use when constructing this feature
  78941. */
  78942. constructor(_xrSessionManager: WebXRSessionManager,
  78943. /**
  78944. * options to use when constructing this feature
  78945. */
  78946. options?: IWebXRHitTestOptions);
  78947. /**
  78948. * attach this feature
  78949. * Will usually be called by the features manager
  78950. *
  78951. * @returns true if successful.
  78952. */
  78953. attach(): boolean;
  78954. /**
  78955. * detach this feature.
  78956. * Will usually be called by the features manager
  78957. *
  78958. * @returns true if successful.
  78959. */
  78960. detach(): boolean;
  78961. /**
  78962. * Dispose this feature and all of the resources attached
  78963. */
  78964. dispose(): void;
  78965. protected _onXRFrame(frame: XRFrame): void;
  78966. private _processWebXRHitTestResult;
  78967. }
  78968. }
  78969. declare module BABYLON {
  78970. /**
  78971. * Configuration options of the anchor system
  78972. */
  78973. export interface IWebXRAnchorSystemOptions {
  78974. /**
  78975. * a node that will be used to convert local to world coordinates
  78976. */
  78977. worldParentNode?: TransformNode;
  78978. /**
  78979. * If set to true a reference of the created anchors will be kept until the next session starts
  78980. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  78981. */
  78982. doNotRemoveAnchorsOnSessionEnded?: boolean;
  78983. }
  78984. /**
  78985. * A babylon container for an XR Anchor
  78986. */
  78987. export interface IWebXRAnchor {
  78988. /**
  78989. * A babylon-assigned ID for this anchor
  78990. */
  78991. id: number;
  78992. /**
  78993. * Transformation matrix to apply to an object attached to this anchor
  78994. */
  78995. transformationMatrix: Matrix;
  78996. /**
  78997. * The native anchor object
  78998. */
  78999. xrAnchor: XRAnchor;
  79000. /**
  79001. * if defined, this object will be constantly updated by the anchor's position and rotation
  79002. */
  79003. attachedNode?: TransformNode;
  79004. /**
  79005. * Remove this anchor from the scene
  79006. */
  79007. remove(): void;
  79008. }
  79009. /**
  79010. * An implementation of the anchor system for WebXR.
  79011. * For further information see https://github.com/immersive-web/anchors/
  79012. */
  79013. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79014. private _options;
  79015. private _lastFrameDetected;
  79016. private _trackedAnchors;
  79017. private _referenceSpaceForFrameAnchors;
  79018. private _futureAnchors;
  79019. /**
  79020. * The module's name
  79021. */
  79022. static readonly Name: string;
  79023. /**
  79024. * The (Babylon) version of this module.
  79025. * This is an integer representing the implementation version.
  79026. * This number does not correspond to the WebXR specs version
  79027. */
  79028. static readonly Version: number;
  79029. /**
  79030. * Observers registered here will be executed when a new anchor was added to the session
  79031. */
  79032. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79033. /**
  79034. * Observers registered here will be executed when an anchor was removed from the session
  79035. */
  79036. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79037. /**
  79038. * Observers registered here will be executed when an existing anchor updates
  79039. * This can execute N times every frame
  79040. */
  79041. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79042. /**
  79043. * Set the reference space to use for anchor creation, when not using a hit test.
  79044. * Will default to the session's reference space if not defined
  79045. */
  79046. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79047. /**
  79048. * constructs a new anchor system
  79049. * @param _xrSessionManager an instance of WebXRSessionManager
  79050. * @param _options configuration object for this feature
  79051. */
  79052. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79053. private _tmpVector;
  79054. private _tmpQuaternion;
  79055. private _populateTmpTransformation;
  79056. /**
  79057. * Create a new anchor point using a hit test result at a specific point in the scene
  79058. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79059. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79060. *
  79061. * @param hitTestResult The hit test result to use for this anchor creation
  79062. * @param position an optional position offset for this anchor
  79063. * @param rotationQuaternion an optional rotation offset for this anchor
  79064. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79065. */
  79066. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<IWebXRAnchor>;
  79067. /**
  79068. * Add a new anchor at a specific position and rotation
  79069. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79070. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79071. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79072. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79073. *
  79074. * @param position the position in which to add an anchor
  79075. * @param rotationQuaternion an optional rotation for the anchor transformation
  79076. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79077. * @returns A promise that fulfills when babylon has created the corresponding WebXRAnchor object and tracking has begun
  79078. */
  79079. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<IWebXRAnchor>;
  79080. /**
  79081. * Get the list of anchors currently being tracked by the system
  79082. */
  79083. get anchors(): IWebXRAnchor[];
  79084. /**
  79085. * detach this feature.
  79086. * Will usually be called by the features manager
  79087. *
  79088. * @returns true if successful.
  79089. */
  79090. detach(): boolean;
  79091. /**
  79092. * Dispose this feature and all of the resources attached
  79093. */
  79094. dispose(): void;
  79095. protected _onXRFrame(frame: XRFrame): void;
  79096. /**
  79097. * avoiding using Array.find for global support.
  79098. * @param xrAnchor the plane to find in the array
  79099. */
  79100. private _findIndexInAnchorArray;
  79101. private _updateAnchorWithXRFrame;
  79102. private _createAnchorAtTransformation;
  79103. }
  79104. }
  79105. declare module BABYLON {
  79106. /**
  79107. * Options used in the plane detector module
  79108. */
  79109. export interface IWebXRPlaneDetectorOptions {
  79110. /**
  79111. * The node to use to transform the local results to world coordinates
  79112. */
  79113. worldParentNode?: TransformNode;
  79114. /**
  79115. * If set to true a reference of the created planes will be kept until the next session starts
  79116. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79117. */
  79118. doNotRemovePlanesOnSessionEnded?: boolean;
  79119. /**
  79120. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79121. */
  79122. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79123. }
  79124. /**
  79125. * A babylon interface for a WebXR plane.
  79126. * A Plane is actually a polygon, built from N points in space
  79127. *
  79128. * Supported in chrome 79, not supported in canary 81 ATM
  79129. */
  79130. export interface IWebXRPlane {
  79131. /**
  79132. * a babylon-assigned ID for this polygon
  79133. */
  79134. id: number;
  79135. /**
  79136. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79137. */
  79138. polygonDefinition: Array<Vector3>;
  79139. /**
  79140. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79141. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79142. */
  79143. transformationMatrix: Matrix;
  79144. /**
  79145. * the native xr-plane object
  79146. */
  79147. xrPlane: XRPlane;
  79148. }
  79149. /**
  79150. * The plane detector is used to detect planes in the real world when in AR
  79151. * For more information see https://github.com/immersive-web/real-world-geometry/
  79152. */
  79153. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79154. private _options;
  79155. private _detectedPlanes;
  79156. private _enabled;
  79157. private _lastFrameDetected;
  79158. /**
  79159. * The module's name
  79160. */
  79161. static readonly Name: string;
  79162. /**
  79163. * The (Babylon) version of this module.
  79164. * This is an integer representing the implementation version.
  79165. * This number does not correspond to the WebXR specs version
  79166. */
  79167. static readonly Version: number;
  79168. /**
  79169. * Observers registered here will be executed when a new plane was added to the session
  79170. */
  79171. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79172. /**
  79173. * Observers registered here will be executed when a plane is no longer detected in the session
  79174. */
  79175. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79176. /**
  79177. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79178. * This can execute N times every frame
  79179. */
  79180. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79181. /**
  79182. * construct a new Plane Detector
  79183. * @param _xrSessionManager an instance of xr Session manager
  79184. * @param _options configuration to use when constructing this feature
  79185. */
  79186. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79187. /**
  79188. * detach this feature.
  79189. * Will usually be called by the features manager
  79190. *
  79191. * @returns true if successful.
  79192. */
  79193. detach(): boolean;
  79194. /**
  79195. * Dispose this feature and all of the resources attached
  79196. */
  79197. dispose(): void;
  79198. /**
  79199. * Check if the needed objects are defined.
  79200. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79201. */
  79202. isCompatible(): boolean;
  79203. protected _onXRFrame(frame: XRFrame): void;
  79204. private _init;
  79205. private _updatePlaneWithXRPlane;
  79206. /**
  79207. * avoiding using Array.find for global support.
  79208. * @param xrPlane the plane to find in the array
  79209. */
  79210. private _findIndexInPlaneArray;
  79211. }
  79212. }
  79213. declare module BABYLON {
  79214. /**
  79215. * Options interface for the background remover plugin
  79216. */
  79217. export interface IWebXRBackgroundRemoverOptions {
  79218. /**
  79219. * Further background meshes to disable when entering AR
  79220. */
  79221. backgroundMeshes?: AbstractMesh[];
  79222. /**
  79223. * flags to configure the removal of the environment helper.
  79224. * If not set, the entire background will be removed. If set, flags should be set as well.
  79225. */
  79226. environmentHelperRemovalFlags?: {
  79227. /**
  79228. * Should the skybox be removed (default false)
  79229. */
  79230. skyBox?: boolean;
  79231. /**
  79232. * Should the ground be removed (default false)
  79233. */
  79234. ground?: boolean;
  79235. };
  79236. /**
  79237. * don't disable the environment helper
  79238. */
  79239. ignoreEnvironmentHelper?: boolean;
  79240. }
  79241. /**
  79242. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79243. */
  79244. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79245. /**
  79246. * read-only options to be used in this module
  79247. */
  79248. readonly options: IWebXRBackgroundRemoverOptions;
  79249. /**
  79250. * The module's name
  79251. */
  79252. static readonly Name: string;
  79253. /**
  79254. * The (Babylon) version of this module.
  79255. * This is an integer representing the implementation version.
  79256. * This number does not correspond to the WebXR specs version
  79257. */
  79258. static readonly Version: number;
  79259. /**
  79260. * registered observers will be triggered when the background state changes
  79261. */
  79262. onBackgroundStateChangedObservable: Observable<boolean>;
  79263. /**
  79264. * constructs a new background remover module
  79265. * @param _xrSessionManager the session manager for this module
  79266. * @param options read-only options to be used in this module
  79267. */
  79268. constructor(_xrSessionManager: WebXRSessionManager,
  79269. /**
  79270. * read-only options to be used in this module
  79271. */
  79272. options?: IWebXRBackgroundRemoverOptions);
  79273. /**
  79274. * attach this feature
  79275. * Will usually be called by the features manager
  79276. *
  79277. * @returns true if successful.
  79278. */
  79279. attach(): boolean;
  79280. /**
  79281. * detach this feature.
  79282. * Will usually be called by the features manager
  79283. *
  79284. * @returns true if successful.
  79285. */
  79286. detach(): boolean;
  79287. /**
  79288. * Dispose this feature and all of the resources attached
  79289. */
  79290. dispose(): void;
  79291. protected _onXRFrame(_xrFrame: XRFrame): void;
  79292. private _setBackgroundState;
  79293. }
  79294. }
  79295. declare module BABYLON {
  79296. /**
  79297. * Options for the controller physics feature
  79298. */
  79299. export class IWebXRControllerPhysicsOptions {
  79300. /**
  79301. * Should the headset get its own impostor
  79302. */
  79303. enableHeadsetImpostor?: boolean;
  79304. /**
  79305. * Optional parameters for the headset impostor
  79306. */
  79307. headsetImpostorParams?: {
  79308. /**
  79309. * The type of impostor to create. Default is sphere
  79310. */
  79311. impostorType: number;
  79312. /**
  79313. * the size of the impostor. Defaults to 10cm
  79314. */
  79315. impostorSize?: number | {
  79316. width: number;
  79317. height: number;
  79318. depth: number;
  79319. };
  79320. /**
  79321. * Friction definitions
  79322. */
  79323. friction?: number;
  79324. /**
  79325. * Restitution
  79326. */
  79327. restitution?: number;
  79328. };
  79329. /**
  79330. * The physics properties of the future impostors
  79331. */
  79332. physicsProperties?: {
  79333. /**
  79334. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79335. * Note that this requires a physics engine that supports mesh impostors!
  79336. */
  79337. useControllerMesh?: boolean;
  79338. /**
  79339. * The type of impostor to create. Default is sphere
  79340. */
  79341. impostorType?: number;
  79342. /**
  79343. * the size of the impostor. Defaults to 10cm
  79344. */
  79345. impostorSize?: number | {
  79346. width: number;
  79347. height: number;
  79348. depth: number;
  79349. };
  79350. /**
  79351. * Friction definitions
  79352. */
  79353. friction?: number;
  79354. /**
  79355. * Restitution
  79356. */
  79357. restitution?: number;
  79358. };
  79359. /**
  79360. * the xr input to use with this pointer selection
  79361. */
  79362. xrInput: WebXRInput;
  79363. }
  79364. /**
  79365. * Add physics impostor to your webxr controllers,
  79366. * including naive calculation of their linear and angular velocity
  79367. */
  79368. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79369. private readonly _options;
  79370. private _attachController;
  79371. private _controllers;
  79372. private _debugMode;
  79373. private _delta;
  79374. private _headsetImpostor?;
  79375. private _headsetMesh?;
  79376. private _lastTimestamp;
  79377. private _tmpQuaternion;
  79378. private _tmpVector;
  79379. /**
  79380. * The module's name
  79381. */
  79382. static readonly Name: string;
  79383. /**
  79384. * The (Babylon) version of this module.
  79385. * This is an integer representing the implementation version.
  79386. * This number does not correspond to the webxr specs version
  79387. */
  79388. static readonly Version: number;
  79389. /**
  79390. * Construct a new Controller Physics Feature
  79391. * @param _xrSessionManager the corresponding xr session manager
  79392. * @param _options options to create this feature with
  79393. */
  79394. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79395. /**
  79396. * @hidden
  79397. * enable debugging - will show console outputs and the impostor mesh
  79398. */
  79399. _enablePhysicsDebug(): void;
  79400. /**
  79401. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79402. * @param xrController the controller to add
  79403. */
  79404. addController(xrController: WebXRInputSource): void;
  79405. /**
  79406. * attach this feature
  79407. * Will usually be called by the features manager
  79408. *
  79409. * @returns true if successful.
  79410. */
  79411. attach(): boolean;
  79412. /**
  79413. * detach this feature.
  79414. * Will usually be called by the features manager
  79415. *
  79416. * @returns true if successful.
  79417. */
  79418. detach(): boolean;
  79419. /**
  79420. * Get the headset impostor, if enabled
  79421. * @returns the impostor
  79422. */
  79423. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79424. /**
  79425. * Get the physics impostor of a specific controller.
  79426. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79427. * @param controller the controller or the controller id of which to get the impostor
  79428. * @returns the impostor or null
  79429. */
  79430. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79431. /**
  79432. * Update the physics properties provided in the constructor
  79433. * @param newProperties the new properties object
  79434. */
  79435. setPhysicsProperties(newProperties: {
  79436. impostorType?: number;
  79437. impostorSize?: number | {
  79438. width: number;
  79439. height: number;
  79440. depth: number;
  79441. };
  79442. friction?: number;
  79443. restitution?: number;
  79444. }): void;
  79445. protected _onXRFrame(_xrFrame: any): void;
  79446. private _detachController;
  79447. }
  79448. }
  79449. declare module BABYLON {
  79450. /**
  79451. * A babylon interface for a "WebXR" feature point.
  79452. * Represents the position and confidence value of a given feature point.
  79453. */
  79454. export interface IWebXRFeaturePoint {
  79455. /**
  79456. * Represents the position of the feature point in world space.
  79457. */
  79458. position: Vector3;
  79459. /**
  79460. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79461. */
  79462. confidenceValue: number;
  79463. }
  79464. /**
  79465. * The feature point system is used to detect feature points from real world geometry.
  79466. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79467. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79468. */
  79469. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79470. private _enabled;
  79471. private _featurePointCloud;
  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. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79484. * Will notify the observers about which feature points have been added.
  79485. */
  79486. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79487. /**
  79488. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79489. * Will notify the observers about which feature points have been updated.
  79490. */
  79491. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79492. /**
  79493. * The current feature point cloud maintained across frames.
  79494. */
  79495. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79496. /**
  79497. * construct the feature point system
  79498. * @param _xrSessionManager an instance of xr Session manager
  79499. */
  79500. constructor(_xrSessionManager: WebXRSessionManager);
  79501. /**
  79502. * Detach this feature.
  79503. * Will usually be called by the features manager
  79504. *
  79505. * @returns true if successful.
  79506. */
  79507. detach(): boolean;
  79508. /**
  79509. * Dispose this feature and all of the resources attached
  79510. */
  79511. dispose(): void;
  79512. /**
  79513. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79514. */
  79515. protected _onXRFrame(frame: XRFrame): void;
  79516. /**
  79517. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79518. */
  79519. private _init;
  79520. }
  79521. }
  79522. declare module BABYLON {
  79523. /**
  79524. * Configuration interface for the hand tracking feature
  79525. */
  79526. export interface IWebXRHandTrackingOptions {
  79527. /**
  79528. * The xrInput that will be used as source for new hands
  79529. */
  79530. xrInput: WebXRInput;
  79531. /**
  79532. * Configuration object for the joint meshes
  79533. */
  79534. jointMeshes?: {
  79535. /**
  79536. * Should the meshes created be invisible (defaults to false)
  79537. */
  79538. invisible?: boolean;
  79539. /**
  79540. * A source mesh to be used to create instances. Defaults to a sphere.
  79541. * This mesh will be the source for all other (25) meshes.
  79542. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79543. */
  79544. sourceMesh?: Mesh;
  79545. /**
  79546. * This function will be called after a mesh was created for a specific joint.
  79547. * Using this function you can either manipulate the instance or return a new mesh.
  79548. * When returning a new mesh the instance created before will be disposed
  79549. */
  79550. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  79551. /**
  79552. * Should the source mesh stay visible. Defaults to false
  79553. */
  79554. keepOriginalVisible?: boolean;
  79555. /**
  79556. * Scale factor for all instances (defaults to 2)
  79557. */
  79558. scaleFactor?: number;
  79559. /**
  79560. * Should each instance have its own physics impostor
  79561. */
  79562. enablePhysics?: boolean;
  79563. /**
  79564. * If enabled, override default physics properties
  79565. */
  79566. physicsProps?: {
  79567. friction?: number;
  79568. restitution?: number;
  79569. impostorType?: number;
  79570. };
  79571. /**
  79572. * Should the default hand mesh be disabled. In this case, the spheres will be visible (unless set invisible).
  79573. */
  79574. disableDefaultHandMesh?: boolean;
  79575. /**
  79576. * a rigged hand-mesh that will be updated according to the XRHand data provided. This will override the default hand mesh
  79577. */
  79578. handMeshes?: {
  79579. right: AbstractMesh;
  79580. left: AbstractMesh;
  79581. };
  79582. /**
  79583. * If a hand mesh was provided, this array will define what axis will update which node. This will override the default hand mesh
  79584. */
  79585. rigMapping?: {
  79586. right: string[];
  79587. left: string[];
  79588. };
  79589. };
  79590. }
  79591. /**
  79592. * Parts of the hands divided to writs and finger names
  79593. */
  79594. export const enum HandPart {
  79595. /**
  79596. * HandPart - Wrist
  79597. */
  79598. WRIST = "wrist",
  79599. /**
  79600. * HandPart - The THumb
  79601. */
  79602. THUMB = "thumb",
  79603. /**
  79604. * HandPart - Index finger
  79605. */
  79606. INDEX = "index",
  79607. /**
  79608. * HandPart - Middle finger
  79609. */
  79610. MIDDLE = "middle",
  79611. /**
  79612. * HandPart - Ring finger
  79613. */
  79614. RING = "ring",
  79615. /**
  79616. * HandPart - Little finger
  79617. */
  79618. LITTLE = "little"
  79619. }
  79620. /**
  79621. * Representing a single hand (with its corresponding native XRHand object)
  79622. */
  79623. export class WebXRHand implements IDisposable {
  79624. /** the controller to which the hand correlates */
  79625. readonly xrController: WebXRInputSource;
  79626. /** the meshes to be used to track the hand joints */
  79627. readonly trackedMeshes: AbstractMesh[];
  79628. private _handMesh?;
  79629. private _rigMapping?;
  79630. private _scene;
  79631. private _defaultHandMesh;
  79632. private _transformNodeMapping;
  79633. /**
  79634. * Hand-parts definition (key is HandPart)
  79635. */
  79636. handPartsDefinition: {
  79637. [key: string]: number[];
  79638. };
  79639. /**
  79640. * Observers will be triggered when the mesh for this hand was initialized.
  79641. */
  79642. onHandMeshReadyObservable: Observable<WebXRHand>;
  79643. /**
  79644. * Populate the HandPartsDefinition object.
  79645. * This is called as a side effect since certain browsers don't have XRHand defined.
  79646. */
  79647. private generateHandPartsDefinition;
  79648. /**
  79649. * Construct a new hand object
  79650. * @param xrController the controller to which the hand correlates
  79651. * @param trackedMeshes the meshes to be used to track the hand joints
  79652. * @param _handMesh an optional hand mesh. if not provided, ours will be used
  79653. * @param _rigMapping an optional rig mapping for the hand mesh. if not provided, ours will be used
  79654. * @param disableDefaultHandMesh should the default mesh creation be disabled
  79655. */
  79656. constructor(
  79657. /** the controller to which the hand correlates */
  79658. xrController: WebXRInputSource,
  79659. /** the meshes to be used to track the hand joints */
  79660. trackedMeshes: AbstractMesh[], _handMesh?: AbstractMesh | undefined, _rigMapping?: string[] | undefined, disableDefaultHandMesh?: boolean);
  79661. /**
  79662. * Get the hand mesh. It is possible that the hand mesh is not yet ready!
  79663. */
  79664. get handMesh(): AbstractMesh | undefined;
  79665. /**
  79666. * Update this hand from the latest xr frame
  79667. * @param xrFrame xrFrame to update from
  79668. * @param referenceSpace The current viewer reference space
  79669. * @param scaleFactor optional scale factor for the meshes
  79670. */
  79671. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79672. /**
  79673. * Get meshes of part of the hand
  79674. * @param part the part of hand to get
  79675. * @returns An array of meshes that correlate to the hand part requested
  79676. */
  79677. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79678. /**
  79679. * Dispose this Hand object
  79680. */
  79681. dispose(): void;
  79682. private _generateDefaultHandMesh;
  79683. }
  79684. /**
  79685. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79686. */
  79687. export class WebXRHandTracking extends WebXRAbstractFeature {
  79688. /**
  79689. * options to use when constructing this feature
  79690. */
  79691. readonly options: IWebXRHandTrackingOptions;
  79692. private static _idCounter;
  79693. /**
  79694. * The module's name
  79695. */
  79696. static readonly Name: string;
  79697. /**
  79698. * The (Babylon) version of this module.
  79699. * This is an integer representing the implementation version.
  79700. * This number does not correspond to the WebXR specs version
  79701. */
  79702. static readonly Version: number;
  79703. /**
  79704. * This observable will notify registered observers when a new hand object was added and initialized
  79705. */
  79706. onHandAddedObservable: Observable<WebXRHand>;
  79707. /**
  79708. * This observable will notify its observers right before the hand object is disposed
  79709. */
  79710. onHandRemovedObservable: Observable<WebXRHand>;
  79711. private _hands;
  79712. /**
  79713. * Creates a new instance of the hit test feature
  79714. * @param _xrSessionManager an instance of WebXRSessionManager
  79715. * @param options options to use when constructing this feature
  79716. */
  79717. constructor(_xrSessionManager: WebXRSessionManager,
  79718. /**
  79719. * options to use when constructing this feature
  79720. */
  79721. options: IWebXRHandTrackingOptions);
  79722. /**
  79723. * Check if the needed objects are defined.
  79724. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79725. */
  79726. isCompatible(): boolean;
  79727. /**
  79728. * attach this feature
  79729. * Will usually be called by the features manager
  79730. *
  79731. * @returns true if successful.
  79732. */
  79733. attach(): boolean;
  79734. /**
  79735. * detach this feature.
  79736. * Will usually be called by the features manager
  79737. *
  79738. * @returns true if successful.
  79739. */
  79740. detach(): boolean;
  79741. /**
  79742. * Dispose this feature and all of the resources attached
  79743. */
  79744. dispose(): void;
  79745. /**
  79746. * Get the hand object according to the controller id
  79747. * @param controllerId the controller id to which we want to get the hand
  79748. * @returns null if not found or the WebXRHand object if found
  79749. */
  79750. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79751. /**
  79752. * Get a hand object according to the requested handedness
  79753. * @param handedness the handedness to request
  79754. * @returns null if not found or the WebXRHand object if found
  79755. */
  79756. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79757. protected _onXRFrame(_xrFrame: XRFrame): void;
  79758. private _attachHand;
  79759. private _detachHand;
  79760. }
  79761. }
  79762. declare module BABYLON {
  79763. /**
  79764. * Options used in the mesh detector module
  79765. */
  79766. export interface IWebXRMeshDetectorOptions {
  79767. /**
  79768. * The node to use to transform the local results to world coordinates
  79769. */
  79770. worldParentNode?: TransformNode;
  79771. /**
  79772. * If set to true a reference of the created meshes will be kept until the next session starts
  79773. * If not defined, meshes will be removed from the array when the feature is detached or the session ended.
  79774. */
  79775. doNotRemoveMeshesOnSessionEnded?: boolean;
  79776. /**
  79777. * Preferred detector configuration, not all preferred options will be supported by all platforms.
  79778. */
  79779. preferredDetectorOptions?: XRGeometryDetectorOptions;
  79780. /**
  79781. * If set to true, WebXRMeshDetector will convert coordinate systems for meshes.
  79782. * If not defined, mesh conversions from right handed to left handed coordinate systems won't be conducted.
  79783. * Right handed mesh data will be available through IWebXRVertexData.xrMesh.
  79784. */
  79785. convertCoordinateSystems?: boolean;
  79786. }
  79787. /**
  79788. * A babylon interface for a XR mesh's vertex data.
  79789. *
  79790. * Currently not supported by WebXR, available only with BabylonNative
  79791. */
  79792. export interface IWebXRVertexData {
  79793. /**
  79794. * A babylon-assigned ID for this mesh
  79795. */
  79796. id: number;
  79797. /**
  79798. * Data required for constructing a mesh in Babylon.js.
  79799. */
  79800. xrMesh: XRMesh;
  79801. /**
  79802. * The node to use to transform the local results to world coordinates.
  79803. * WorldParentNode will only exist if it was declared in the IWebXRMeshDetectorOptions.
  79804. */
  79805. worldParentNode?: TransformNode;
  79806. /**
  79807. * An array of vertex positions in babylon space. right/left hand system is taken into account.
  79808. * Positions will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79809. */
  79810. positions?: Float32Array;
  79811. /**
  79812. * An array of indices in babylon space. right/left hand system is taken into account.
  79813. * Indices will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79814. */
  79815. indices?: Uint32Array;
  79816. /**
  79817. * An array of vertex normals in babylon space. right/left hand system is taken into account.
  79818. * Normals will not be calculated if convertCoordinateSystems is undefined in the IWebXRMeshDetectorOptions.
  79819. * Different platforms may or may not support mesh normals when convertCoordinateSystems is set to true.
  79820. */
  79821. normals?: Float32Array;
  79822. /**
  79823. * A transformation matrix to apply on the mesh that will be built using the meshDefinition.
  79824. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module.
  79825. * TransformationMatrix will only be calculated if convertCoordinateSystems is set to true in the IWebXRMeshDetectorOptions.
  79826. */
  79827. transformationMatrix?: Matrix;
  79828. }
  79829. /**
  79830. * The mesh detector is used to detect meshes in the real world when in AR
  79831. */
  79832. export class WebXRMeshDetector extends WebXRAbstractFeature {
  79833. private _options;
  79834. private _detectedMeshes;
  79835. /**
  79836. * The module's name
  79837. */
  79838. static readonly Name: string;
  79839. /**
  79840. * The (Babylon) version of this module.
  79841. * This is an integer representing the implementation version.
  79842. * This number does not correspond to the WebXR specs version
  79843. */
  79844. static readonly Version: number;
  79845. /**
  79846. * Observers registered here will be executed when a new mesh was added to the session
  79847. */
  79848. onMeshAddedObservable: Observable<IWebXRVertexData>;
  79849. /**
  79850. * Observers registered here will be executed when a mesh is no longer detected in the session
  79851. */
  79852. onMeshRemovedObservable: Observable<IWebXRVertexData>;
  79853. /**
  79854. * Observers registered here will be executed when an existing mesh updates
  79855. */
  79856. onMeshUpdatedObservable: Observable<IWebXRVertexData>;
  79857. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRMeshDetectorOptions);
  79858. detach(): boolean;
  79859. dispose(): void;
  79860. protected _onXRFrame(frame: XRFrame): void;
  79861. private _init;
  79862. private _updateVertexDataWithXRMesh;
  79863. }
  79864. }
  79865. declare module BABYLON {
  79866. /**
  79867. * Options interface for the background remover plugin
  79868. */
  79869. export interface IWebXRImageTrackingOptions {
  79870. /**
  79871. * A required array with images to track
  79872. */
  79873. images: {
  79874. /**
  79875. * The source of the image. can be a URL or an image bitmap
  79876. */
  79877. src: string | ImageBitmap;
  79878. /**
  79879. * The estimated width in the real world (in meters)
  79880. */
  79881. estimatedRealWorldWidth: number;
  79882. }[];
  79883. }
  79884. /**
  79885. * An object representing an image tracked by the system
  79886. */
  79887. export interface IWebXRTrackedImage {
  79888. /**
  79889. * The ID of this image (which is the same as the position in the array that was used to initialize the feature)
  79890. */
  79891. id: number;
  79892. /**
  79893. * Is the transformation provided emulated. If it is, the system "guesses" its real position. Otherwise it can be considered as exact position.
  79894. */
  79895. emulated?: boolean;
  79896. /**
  79897. * Just in case it is needed - the image bitmap that is being tracked
  79898. */
  79899. originalBitmap: ImageBitmap;
  79900. /**
  79901. * The native XR result image tracking result, untouched
  79902. */
  79903. xrTrackingResult?: XRImageTrackingResult;
  79904. /**
  79905. * Width in real world (meters)
  79906. */
  79907. realWorldWidth?: number;
  79908. /**
  79909. * A transformation matrix of this current image in the current reference space.
  79910. */
  79911. transformationMatrix: Matrix;
  79912. /**
  79913. * The width/height ratio of this image. can be used to calculate the size of the detected object/image
  79914. */
  79915. ratio?: number;
  79916. }
  79917. /**
  79918. * Image tracking for immersive AR sessions.
  79919. * Providing a list of images and their estimated widths will enable tracking those images in the real world.
  79920. */
  79921. export class WebXRImageTracking extends WebXRAbstractFeature {
  79922. /**
  79923. * read-only options to be used in this module
  79924. */
  79925. readonly options: IWebXRImageTrackingOptions;
  79926. /**
  79927. * The module's name
  79928. */
  79929. static readonly Name: string;
  79930. /**
  79931. * The (Babylon) version of this module.
  79932. * This is an integer representing the implementation version.
  79933. * This number does not correspond to the WebXR specs version
  79934. */
  79935. static readonly Version: number;
  79936. /**
  79937. * This will be triggered if the underlying system deems an image untrackable.
  79938. * The index is the index of the image from the array used to initialize the feature.
  79939. */
  79940. onUntrackableImageFoundObservable: Observable<number>;
  79941. /**
  79942. * An image was deemed trackable, and the system will start tracking it.
  79943. */
  79944. onTrackableImageFoundObservable: Observable<IWebXRTrackedImage>;
  79945. /**
  79946. * The image was found and its state was updated.
  79947. */
  79948. onTrackedImageUpdatedObservable: Observable<IWebXRTrackedImage>;
  79949. private _trackedImages;
  79950. private _originalTrackingRequest;
  79951. /**
  79952. * constructs the image tracking feature
  79953. * @param _xrSessionManager the session manager for this module
  79954. * @param options read-only options to be used in this module
  79955. */
  79956. constructor(_xrSessionManager: WebXRSessionManager,
  79957. /**
  79958. * read-only options to be used in this module
  79959. */
  79960. options: IWebXRImageTrackingOptions);
  79961. /**
  79962. * attach this feature
  79963. * Will usually be called by the features manager
  79964. *
  79965. * @returns true if successful.
  79966. */
  79967. attach(): boolean;
  79968. /**
  79969. * detach this feature.
  79970. * Will usually be called by the features manager
  79971. *
  79972. * @returns true if successful.
  79973. */
  79974. detach(): boolean;
  79975. /**
  79976. * Check if the needed objects are defined.
  79977. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79978. */
  79979. isCompatible(): boolean;
  79980. /**
  79981. * Get a tracked image by its ID.
  79982. *
  79983. * @param id the id of the image to load (position in the init array)
  79984. * @returns a trackable image, if exists in this location
  79985. */
  79986. getTrackedImageById(id: number): Nullable<IWebXRTrackedImage>;
  79987. /**
  79988. * Dispose this feature and all of the resources attached
  79989. */
  79990. dispose(): void;
  79991. /**
  79992. * Extends the session init object if needed
  79993. * @returns augmentation object fo the xr session init object.
  79994. */
  79995. getXRSessionInitExtension(): Promise<Partial<XRSessionInit>>;
  79996. protected _onXRFrame(_xrFrame: XRFrame): void;
  79997. private _init;
  79998. }
  79999. }
  80000. declare module BABYLON {
  80001. /**
  80002. * The motion controller class for all microsoft mixed reality controllers
  80003. */
  80004. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80005. protected readonly _mapping: {
  80006. defaultButton: {
  80007. valueNodeName: string;
  80008. unpressedNodeName: string;
  80009. pressedNodeName: string;
  80010. };
  80011. defaultAxis: {
  80012. valueNodeName: string;
  80013. minNodeName: string;
  80014. maxNodeName: string;
  80015. };
  80016. buttons: {
  80017. "xr-standard-trigger": {
  80018. rootNodeName: string;
  80019. componentProperty: string;
  80020. states: string[];
  80021. };
  80022. "xr-standard-squeeze": {
  80023. rootNodeName: string;
  80024. componentProperty: string;
  80025. states: string[];
  80026. };
  80027. "xr-standard-touchpad": {
  80028. rootNodeName: string;
  80029. labelAnchorNodeName: string;
  80030. touchPointNodeName: string;
  80031. };
  80032. "xr-standard-thumbstick": {
  80033. rootNodeName: string;
  80034. componentProperty: string;
  80035. states: string[];
  80036. };
  80037. };
  80038. axes: {
  80039. "xr-standard-touchpad": {
  80040. "x-axis": {
  80041. rootNodeName: string;
  80042. };
  80043. "y-axis": {
  80044. rootNodeName: string;
  80045. };
  80046. };
  80047. "xr-standard-thumbstick": {
  80048. "x-axis": {
  80049. rootNodeName: string;
  80050. };
  80051. "y-axis": {
  80052. rootNodeName: string;
  80053. };
  80054. };
  80055. };
  80056. };
  80057. /**
  80058. * The base url used to load the left and right controller models
  80059. */
  80060. static MODEL_BASE_URL: string;
  80061. /**
  80062. * The name of the left controller model file
  80063. */
  80064. static MODEL_LEFT_FILENAME: string;
  80065. /**
  80066. * The name of the right controller model file
  80067. */
  80068. static MODEL_RIGHT_FILENAME: string;
  80069. profileId: string;
  80070. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80071. protected _getFilenameAndPath(): {
  80072. filename: string;
  80073. path: string;
  80074. };
  80075. protected _getModelLoadingConstraints(): boolean;
  80076. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80077. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80078. protected _updateModel(): void;
  80079. }
  80080. }
  80081. declare module BABYLON {
  80082. /**
  80083. * The motion controller class for oculus touch (quest, rift).
  80084. * This class supports legacy mapping as well the standard xr mapping
  80085. */
  80086. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80087. private _forceLegacyControllers;
  80088. private _modelRootNode;
  80089. /**
  80090. * The base url used to load the left and right controller models
  80091. */
  80092. static MODEL_BASE_URL: string;
  80093. /**
  80094. * The name of the left controller model file
  80095. */
  80096. static MODEL_LEFT_FILENAME: string;
  80097. /**
  80098. * The name of the right controller model file
  80099. */
  80100. static MODEL_RIGHT_FILENAME: string;
  80101. /**
  80102. * Base Url for the Quest controller model.
  80103. */
  80104. static QUEST_MODEL_BASE_URL: string;
  80105. profileId: string;
  80106. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80107. protected _getFilenameAndPath(): {
  80108. filename: string;
  80109. path: string;
  80110. };
  80111. protected _getModelLoadingConstraints(): boolean;
  80112. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80113. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80114. protected _updateModel(): void;
  80115. /**
  80116. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80117. * between the touch and touch 2.
  80118. */
  80119. private _isQuest;
  80120. }
  80121. }
  80122. declare module BABYLON {
  80123. /**
  80124. * The motion controller class for the standard HTC-Vive controllers
  80125. */
  80126. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80127. private _modelRootNode;
  80128. /**
  80129. * The base url used to load the left and right controller models
  80130. */
  80131. static MODEL_BASE_URL: string;
  80132. /**
  80133. * File name for the controller model.
  80134. */
  80135. static MODEL_FILENAME: string;
  80136. profileId: string;
  80137. /**
  80138. * Create a new Vive motion controller object
  80139. * @param scene the scene to use to create this controller
  80140. * @param gamepadObject the corresponding gamepad object
  80141. * @param handedness the handedness of the controller
  80142. */
  80143. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80144. protected _getFilenameAndPath(): {
  80145. filename: string;
  80146. path: string;
  80147. };
  80148. protected _getModelLoadingConstraints(): boolean;
  80149. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80150. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80151. protected _updateModel(): void;
  80152. }
  80153. }
  80154. declare module BABYLON {
  80155. /**
  80156. * A cursor which tracks a point on a path
  80157. */
  80158. export class PathCursor {
  80159. private path;
  80160. /**
  80161. * Stores path cursor callbacks for when an onchange event is triggered
  80162. */
  80163. private _onchange;
  80164. /**
  80165. * The value of the path cursor
  80166. */
  80167. value: number;
  80168. /**
  80169. * The animation array of the path cursor
  80170. */
  80171. animations: Animation[];
  80172. /**
  80173. * Initializes the path cursor
  80174. * @param path The path to track
  80175. */
  80176. constructor(path: Path2);
  80177. /**
  80178. * Gets the cursor point on the path
  80179. * @returns A point on the path cursor at the cursor location
  80180. */
  80181. getPoint(): Vector3;
  80182. /**
  80183. * Moves the cursor ahead by the step amount
  80184. * @param step The amount to move the cursor forward
  80185. * @returns This path cursor
  80186. */
  80187. moveAhead(step?: number): PathCursor;
  80188. /**
  80189. * Moves the cursor behind by the step amount
  80190. * @param step The amount to move the cursor back
  80191. * @returns This path cursor
  80192. */
  80193. moveBack(step?: number): PathCursor;
  80194. /**
  80195. * Moves the cursor by the step amount
  80196. * If the step amount is greater than one, an exception is thrown
  80197. * @param step The amount to move the cursor
  80198. * @returns This path cursor
  80199. */
  80200. move(step: number): PathCursor;
  80201. /**
  80202. * Ensures that the value is limited between zero and one
  80203. * @returns This path cursor
  80204. */
  80205. private ensureLimits;
  80206. /**
  80207. * Runs onchange callbacks on change (used by the animation engine)
  80208. * @returns This path cursor
  80209. */
  80210. private raiseOnChange;
  80211. /**
  80212. * Executes a function on change
  80213. * @param f A path cursor onchange callback
  80214. * @returns This path cursor
  80215. */
  80216. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80217. }
  80218. }
  80219. declare module BABYLON {
  80220. /** @hidden */
  80221. export var blurPixelShader: {
  80222. name: string;
  80223. shader: string;
  80224. };
  80225. }
  80226. declare module BABYLON {
  80227. /** @hidden */
  80228. export var pointCloudVertexDeclaration: {
  80229. name: string;
  80230. shader: string;
  80231. };
  80232. }
  80233. // Mixins
  80234. interface Window {
  80235. mozIndexedDB: IDBFactory;
  80236. webkitIndexedDB: IDBFactory;
  80237. msIndexedDB: IDBFactory;
  80238. webkitURL: typeof URL;
  80239. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  80240. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  80241. WebGLRenderingContext: WebGLRenderingContext;
  80242. MSGesture: MSGesture;
  80243. CANNON: any;
  80244. AudioContext: AudioContext;
  80245. webkitAudioContext: AudioContext;
  80246. PointerEvent: any;
  80247. Math: Math;
  80248. Uint8Array: Uint8ArrayConstructor;
  80249. Float32Array: Float32ArrayConstructor;
  80250. mozURL: typeof URL;
  80251. msURL: typeof URL;
  80252. VRFrameData: any; // WebVR, from specs 1.1
  80253. DracoDecoderModule: any;
  80254. setImmediate(handler: (...args: any[]) => void): number;
  80255. }
  80256. interface HTMLCanvasElement {
  80257. requestPointerLock(): void;
  80258. msRequestPointerLock?(): void;
  80259. mozRequestPointerLock?(): void;
  80260. webkitRequestPointerLock?(): void;
  80261. /** Track wether a record is in progress */
  80262. isRecording: boolean;
  80263. /** Capture Stream method defined by some browsers */
  80264. captureStream(fps?: number): MediaStream;
  80265. }
  80266. interface CanvasRenderingContext2D {
  80267. msImageSmoothingEnabled: boolean;
  80268. }
  80269. interface MouseEvent {
  80270. mozMovementX: number;
  80271. mozMovementY: number;
  80272. webkitMovementX: number;
  80273. webkitMovementY: number;
  80274. msMovementX: number;
  80275. msMovementY: number;
  80276. }
  80277. interface Navigator {
  80278. mozGetVRDevices: (any: any) => any;
  80279. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80280. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80281. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  80282. webkitGetGamepads(): Gamepad[];
  80283. msGetGamepads(): Gamepad[];
  80284. webkitGamepads(): Gamepad[];
  80285. }
  80286. interface HTMLVideoElement {
  80287. mozSrcObject: any;
  80288. }
  80289. interface Math {
  80290. fround(x: number): number;
  80291. imul(a: number, b: number): number;
  80292. log2(x: number): number;
  80293. }
  80294. interface WebGLRenderingContext {
  80295. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  80296. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  80297. vertexAttribDivisor(index: number, divisor: number): void;
  80298. createVertexArray(): any;
  80299. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  80300. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  80301. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  80302. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  80303. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  80304. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  80305. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  80306. // Queries
  80307. createQuery(): WebGLQuery;
  80308. deleteQuery(query: WebGLQuery): void;
  80309. beginQuery(target: number, query: WebGLQuery): void;
  80310. endQuery(target: number): void;
  80311. getQueryParameter(query: WebGLQuery, pname: number): any;
  80312. getQuery(target: number, pname: number): any;
  80313. MAX_SAMPLES: number;
  80314. RGBA8: number;
  80315. READ_FRAMEBUFFER: number;
  80316. DRAW_FRAMEBUFFER: number;
  80317. UNIFORM_BUFFER: number;
  80318. HALF_FLOAT_OES: number;
  80319. RGBA16F: number;
  80320. RGBA32F: number;
  80321. R32F: number;
  80322. RG32F: number;
  80323. RGB32F: number;
  80324. R16F: number;
  80325. RG16F: number;
  80326. RGB16F: number;
  80327. RED: number;
  80328. RG: number;
  80329. R8: number;
  80330. RG8: number;
  80331. UNSIGNED_INT_24_8: number;
  80332. DEPTH24_STENCIL8: number;
  80333. MIN: number;
  80334. MAX: number;
  80335. /* Multiple Render Targets */
  80336. drawBuffers(buffers: number[]): void;
  80337. readBuffer(src: number): void;
  80338. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  80339. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  80340. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  80341. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  80342. // Occlusion Query
  80343. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  80344. ANY_SAMPLES_PASSED: number;
  80345. QUERY_RESULT_AVAILABLE: number;
  80346. QUERY_RESULT: number;
  80347. }
  80348. interface WebGLProgram {
  80349. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  80350. }
  80351. interface EXT_disjoint_timer_query {
  80352. QUERY_COUNTER_BITS_EXT: number;
  80353. TIME_ELAPSED_EXT: number;
  80354. TIMESTAMP_EXT: number;
  80355. GPU_DISJOINT_EXT: number;
  80356. QUERY_RESULT_EXT: number;
  80357. QUERY_RESULT_AVAILABLE_EXT: number;
  80358. queryCounterEXT(query: WebGLQuery, target: number): void;
  80359. createQueryEXT(): WebGLQuery;
  80360. beginQueryEXT(target: number, query: WebGLQuery): void;
  80361. endQueryEXT(target: number): void;
  80362. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  80363. deleteQueryEXT(query: WebGLQuery): void;
  80364. }
  80365. interface WebGLUniformLocation {
  80366. _currentState: any;
  80367. }
  80368. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  80369. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  80370. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  80371. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  80372. interface WebGLRenderingContext {
  80373. readonly RASTERIZER_DISCARD: number;
  80374. readonly DEPTH_COMPONENT24: number;
  80375. readonly TEXTURE_3D: number;
  80376. readonly TEXTURE_2D_ARRAY: number;
  80377. readonly TEXTURE_COMPARE_FUNC: number;
  80378. readonly TEXTURE_COMPARE_MODE: number;
  80379. readonly COMPARE_REF_TO_TEXTURE: number;
  80380. readonly TEXTURE_WRAP_R: number;
  80381. readonly HALF_FLOAT: number;
  80382. readonly RGB8: number;
  80383. readonly RED_INTEGER: number;
  80384. readonly RG_INTEGER: number;
  80385. readonly RGB_INTEGER: number;
  80386. readonly RGBA_INTEGER: number;
  80387. readonly R8_SNORM: number;
  80388. readonly RG8_SNORM: number;
  80389. readonly RGB8_SNORM: number;
  80390. readonly RGBA8_SNORM: number;
  80391. readonly R8I: number;
  80392. readonly RG8I: number;
  80393. readonly RGB8I: number;
  80394. readonly RGBA8I: number;
  80395. readonly R8UI: number;
  80396. readonly RG8UI: number;
  80397. readonly RGB8UI: number;
  80398. readonly RGBA8UI: number;
  80399. readonly R16I: number;
  80400. readonly RG16I: number;
  80401. readonly RGB16I: number;
  80402. readonly RGBA16I: number;
  80403. readonly R16UI: number;
  80404. readonly RG16UI: number;
  80405. readonly RGB16UI: number;
  80406. readonly RGBA16UI: number;
  80407. readonly R32I: number;
  80408. readonly RG32I: number;
  80409. readonly RGB32I: number;
  80410. readonly RGBA32I: number;
  80411. readonly R32UI: number;
  80412. readonly RG32UI: number;
  80413. readonly RGB32UI: number;
  80414. readonly RGBA32UI: number;
  80415. readonly RGB10_A2UI: number;
  80416. readonly R11F_G11F_B10F: number;
  80417. readonly RGB9_E5: number;
  80418. readonly RGB10_A2: number;
  80419. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  80420. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  80421. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  80422. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  80423. readonly DEPTH_COMPONENT32F: number;
  80424. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  80425. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  80426. 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;
  80427. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  80428. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  80429. readonly TRANSFORM_FEEDBACK: number;
  80430. readonly INTERLEAVED_ATTRIBS: number;
  80431. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  80432. createTransformFeedback(): WebGLTransformFeedback;
  80433. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  80434. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  80435. beginTransformFeedback(primitiveMode: number): void;
  80436. endTransformFeedback(): void;
  80437. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  80438. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80439. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80440. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  80441. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  80442. }
  80443. interface ImageBitmap {
  80444. readonly width: number;
  80445. readonly height: number;
  80446. close(): void;
  80447. }
  80448. interface WebGLQuery extends WebGLObject {
  80449. }
  80450. declare var WebGLQuery: {
  80451. prototype: WebGLQuery;
  80452. new(): WebGLQuery;
  80453. };
  80454. interface WebGLSampler extends WebGLObject {
  80455. }
  80456. declare var WebGLSampler: {
  80457. prototype: WebGLSampler;
  80458. new(): WebGLSampler;
  80459. };
  80460. interface WebGLSync extends WebGLObject {
  80461. }
  80462. declare var WebGLSync: {
  80463. prototype: WebGLSync;
  80464. new(): WebGLSync;
  80465. };
  80466. interface WebGLTransformFeedback extends WebGLObject {
  80467. }
  80468. declare var WebGLTransformFeedback: {
  80469. prototype: WebGLTransformFeedback;
  80470. new(): WebGLTransformFeedback;
  80471. };
  80472. interface WebGLVertexArrayObject extends WebGLObject {
  80473. }
  80474. declare var WebGLVertexArrayObject: {
  80475. prototype: WebGLVertexArrayObject;
  80476. new(): WebGLVertexArrayObject;
  80477. };
  80478. interface Navigator {
  80479. readonly gpu: GPU | undefined;
  80480. }
  80481. interface GPUColorDict {
  80482. a: number;
  80483. b: number;
  80484. g: number;
  80485. r: number;
  80486. }
  80487. type GPUColor = [number, number, number, number] | GPUColorDict;
  80488. interface GPUOrigin2DDict {
  80489. x?: number;
  80490. y?: number;
  80491. }
  80492. type GPUOrigin2D = [number, number] | GPUOrigin2DDict;
  80493. interface GPUOrigin3DDict {
  80494. x?: number;
  80495. y?: number;
  80496. z?: number;
  80497. }
  80498. type GPUOrigin3D = [number, number, number] | GPUOrigin3DDict;
  80499. interface GPUExtent3DDict {
  80500. width: number;
  80501. height: number;
  80502. depth: number;
  80503. }
  80504. type GPUExtent3D = [number, number, number] | GPUExtent3DDict;
  80505. type GPUBindingResource =
  80506. | GPUSampler
  80507. | GPUTextureView
  80508. | GPUBufferBinding;
  80509. type GPUExtensionName =
  80510. | "texture-compression-bc"
  80511. | "timestamp-query"
  80512. | "pipeline-statistics-query"
  80513. | "depth-clamping"
  80514. | "depth24unorm-stencil8"
  80515. | "depth32float-stencil8";
  80516. type GPUAddressMode = "clamp-to-edge" | "repeat" | "mirror-repeat";
  80517. type GPUBindingType =
  80518. | "uniform-buffer"
  80519. | "storage-buffer"
  80520. | "readonly-storage-buffer"
  80521. | "sampler"
  80522. | "comparison-sampler"
  80523. | "sampled-texture"
  80524. | "readonly-storage-texture"
  80525. | "writeonly-storage-texture";
  80526. type GPUBlendFactor =
  80527. | "zero"
  80528. | "one"
  80529. | "src-color"
  80530. | "one-minus-src-color"
  80531. | "src-alpha"
  80532. | "one-minus-src-alpha"
  80533. | "dst-color"
  80534. | "one-minus-dst-color"
  80535. | "dst-alpha"
  80536. | "one-minus-dst-alpha"
  80537. | "src-alpha-saturated"
  80538. | "blend-color"
  80539. | "one-minus-blend-color";
  80540. type GPUBlendOperation =
  80541. | "add"
  80542. | "subtract"
  80543. | "reverse-subtract"
  80544. | "min"
  80545. | "max";
  80546. type GPUCompareFunction =
  80547. | "never"
  80548. | "less"
  80549. | "equal"
  80550. | "less-equal"
  80551. | "greater"
  80552. | "not-equal"
  80553. | "greater-equal"
  80554. | "always";
  80555. type GPUCullMode = "none" | "front" | "back";
  80556. type GPUFilterMode = "nearest" | "linear";
  80557. type GPUFrontFace = "ccw" | "cw";
  80558. type GPUIndexFormat = "uint16" | "uint32";
  80559. type GPUInputStepMode = "vertex" | "instance";
  80560. type GPULoadOp = "load";
  80561. type GPUPrimitiveTopology =
  80562. | "point-list"
  80563. | "line-list"
  80564. | "line-strip"
  80565. | "triangle-list"
  80566. | "triangle-strip";
  80567. type GPUStencilOperation =
  80568. | "keep"
  80569. | "zero"
  80570. | "replace"
  80571. | "invert"
  80572. | "increment-clamp"
  80573. | "decrement-clamp"
  80574. | "increment-wrap"
  80575. | "decrement-wrap";
  80576. type GPUStoreOp = "store" | "clear";
  80577. type GPUTextureDimension = "1d" | "2d" | "3d";
  80578. type GPUTextureFormat =
  80579. | "r8unorm"
  80580. | "r8snorm"
  80581. | "r8uint"
  80582. | "r8sint"
  80583. | "r16uint"
  80584. | "r16sint"
  80585. | "r16float"
  80586. | "rg8unorm"
  80587. | "rg8snorm"
  80588. | "rg8uint"
  80589. | "rg8sint"
  80590. | "r32uint"
  80591. | "r32sint"
  80592. | "r32float"
  80593. | "rg16uint"
  80594. | "rg16sint"
  80595. | "rg16float"
  80596. | "rgba8unorm"
  80597. | "rgba8unorm-srgb"
  80598. | "rgba8snorm"
  80599. | "rgba8uint"
  80600. | "rgba8sint"
  80601. | "bgra8unorm"
  80602. | "bgra8unorm-srgb"
  80603. | "rgb9e5ufloat"
  80604. | "rgb10a2unorm"
  80605. | "rg11b10ufloat"
  80606. | "rg32uint"
  80607. | "rg32sint"
  80608. | "rg32float"
  80609. | "rgba16uint"
  80610. | "rgba16sint"
  80611. | "rgba16float"
  80612. | "rgba32uint"
  80613. | "rgba32sint"
  80614. | "rgba32float"
  80615. | "stencil8"
  80616. | "depth16unorm"
  80617. | "depth24plus"
  80618. | "depth24plus-stencil8"
  80619. | "depth32float"
  80620. | "bc1-rgba-unorm"
  80621. | "bc1-rgba-unorm-srgb"
  80622. | "bc2-rgba-unorm"
  80623. | "bc2-rgba-unorm-srgb"
  80624. | "bc3-rgba-unorm"
  80625. | "bc3-rgba-unorm-srgb"
  80626. | "bc4-r-unorm"
  80627. | "bc4-r-snorm"
  80628. | "bc5-rg-unorm"
  80629. | "bc5-rg-snorm"
  80630. | "bc6h-rgb-ufloat"
  80631. | "bc6h-rgb-float"
  80632. | "bc7-rgba-unorm"
  80633. | "bc7-rgba-unorm-srgb"
  80634. | "depth24unorm-stencil8"
  80635. | "depth32float-stencil8";
  80636. type GPUTextureComponentType = "float" | "sint" | "uint" | "depth-comparison";
  80637. type GPUTextureViewDimension =
  80638. | "1d"
  80639. | "2d"
  80640. | "2d-array"
  80641. | "cube"
  80642. | "cube-array"
  80643. | "3d";
  80644. type GPUVertexFormat =
  80645. | "uchar2"
  80646. | "uchar4"
  80647. | "char2"
  80648. | "char4"
  80649. | "uchar2norm"
  80650. | "uchar4norm"
  80651. | "char2norm"
  80652. | "char4norm"
  80653. | "ushort2"
  80654. | "ushort4"
  80655. | "short2"
  80656. | "short4"
  80657. | "ushort2norm"
  80658. | "ushort4norm"
  80659. | "short2norm"
  80660. | "short4norm"
  80661. | "half2"
  80662. | "half4"
  80663. | "float"
  80664. | "float2"
  80665. | "float3"
  80666. | "float4"
  80667. | "uint"
  80668. | "uint2"
  80669. | "uint3"
  80670. | "uint4"
  80671. | "int"
  80672. | "int2"
  80673. | "int3"
  80674. | "int4";
  80675. type GPUTextureAspect = "all" | "stencil-only" | "depth-only";
  80676. type GPUBufferUsageFlags = number;
  80677. type GPUColorWriteFlags = number;
  80678. type GPUShaderStageFlags = number;
  80679. type GPUTextureUsageFlags = number;
  80680. type GPUMapModeFlags = number;
  80681. interface GPUBindGroupEntry {
  80682. binding: number;
  80683. resource: GPUBindingResource;
  80684. }
  80685. interface GPUBindGroupDescriptor extends GPUObjectDescriptorBase {
  80686. layout: GPUBindGroupLayout;
  80687. entries: Iterable<GPUBindGroupEntry>;
  80688. }
  80689. interface GPUBindGroupLayoutEntry {
  80690. binding: number;
  80691. visibility: GPUShaderStageFlags;
  80692. type: GPUBindingType;
  80693. hasDynamicOffset?: boolean;
  80694. minBufferBindingSize?: number;
  80695. viewDimension?: GPUTextureViewDimension;
  80696. textureComponentType?: GPUTextureComponentType;
  80697. storageTextureFormat?: GPUTextureFormat;
  80698. }
  80699. interface GPUBindGroupLayoutDescriptor
  80700. extends GPUObjectDescriptorBase {
  80701. entries: Iterable<GPUBindGroupLayoutEntry>;
  80702. }
  80703. interface GPUBlendDescriptor {
  80704. dstFactor?: GPUBlendFactor;
  80705. operation?: GPUBlendOperation;
  80706. srcFactor?: GPUBlendFactor;
  80707. }
  80708. interface GPUColorStateDescriptor {
  80709. format: GPUTextureFormat;
  80710. alphaBlend?: GPUBlendDescriptor;
  80711. colorBlend?: GPUBlendDescriptor;
  80712. writeMask?: GPUColorWriteFlags;
  80713. }
  80714. interface GPUBufferBinding {
  80715. buffer: GPUBuffer;
  80716. offset?: number;
  80717. size?: number;
  80718. }
  80719. interface GPUTextureDataLayout {
  80720. offset?: number;
  80721. bytesPerRow: number;
  80722. rowsPerImage?: number;
  80723. }
  80724. interface GPUBufferCopyView extends GPUTextureDataLayout {
  80725. buffer: GPUBuffer;
  80726. }
  80727. interface GPUTextureCopyView {
  80728. texture: GPUTexture;
  80729. mipLevel?: number;
  80730. origin?: GPUOrigin3D;
  80731. }
  80732. interface GPUImageBitmapCopyView {
  80733. imageBitmap: ImageBitmap;
  80734. origin?: GPUOrigin2D;
  80735. }
  80736. interface GPUBufferDescriptor extends GPUObjectDescriptorBase {
  80737. size: number;
  80738. usage: GPUBufferUsageFlags;
  80739. mappedAtCreation?: boolean;
  80740. }
  80741. interface GPUCommandEncoderDescriptor extends GPUObjectDescriptorBase {
  80742. label?: string;
  80743. measureExecutionTime?: boolean;
  80744. }
  80745. interface GPUComputePipelineDescriptor
  80746. extends GPUPipelineDescriptorBase {
  80747. computeStage: GPUProgrammableStageDescriptor;
  80748. }
  80749. interface GPUDepthStencilStateDescriptor {
  80750. format: GPUTextureFormat;
  80751. depthWriteEnabled?: boolean;
  80752. depthCompare?: GPUCompareFunction;
  80753. stencilFront?: GPUStencilStateFaceDescriptor;
  80754. stencilBack?: GPUStencilStateFaceDescriptor;
  80755. stencilReadMask?: number;
  80756. stencilWriteMask?: number;
  80757. }
  80758. interface GPUDeviceDescriptor extends GPUObjectDescriptorBase {
  80759. extensions?: Iterable<GPUExtensionName>;
  80760. limits?: GPULimits;
  80761. }
  80762. interface GPUFenceDescriptor extends GPUObjectDescriptorBase {
  80763. initialValue?: number;
  80764. label?: string;
  80765. signalQueue?: GPUQueue;
  80766. }
  80767. interface GPUVertexAttributeDescriptor {
  80768. format: GPUVertexFormat;
  80769. offset: number;
  80770. shaderLocation: number;
  80771. }
  80772. interface GPUVertexBufferLayoutDescriptor {
  80773. arrayStride: number;
  80774. stepMode?: GPUInputStepMode;
  80775. attributes: Iterable<GPUVertexAttributeDescriptor>;
  80776. }
  80777. interface GPUVertexStateDescriptor {
  80778. indexFormat?: GPUIndexFormat;
  80779. vertexBuffers?: Iterable<GPUVertexBufferLayoutDescriptor>;
  80780. }
  80781. interface GPULimits {
  80782. maxBindGroups?: number;
  80783. maxDynamicUniformBuffersPerPipelineLayout?: number;
  80784. maxDynamicStorageBuffersPerPipelineLayout?: number;
  80785. maxSampledTexturesPerShaderStage?: number;
  80786. maxSamplersPerShaderStage?: number;
  80787. maxStorageBuffersPerShaderStage?: number;
  80788. maxStorageTexturesPerShaderStage?: number;
  80789. maxUniformBuffersPerShaderStage?: number;
  80790. maxUniformBufferBindingSize?: number;
  80791. }
  80792. interface GPUPipelineDescriptorBase {
  80793. label?: string;
  80794. layout?: GPUPipelineLayout;
  80795. }
  80796. interface GPUPipelineLayoutDescriptor extends GPUObjectDescriptorBase {
  80797. bindGroupLayouts: Iterable<GPUBindGroupLayout>;
  80798. }
  80799. interface GPUProgrammableStageDescriptor {
  80800. module: GPUShaderModule;
  80801. entryPoint: string;
  80802. }
  80803. interface GPURasterizationStateDescriptor {
  80804. frontFace?: GPUFrontFace;
  80805. cullMode?: GPUCullMode;
  80806. clampDepth?: boolean;
  80807. depthBias?: number;
  80808. depthBiasSlopeScale?: number;
  80809. depthBiasClamp?: number;
  80810. }
  80811. interface GPURenderPassColorAttachmentDescriptor {
  80812. attachment: GPUTextureView;
  80813. resolveTarget?: GPUTextureView;
  80814. loadValue: GPULoadOp | GPUColor;
  80815. storeOp?: GPUStoreOp;
  80816. }
  80817. interface GPURenderPassDepthStencilAttachmentDescriptor {
  80818. attachment: GPUTextureView;
  80819. depthLoadValue: GPULoadOp | number;
  80820. depthStoreOp: GPUStoreOp;
  80821. depthReadOnly?: boolean;
  80822. stencilLoadValue: GPULoadOp | number;
  80823. stencilStoreOp: GPUStoreOp;
  80824. stencilReadOnly?: boolean;
  80825. }
  80826. interface GPURenderPassDescriptor extends GPUObjectDescriptorBase {
  80827. colorAttachments: Iterable<GPURenderPassColorAttachmentDescriptor>;
  80828. depthStencilAttachment?: GPURenderPassDepthStencilAttachmentDescriptor;
  80829. }
  80830. interface GPURenderPipelineDescriptor
  80831. extends GPUPipelineDescriptorBase {
  80832. vertexStage: GPUProgrammableStageDescriptor;
  80833. fragmentStage?: GPUProgrammableStageDescriptor;
  80834. primitiveTopology: GPUPrimitiveTopology;
  80835. rasterizationState?: GPURasterizationStateDescriptor;
  80836. colorStates: Iterable<GPUColorStateDescriptor>;
  80837. depthStencilState?: GPUDepthStencilStateDescriptor;
  80838. vertexState?: GPUVertexStateDescriptor;
  80839. sampleCount?: number;
  80840. sampleMask?: number;
  80841. alphaToCoverageEnabled?: boolean;
  80842. }
  80843. interface GPUSamplerDescriptor extends GPUObjectDescriptorBase {
  80844. addressModeU?: GPUAddressMode;
  80845. addressModeV?: GPUAddressMode;
  80846. addressModeW?: GPUAddressMode;
  80847. magFilter?: GPUFilterMode;
  80848. minFilter?: GPUFilterMode;
  80849. mipmapFilter?: GPUFilterMode;
  80850. lodMinClamp?: number;
  80851. lodMaxClamp?: number;
  80852. compare?: GPUCompareFunction;
  80853. maxAnisotropy?: number;
  80854. }
  80855. interface GPUShaderModuleDescriptor extends GPUObjectDescriptorBase {
  80856. code: Uint32Array | string;
  80857. label?: string;
  80858. sourceMap?: object;
  80859. }
  80860. interface GPUStencilStateFaceDescriptor {
  80861. compare?: GPUCompareFunction;
  80862. depthFailOp?: GPUStencilOperation;
  80863. passOp?: GPUStencilOperation;
  80864. failOp?: GPUStencilOperation;
  80865. }
  80866. interface GPUSwapChainDescriptor extends GPUObjectDescriptorBase {
  80867. device: GPUDevice;
  80868. format: GPUTextureFormat;
  80869. usage?: GPUTextureUsageFlags;
  80870. }
  80871. interface GPUTextureDescriptor extends GPUObjectDescriptorBase {
  80872. size: GPUExtent3D;
  80873. mipLevelCount?: number;
  80874. sampleCount?: number;
  80875. dimension?: GPUTextureDimension;
  80876. format: GPUTextureFormat;
  80877. usage: GPUTextureUsageFlags;
  80878. }
  80879. interface GPUTextureViewDescriptor extends GPUObjectDescriptorBase {
  80880. format?: GPUTextureFormat;
  80881. dimension?: GPUTextureViewDimension;
  80882. aspect?: GPUTextureAspect;
  80883. baseArrayLayer?: number;
  80884. baseMipLevel?: number;
  80885. arrayLayerCount?: number;
  80886. mipLevelCount?: number;
  80887. }
  80888. declare class GPUAdapter {
  80889. // https://michalzalecki.com/nominal-typing-in-typescript/#approach-1-class-with-a-private-property
  80890. private __brand: void;
  80891. readonly name: string;
  80892. readonly extensions: GPUExtensionName[];
  80893. readonly limits: Required<GPULimits>;
  80894. requestDevice(descriptor?: GPUDeviceDescriptor): Promise<GPUDevice | null>;
  80895. }
  80896. declare class GPUBindGroup implements GPUObjectBase {
  80897. private __brand: void;
  80898. label: string | undefined;
  80899. }
  80900. declare class GPUBindGroupLayout implements GPUObjectBase {
  80901. private __brand: void;
  80902. label: string | undefined;
  80903. }
  80904. declare class GPUBuffer implements GPUObjectBase {
  80905. private __brand: void;
  80906. label: string | undefined;
  80907. destroy(): void;
  80908. unmap(): void;
  80909. mapAsync(mode: GPUMapModeFlags, offset?: number, size?: number): Promise<void>;
  80910. getMappedRange(offset?: number, size?: number): ArrayBuffer;
  80911. }
  80912. declare class GPUCommandBuffer implements GPUObjectBase {
  80913. private __brand: void;
  80914. label: string | undefined;
  80915. readonly executionTime: Promise<number>;
  80916. }
  80917. interface GPUCommandBufferDescriptor extends GPUObjectDescriptorBase { }
  80918. declare class GPUCommandEncoder implements GPUObjectBase {
  80919. private __brand: void;
  80920. label: string | undefined;
  80921. beginComputePass(
  80922. descriptor?: GPUComputePassDescriptor
  80923. ): GPUComputePassEncoder;
  80924. beginRenderPass(descriptor: GPURenderPassDescriptor): GPURenderPassEncoder;
  80925. copyBufferToBuffer(
  80926. source: GPUBuffer,
  80927. sourceOffset: number,
  80928. destination: GPUBuffer,
  80929. destinationOffset: number,
  80930. size: number
  80931. ): void;
  80932. copyBufferToTexture(
  80933. source: GPUBufferCopyView,
  80934. destination: GPUTextureCopyView,
  80935. copySize: GPUExtent3D
  80936. ): void;
  80937. copyTextureToBuffer(
  80938. source: GPUTextureCopyView,
  80939. destination: GPUBufferCopyView,
  80940. copySize: GPUExtent3D
  80941. ): void;
  80942. copyTextureToTexture(
  80943. source: GPUTextureCopyView,
  80944. destination: GPUTextureCopyView,
  80945. copySize: GPUExtent3D
  80946. ): void;
  80947. finish(descriptor?: GPUCommandBufferDescriptor): GPUCommandBuffer;
  80948. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80949. popDebugGroup(): void;
  80950. pushDebugGroup(groupLabel: string): void;
  80951. insertDebugMarker(markerLabel: string): void;
  80952. }
  80953. interface GPUComputePassDescriptor extends GPUObjectDescriptorBase { }
  80954. declare class GPUComputePassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder {
  80955. private __brand: void;
  80956. label: string | undefined;
  80957. setBindGroup(
  80958. index: number,
  80959. bindGroup: GPUBindGroup,
  80960. dynamicOffsets?: Iterable<number>
  80961. ): void;
  80962. popDebugGroup(): void;
  80963. pushDebugGroup(groupLabel: string): void;
  80964. insertDebugMarker(markerLabel: string): void;
  80965. setPipeline(pipeline: GPUComputePipeline): void;
  80966. dispatch(x: number, y?: number, z?: number): void;
  80967. dispatchIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  80968. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  80969. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80970. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  80971. endPass(): void;
  80972. }
  80973. declare class GPUComputePipeline implements GPUPipelineBase {
  80974. private __brand: void;
  80975. label: string | undefined;
  80976. getBindGroupLayout(index: number): GPUBindGroupLayout;
  80977. }
  80978. interface GPUObjectBase {
  80979. label: string | undefined;
  80980. }
  80981. interface GPUObjectDescriptorBase {
  80982. label?: string;
  80983. }
  80984. // SwapChain / CanvasContext
  80985. declare class GPUCanvasContext {
  80986. private __brand: void;
  80987. configureSwapChain(descriptor: GPUSwapChainDescriptor): GPUSwapChain;
  80988. getSwapChainPreferredFormat(device: GPUDevice): Promise<GPUTextureFormat>;
  80989. }
  80990. declare class GPUDevice extends EventTarget implements GPUObjectBase {
  80991. private __brand: void;
  80992. label: string | undefined;
  80993. readonly adapter: GPUAdapter;
  80994. readonly extensions: GPUExtensionName[];
  80995. readonly limits: Required<GPULimits>;
  80996. createBindGroup(descriptor: GPUBindGroupDescriptor): GPUBindGroup;
  80997. createBindGroupLayout(
  80998. descriptor: GPUBindGroupLayoutDescriptor
  80999. ): GPUBindGroupLayout;
  81000. createBuffer(descriptor: GPUBufferDescriptor): GPUBuffer;
  81001. createPipelineLayout(
  81002. descriptor: GPUPipelineLayoutDescriptor
  81003. ): GPUPipelineLayout;
  81004. createSampler(descriptor?: GPUSamplerDescriptor): GPUSampler;
  81005. createShaderModule(descriptor: GPUShaderModuleDescriptor): GPUShaderModule;
  81006. createTexture(descriptor: GPUTextureDescriptor): GPUTexture;
  81007. createComputePipeline(
  81008. descriptor: GPUComputePipelineDescriptor
  81009. ): GPUComputePipeline;
  81010. createRenderPipeline(
  81011. descriptor: GPURenderPipelineDescriptor
  81012. ): GPURenderPipeline;
  81013. createReadyComputePipeline(
  81014. descriptor: GPUComputePipelineDescriptor
  81015. ): Promise<GPUComputePipeline>;
  81016. createReadyRenderPipeline(
  81017. descriptor: GPURenderPipelineDescriptor
  81018. ): Promise<GPURenderPipeline>;
  81019. createCommandEncoder(
  81020. descriptor?: GPUCommandEncoderDescriptor
  81021. ): GPUCommandEncoder;
  81022. createRenderBundleEncoder(
  81023. descriptor: GPURenderBundleEncoderDescriptor
  81024. ): GPURenderBundleEncoder;
  81025. createQuerySet(descriptor: GPUQuerySetDescriptor): GPUQuerySet;
  81026. defaultQueue: GPUQueue;
  81027. pushErrorScope(filter: GPUErrorFilter): void;
  81028. popErrorScope(): Promise<GPUError | null>;
  81029. onuncapturederror: Event | undefined;
  81030. readonly lost: Promise<GPUDeviceLostInfo>;
  81031. }
  81032. declare class GPUFence implements GPUObjectBase {
  81033. private __brand: void;
  81034. label: string | undefined;
  81035. getCompletedValue(): number;
  81036. onCompletion(completionValue: number): Promise<void>;
  81037. }
  81038. interface GPUPipelineBase extends GPUObjectBase {
  81039. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81040. }
  81041. declare class GPUPipelineLayout implements GPUObjectBase {
  81042. private __brand: void;
  81043. label: string | undefined;
  81044. }
  81045. interface GPUProgrammablePassEncoder {
  81046. setBindGroup(
  81047. index: number,
  81048. bindGroup: GPUBindGroup,
  81049. dynamicOffsets?: Iterable<number>
  81050. ): void;
  81051. popDebugGroup(): void;
  81052. pushDebugGroup(groupLabel: string): void;
  81053. insertDebugMarker(markerLabel: string): void;
  81054. }
  81055. declare class GPUQueue implements GPUObjectBase {
  81056. private __brand: void;
  81057. label: string | undefined;
  81058. signal(fence: GPUFence, signalValue: number): void;
  81059. submit(commandBuffers: Iterable<GPUCommandBuffer>): void;
  81060. createFence(descriptor?: GPUFenceDescriptor): GPUFence;
  81061. writeBuffer(buffer: GPUBuffer,
  81062. bufferOffset: number,
  81063. data: BufferSource | ArrayBuffer,
  81064. dataOffset?: number,
  81065. size?: number): void;
  81066. writeTexture(destination: GPUTextureCopyView,
  81067. data: BufferSource | ArrayBuffer,
  81068. dataLayout: GPUTextureDataLayout,
  81069. size: GPUExtent3D): void;
  81070. copyImageBitmapToTexture(
  81071. source: GPUImageBitmapCopyView,
  81072. destination: GPUTextureCopyView,
  81073. copySize: GPUExtent3D
  81074. ): void;
  81075. }
  81076. type GPUQueryType =
  81077. | "occlusion"
  81078. | "timestamp"
  81079. | "pipeline-statistics";
  81080. type GPUPipelineStatisticName =
  81081. | "vertex-shader-invocations"
  81082. | "clipper-invocations"
  81083. | "clipper-primitives-out"
  81084. | "fragment-shader-invocations"
  81085. | "compute-shader-invocations";
  81086. interface GPUQuerySetDescriptor extends GPUObjectDescriptorBase {
  81087. type: GPUQueryType;
  81088. count: number;
  81089. pipelineStatistics?: Iterable<GPUPipelineStatisticName>;
  81090. }
  81091. declare class GPUQuerySet implements GPUObjectBase {
  81092. private __brand: void;
  81093. label: string | undefined;
  81094. destroy(): void;
  81095. }
  81096. interface GPURenderEncoderBase {
  81097. setPipeline(pipeline: GPURenderPipeline): void;
  81098. setIndexBuffer(buffer: GPUBuffer, offset?: number, size?: number): void;
  81099. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81100. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number, size?: number): void;
  81101. draw(
  81102. vertexCount: number,
  81103. instanceCount?: number,
  81104. firstVertex?: number,
  81105. firstInstance?: number
  81106. ): void;
  81107. drawIndexed(
  81108. indexCount: number,
  81109. instanceCount?: number,
  81110. firstIndex?: number,
  81111. baseVertex?: number,
  81112. firstInstance?: number
  81113. ): void;
  81114. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81115. drawIndexedIndirect(
  81116. indirectBuffer: GPUBuffer,
  81117. indirectOffset: number
  81118. ): void;
  81119. }
  81120. declare class GPURenderPassEncoder implements GPUObjectBase, GPUProgrammablePassEncoder, GPURenderEncoderBase {
  81121. private __brand: void;
  81122. label: string | undefined;
  81123. setBindGroup(
  81124. index: number,
  81125. bindGroup: GPUBindGroup,
  81126. dynamicOffsets?: Iterable<number>
  81127. ): void;
  81128. popDebugGroup(): void;
  81129. pushDebugGroup(groupLabel: string): void;
  81130. insertDebugMarker(markerLabel: string): void;
  81131. setPipeline(pipeline: GPURenderPipeline): void;
  81132. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81133. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81134. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81135. draw(
  81136. vertexCount: number,
  81137. instanceCount?: number,
  81138. firstVertex?: number,
  81139. firstInstance?: number
  81140. ): void;
  81141. drawIndexed(
  81142. indexCount: number,
  81143. instanceCount?: number,
  81144. firstIndex?: number,
  81145. baseVertex?: number,
  81146. firstInstance?: number
  81147. ): void;
  81148. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81149. drawIndexedIndirect(
  81150. indirectBuffer: GPUBuffer,
  81151. indirectOffset: number
  81152. ): void;
  81153. setViewport(
  81154. x: number,
  81155. y: number,
  81156. width: number,
  81157. height: number,
  81158. minDepth: number,
  81159. maxDepth: number
  81160. ): void;
  81161. setScissorRect(x: number, y: number, width: number, height: number): void;
  81162. setBlendColor(color: GPUColor): void;
  81163. setStencilReference(reference: number): void;
  81164. writeTimestamp(querySet: GPUQuerySet, queryIndex: number): void;
  81165. beginOcclusionQuery(queryIndex: number): void;
  81166. endOcclusionQuery(): void;
  81167. beginPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81168. endPipelineStatisticsQuery(querySet: GPUQuerySet, queryIndex: number): void;
  81169. executeBundles(bundles: Iterable<GPURenderBundle>): void;
  81170. endPass(): void;
  81171. }
  81172. interface GPURenderBundleDescriptor extends GPUObjectDescriptorBase { }
  81173. declare class GPURenderBundle implements GPUObjectBase {
  81174. private __brand: void;
  81175. label: string | undefined;
  81176. }
  81177. declare class GPURenderBundleEncoder implements GPURenderEncoderBase {
  81178. private __brand: void;
  81179. label: string | undefined;
  81180. setBindGroup(
  81181. index: number,
  81182. bindGroup: GPUBindGroup,
  81183. dynamicOffsets?: Iterable<number>
  81184. ): void;
  81185. popDebugGroup(): void;
  81186. pushDebugGroup(groupLabel: string): void;
  81187. insertDebugMarker(markerLabel: string): void;
  81188. setPipeline(pipeline: GPURenderPipeline): void;
  81189. setIndexBuffer(buffer: GPUBuffer, offset?: number): void;
  81190. setIndexBuffer(buffer: GPUBuffer, indexFormat: GPUIndexFormat, offset?: number, size?: number): void;
  81191. setVertexBuffer(slot: number, buffer: GPUBuffer, offset?: number): void;
  81192. draw(
  81193. vertexCount: number,
  81194. instanceCount?: number,
  81195. firstVertex?: number,
  81196. firstInstance?: number
  81197. ): void;
  81198. drawIndexed(
  81199. indexCount: number,
  81200. instanceCount?: number,
  81201. firstIndex?: number,
  81202. baseVertex?: number,
  81203. firstInstance?: number
  81204. ): void;
  81205. drawIndirect(indirectBuffer: GPUBuffer, indirectOffset: number): void;
  81206. drawIndexedIndirect(
  81207. indirectBuffer: GPUBuffer,
  81208. indirectOffset: number
  81209. ): void;
  81210. finish(descriptor?: GPURenderBundleDescriptor): GPURenderBundle;
  81211. }
  81212. interface GPURenderBundleEncoderDescriptor
  81213. extends GPUObjectDescriptorBase {
  81214. colorFormats: Iterable<GPUTextureFormat>;
  81215. depthStencilFormat?: GPUTextureFormat;
  81216. sampleCount?: number;
  81217. }
  81218. declare class GPURenderPipeline implements GPUPipelineBase {
  81219. private __brand: void;
  81220. label: string | undefined;
  81221. getBindGroupLayout(index: number): GPUBindGroupLayout;
  81222. }
  81223. declare class GPUSampler implements GPUObjectBase {
  81224. private __brand: void;
  81225. label: string | undefined;
  81226. }
  81227. type GPUCompilationMessageType =
  81228. | "error"
  81229. | "warning"
  81230. | "info";
  81231. interface GPUCompilationMessage {
  81232. readonly message: string;
  81233. readonly type: GPUCompilationMessageType;
  81234. readonly lineNum: number;
  81235. readonly linePos: number;
  81236. }
  81237. interface GPUCompilationInfo {
  81238. readonly messages: readonly GPUCompilationMessage[];
  81239. }
  81240. declare class GPUShaderModule implements GPUObjectBase {
  81241. private __brand: void;
  81242. label: string | undefined;
  81243. compilationInfo(): Promise<GPUCompilationInfo>;
  81244. }
  81245. declare class GPUSwapChain implements GPUObjectBase {
  81246. private __brand: void;
  81247. label: string | undefined;
  81248. getCurrentTexture(): GPUTexture;
  81249. }
  81250. declare class GPUTexture implements GPUObjectBase {
  81251. private __brand: void;
  81252. label: string | undefined;
  81253. createView(descriptor?: GPUTextureViewDescriptor): GPUTextureView;
  81254. destroy(): void;
  81255. }
  81256. declare class GPUTextureView implements GPUObjectBase {
  81257. private __brand: void;
  81258. label: string | undefined;
  81259. }
  81260. type GPUPowerPreference = "low-power" | "high-performance";
  81261. interface GPURequestAdapterOptions {
  81262. powerPreference?: GPUPowerPreference;
  81263. }
  81264. declare class GPU {
  81265. private __brand: void;
  81266. requestAdapter(options?: GPURequestAdapterOptions): Promise<GPUAdapter | null>;
  81267. }
  81268. // ****************************************************************************
  81269. // ERROR SCOPES
  81270. // ****************************************************************************
  81271. type GPUErrorFilter = "out-of-memory" | "validation";
  81272. declare class GPUOutOfMemoryError {
  81273. private __brand: void;
  81274. constructor();
  81275. }
  81276. declare class GPUValidationError {
  81277. private __brand: void;
  81278. constructor(message: string);
  81279. readonly message: string;
  81280. }
  81281. type GPUError = GPUOutOfMemoryError | GPUValidationError;
  81282. // ****************************************************************************
  81283. // TELEMETRY
  81284. // ****************************************************************************
  81285. declare class GPUUncapturedErrorEvent extends Event {
  81286. private __brand: void;
  81287. constructor(
  81288. type: string,
  81289. gpuUncapturedErrorEventInitDict: GPUUncapturedErrorEventInit
  81290. );
  81291. readonly error: GPUError;
  81292. }
  81293. interface GPUUncapturedErrorEventInit extends EventInit {
  81294. error: GPUError;
  81295. }
  81296. declare class GPUDeviceLostInfo {
  81297. private __brand: void;
  81298. readonly message: string;
  81299. }
  81300. // Type definitions for WebVR API
  81301. // Project: https://w3c.github.io/webvr/
  81302. // Definitions by: six a <https://github.com/lostfictions>
  81303. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  81304. interface VRDisplay extends EventTarget {
  81305. /**
  81306. * Dictionary of capabilities describing the VRDisplay.
  81307. */
  81308. readonly capabilities: VRDisplayCapabilities;
  81309. /**
  81310. * z-depth defining the far plane of the eye view frustum
  81311. * enables mapping of values in the render target depth
  81312. * attachment to scene coordinates. Initially set to 10000.0.
  81313. */
  81314. depthFar: number;
  81315. /**
  81316. * z-depth defining the near plane of the eye view frustum
  81317. * enables mapping of values in the render target depth
  81318. * attachment to scene coordinates. Initially set to 0.01.
  81319. */
  81320. depthNear: number;
  81321. /**
  81322. * An identifier for this distinct VRDisplay. Used as an
  81323. * association point in the Gamepad API.
  81324. */
  81325. readonly displayId: number;
  81326. /**
  81327. * A display name, a user-readable name identifying it.
  81328. */
  81329. readonly displayName: string;
  81330. readonly isConnected: boolean;
  81331. readonly isPresenting: boolean;
  81332. /**
  81333. * If this VRDisplay supports room-scale experiences, the optional
  81334. * stage attribute contains details on the room-scale parameters.
  81335. */
  81336. readonly stageParameters: VRStageParameters | null;
  81337. /**
  81338. * Passing the value returned by `requestAnimationFrame` to
  81339. * `cancelAnimationFrame` will unregister the callback.
  81340. * @param handle Define the hanle of the request to cancel
  81341. */
  81342. cancelAnimationFrame(handle: number): void;
  81343. /**
  81344. * Stops presenting to the VRDisplay.
  81345. * @returns a promise to know when it stopped
  81346. */
  81347. exitPresent(): Promise<void>;
  81348. /**
  81349. * Return the current VREyeParameters for the given eye.
  81350. * @param whichEye Define the eye we want the parameter for
  81351. * @returns the eye parameters
  81352. */
  81353. getEyeParameters(whichEye: string): VREyeParameters;
  81354. /**
  81355. * Populates the passed VRFrameData with the information required to render
  81356. * the current frame.
  81357. * @param frameData Define the data structure to populate
  81358. * @returns true if ok otherwise false
  81359. */
  81360. getFrameData(frameData: VRFrameData): boolean;
  81361. /**
  81362. * Get the layers currently being presented.
  81363. * @returns the list of VR layers
  81364. */
  81365. getLayers(): VRLayer[];
  81366. /**
  81367. * Return a VRPose containing the future predicted pose of the VRDisplay
  81368. * when the current frame will be presented. The value returned will not
  81369. * change until JavaScript has returned control to the browser.
  81370. *
  81371. * The VRPose will contain the position, orientation, velocity,
  81372. * and acceleration of each of these properties.
  81373. * @returns the pose object
  81374. */
  81375. getPose(): VRPose;
  81376. /**
  81377. * Return the current instantaneous pose of the VRDisplay, with no
  81378. * prediction applied.
  81379. * @returns the current instantaneous pose
  81380. */
  81381. getImmediatePose(): VRPose;
  81382. /**
  81383. * The callback passed to `requestAnimationFrame` will be called
  81384. * any time a new frame should be rendered. When the VRDisplay is
  81385. * presenting the callback will be called at the native refresh
  81386. * rate of the HMD. When not presenting this function acts
  81387. * identically to how window.requestAnimationFrame acts. Content should
  81388. * make no assumptions of frame rate or vsync behavior as the HMD runs
  81389. * asynchronously from other displays and at differing refresh rates.
  81390. * @param callback Define the eaction to run next frame
  81391. * @returns the request handle it
  81392. */
  81393. requestAnimationFrame(callback: FrameRequestCallback): number;
  81394. /**
  81395. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  81396. * Repeat calls while already presenting will update the VRLayers being displayed.
  81397. * @param layers Define the list of layer to present
  81398. * @returns a promise to know when the request has been fulfilled
  81399. */
  81400. requestPresent(layers: VRLayer[]): Promise<void>;
  81401. /**
  81402. * Reset the pose for this display, treating its current position and
  81403. * orientation as the "origin/zero" values. VRPose.position,
  81404. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  81405. * updated when calling resetPose(). This should be called in only
  81406. * sitting-space experiences.
  81407. */
  81408. resetPose(): void;
  81409. /**
  81410. * The VRLayer provided to the VRDisplay will be captured and presented
  81411. * in the HMD. Calling this function has the same effect on the source
  81412. * canvas as any other operation that uses its source image, and canvases
  81413. * created without preserveDrawingBuffer set to true will be cleared.
  81414. * @param pose Define the pose to submit
  81415. */
  81416. submitFrame(pose?: VRPose): void;
  81417. }
  81418. declare var VRDisplay: {
  81419. prototype: VRDisplay;
  81420. new(): VRDisplay;
  81421. };
  81422. interface VRLayer {
  81423. leftBounds?: number[] | Float32Array | null;
  81424. rightBounds?: number[] | Float32Array | null;
  81425. source?: HTMLCanvasElement | null;
  81426. }
  81427. interface VRDisplayCapabilities {
  81428. readonly canPresent: boolean;
  81429. readonly hasExternalDisplay: boolean;
  81430. readonly hasOrientation: boolean;
  81431. readonly hasPosition: boolean;
  81432. readonly maxLayers: number;
  81433. }
  81434. interface VREyeParameters {
  81435. /** @deprecated */
  81436. readonly fieldOfView: VRFieldOfView;
  81437. readonly offset: Float32Array;
  81438. readonly renderHeight: number;
  81439. readonly renderWidth: number;
  81440. }
  81441. interface VRFieldOfView {
  81442. readonly downDegrees: number;
  81443. readonly leftDegrees: number;
  81444. readonly rightDegrees: number;
  81445. readonly upDegrees: number;
  81446. }
  81447. interface VRFrameData {
  81448. readonly leftProjectionMatrix: Float32Array;
  81449. readonly leftViewMatrix: Float32Array;
  81450. readonly pose: VRPose;
  81451. readonly rightProjectionMatrix: Float32Array;
  81452. readonly rightViewMatrix: Float32Array;
  81453. readonly timestamp: number;
  81454. }
  81455. interface VRPose {
  81456. readonly angularAcceleration: Float32Array | null;
  81457. readonly angularVelocity: Float32Array | null;
  81458. readonly linearAcceleration: Float32Array | null;
  81459. readonly linearVelocity: Float32Array | null;
  81460. readonly orientation: Float32Array | null;
  81461. readonly position: Float32Array | null;
  81462. readonly timestamp: number;
  81463. }
  81464. interface VRStageParameters {
  81465. sittingToStandingTransform?: Float32Array;
  81466. sizeX?: number;
  81467. sizeY?: number;
  81468. }
  81469. interface Navigator {
  81470. getVRDisplays(): Promise<VRDisplay[]>;
  81471. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  81472. }
  81473. interface Window {
  81474. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  81475. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  81476. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  81477. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81478. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  81479. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  81480. }
  81481. interface Gamepad {
  81482. readonly displayId: number;
  81483. }
  81484. /**
  81485. * Available session modes
  81486. */
  81487. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  81488. /**
  81489. * Reference space types
  81490. */
  81491. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  81492. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  81493. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  81494. /**
  81495. * Handedness types
  81496. */
  81497. type XRHandedness = "none" | "left" | "right";
  81498. /**
  81499. * InputSource target ray modes
  81500. */
  81501. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  81502. /**
  81503. * Eye types
  81504. */
  81505. type XREye = "none" | "left" | "right";
  81506. /**
  81507. * Type of XR events available
  81508. */
  81509. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  81510. type XRFrameRequestCallback = (time: DOMHighResTimeStamp, frame: XRFrame) => void;
  81511. type XRPlaneSet = Set<XRPlane>;
  81512. type XRAnchorSet = Set<XRAnchor>;
  81513. type XREventHandler = (callback: any) => void;
  81514. interface XRLayer extends EventTarget {}
  81515. interface XRSessionInit {
  81516. optionalFeatures?: string[];
  81517. requiredFeatures?: string[];
  81518. trackedImages?: XRTrackedImageInit[];
  81519. }
  81520. interface XRSessionEvent extends Event {
  81521. readonly session: XRSession;
  81522. }
  81523. interface XRSystem {
  81524. isSessionSupported: (sessionMode: XRSessionMode) => Promise<boolean>;
  81525. requestSession: (sessionMode: XRSessionMode, sessionInit?: any) => Promise<XRSession>;
  81526. }
  81527. interface XRViewport {
  81528. readonly x: number;
  81529. readonly y: number;
  81530. readonly width: number;
  81531. readonly height: number;
  81532. }
  81533. interface XRWebGLLayerInit {
  81534. antialias?: boolean;
  81535. depth?: boolean;
  81536. stencil?: boolean;
  81537. alpha?: boolean;
  81538. multiview?: boolean;
  81539. framebufferScaleFactor?: number;
  81540. }
  81541. declare class XRWebGLLayer {
  81542. static getNativeFramebufferScaleFactor(session: XRSession): number;
  81543. constructor(session: XRSession, context: WebGLRenderingContext | WebGL2RenderingContext, layerInit?: XRWebGLLayerInit);
  81544. readonly antialias: boolean;
  81545. readonly framebuffer: WebGLFramebuffer;
  81546. readonly framebufferWidth: number;
  81547. readonly framebufferHeight: number;
  81548. readonly ignoreDepthValues: boolean;
  81549. getViewport: (view: XRView) => XRViewport;
  81550. }
  81551. // tslint:disable-next-line no-empty-interface
  81552. interface XRSpace extends EventTarget {}
  81553. interface XRRenderState {
  81554. readonly baseLayer?: XRWebGLLayer;
  81555. readonly depthFar: number;
  81556. readonly depthNear: number;
  81557. readonly inlineVerticalFieldOfView?: number;
  81558. }
  81559. interface XRRenderStateInit extends XRRenderState {
  81560. baseLayer: XRWebGLLayer;
  81561. depthFar: number;
  81562. depthNear: number;
  81563. inlineVerticalFieldOfView?: number;
  81564. layers?: XRLayer[];
  81565. }
  81566. interface XRReferenceSpace extends XRSpace {
  81567. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  81568. onreset: XREventHandler;
  81569. }
  81570. interface XRBoundedReferenceSpace extends XRSpace {
  81571. readonly boundsGeometry: DOMPointReadOnly[];
  81572. }
  81573. interface XRInputSource {
  81574. readonly handedness: XRHandedness;
  81575. readonly targetRayMode: XRTargetRayMode;
  81576. readonly targetRaySpace: XRSpace;
  81577. readonly gripSpace?: XRSpace;
  81578. readonly gamepad?: Gamepad;
  81579. readonly profiles: Array<string>;
  81580. readonly hand?: XRHand;
  81581. }
  81582. interface XRPose {
  81583. readonly transform: XRRigidTransform;
  81584. readonly emulatedPosition: boolean;
  81585. }
  81586. interface XRWorldInformation {
  81587. detectedPlanes?: XRPlaneSet;
  81588. }
  81589. interface XRFrame {
  81590. readonly session: XRSession;
  81591. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  81592. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  81593. // AR
  81594. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  81595. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  81596. // Anchors
  81597. trackedAnchors?: XRAnchorSet;
  81598. createAnchor?(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  81599. // World geometries
  81600. worldInformation?: XRWorldInformation;
  81601. // Hand tracking
  81602. getJointPose?(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  81603. // Image tracking
  81604. getImageTrackingResults?(): Array<XRImageTrackingResult>;
  81605. }
  81606. interface XRInputSourceEvent extends Event {
  81607. readonly frame: XRFrame;
  81608. readonly inputSource: XRInputSource;
  81609. }
  81610. type XRInputSourceArray = XRInputSource[];
  81611. interface XRSession {
  81612. addEventListener(type: XREventType, listener: XREventHandler, options?: boolean | AddEventListenerOptions): void;
  81613. removeEventListener(type: XREventType, listener: XREventHandler, options?: boolean | EventListenerOptions): void;
  81614. /**
  81615. * Returns a list of this session's XRInputSources, each representing an input device
  81616. * used to control the camera and/or scene.
  81617. */
  81618. readonly inputSources: Array<XRInputSource>;
  81619. /**
  81620. * object which contains options affecting how the imagery is rendered.
  81621. * This includes things such as the near and far clipping planes
  81622. */
  81623. readonly renderState: XRRenderState;
  81624. readonly visibilityState: XRVisibilityState;
  81625. /**
  81626. * Removes a callback from the animation frame painting callback from
  81627. * XRSession's set of animation frame rendering callbacks, given the
  81628. * identifying handle returned by a previous call to requestAnimationFrame().
  81629. */
  81630. cancelAnimationFrame: (handle: number) => void;
  81631. /**
  81632. * Ends the WebXR session. Returns a promise which resolves when the
  81633. * session has been shut down.
  81634. */
  81635. end(): Promise<void>;
  81636. /**
  81637. * Schedules the specified method to be called the next time the user agent
  81638. * is working on rendering an animation frame for the WebXR device. Returns an
  81639. * integer value which can be used to identify the request for the purposes of
  81640. * canceling the callback using cancelAnimationFrame(). This method is comparable
  81641. * to the Window.requestAnimationFrame() method.
  81642. */
  81643. requestAnimationFrame: XRFrameRequestCallback;
  81644. /**
  81645. * Requests that a new XRReferenceSpace of the specified type be created.
  81646. * Returns a promise which resolves with the XRReferenceSpace or
  81647. * XRBoundedReferenceSpace which was requested, or throws a NotSupportedError if
  81648. * the requested space type isn't supported by the device.
  81649. */
  81650. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace | XRBoundedReferenceSpace>;
  81651. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  81652. onend: XREventHandler;
  81653. oninputsourceschange: XREventHandler;
  81654. onselect: XREventHandler;
  81655. onselectstart: XREventHandler;
  81656. onselectend: XREventHandler;
  81657. onsqueeze: XREventHandler;
  81658. onsqueezestart: XREventHandler;
  81659. onsqueezeend: XREventHandler;
  81660. onvisibilitychange: XREventHandler;
  81661. // hit test
  81662. requestHitTestSource?(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  81663. requestHitTestSourceForTransientInput?(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  81664. // legacy AR hit test
  81665. requestHitTest?(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  81666. // legacy plane detection
  81667. updateWorldTrackingState?(options: { planeDetectionState?: { enabled: boolean } }): void;
  81668. // image tracking
  81669. getTrackedImageScores?(): XRImageTrackingScore[];
  81670. }
  81671. interface XRViewerPose extends XRPose {
  81672. readonly views: Array<XRView>;
  81673. }
  81674. declare class XRRigidTransform {
  81675. constructor(position?: DOMPointInit, direction?: DOMPointInit);
  81676. position: DOMPointReadOnly;
  81677. orientation: DOMPointReadOnly;
  81678. matrix: Float32Array;
  81679. inverse: XRRigidTransform;
  81680. }
  81681. interface XRView {
  81682. readonly eye: XREye;
  81683. readonly projectionMatrix: Float32Array;
  81684. readonly transform: XRRigidTransform;
  81685. readonly recommendedViewportScale?: number;
  81686. requestViewportScale(scale: number): void;
  81687. }
  81688. interface XRInputSourceChangeEvent extends Event {
  81689. session: XRSession;
  81690. removed: Array<XRInputSource>;
  81691. added: Array<XRInputSource>;
  81692. }
  81693. // Experimental/Draft features
  81694. declare class XRRay {
  81695. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  81696. origin: DOMPointReadOnly;
  81697. direction: DOMPointReadOnly;
  81698. matrix: Float32Array;
  81699. }
  81700. declare enum XRHitTestTrackableType {
  81701. "point",
  81702. "plane",
  81703. "mesh",
  81704. }
  81705. interface XRHitResult {
  81706. hitMatrix: Float32Array;
  81707. }
  81708. interface XRTransientInputHitTestResult {
  81709. readonly inputSource: XRInputSource;
  81710. readonly results: Array<XRHitTestResult>;
  81711. }
  81712. interface XRHitTestResult {
  81713. getPose(baseSpace: XRSpace): XRPose | undefined;
  81714. // When anchor system is enabled
  81715. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  81716. }
  81717. interface XRHitTestSource {
  81718. cancel(): void;
  81719. }
  81720. interface XRTransientInputHitTestSource {
  81721. cancel(): void;
  81722. }
  81723. interface XRHitTestOptionsInit {
  81724. space: XRSpace;
  81725. entityTypes?: Array<XRHitTestTrackableType>;
  81726. offsetRay?: XRRay;
  81727. }
  81728. interface XRTransientInputHitTestOptionsInit {
  81729. profile: string;
  81730. entityTypes?: Array<XRHitTestTrackableType>;
  81731. offsetRay?: XRRay;
  81732. }
  81733. interface XRAnchor {
  81734. anchorSpace: XRSpace;
  81735. delete(): void;
  81736. }
  81737. interface XRPlane {
  81738. orientation: "Horizontal" | "Vertical";
  81739. planeSpace: XRSpace;
  81740. polygon: Array<DOMPointReadOnly>;
  81741. lastChangedTime: number;
  81742. }
  81743. interface XRJointSpace extends XRSpace {}
  81744. interface XRJointPose extends XRPose {
  81745. radius: number | undefined;
  81746. }
  81747. interface XRHand extends Iterable<XRJointSpace> {
  81748. readonly length: number;
  81749. [index: number]: XRJointSpace;
  81750. readonly WRIST: number;
  81751. readonly THUMB_METACARPAL: number;
  81752. readonly THUMB_PHALANX_PROXIMAL: number;
  81753. readonly THUMB_PHALANX_DISTAL: number;
  81754. readonly THUMB_PHALANX_TIP: number;
  81755. readonly INDEX_METACARPAL: number;
  81756. readonly INDEX_PHALANX_PROXIMAL: number;
  81757. readonly INDEX_PHALANX_INTERMEDIATE: number;
  81758. readonly INDEX_PHALANX_DISTAL: number;
  81759. readonly INDEX_PHALANX_TIP: number;
  81760. readonly MIDDLE_METACARPAL: number;
  81761. readonly MIDDLE_PHALANX_PROXIMAL: number;
  81762. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  81763. readonly MIDDLE_PHALANX_DISTAL: number;
  81764. readonly MIDDLE_PHALANX_TIP: number;
  81765. readonly RING_METACARPAL: number;
  81766. readonly RING_PHALANX_PROXIMAL: number;
  81767. readonly RING_PHALANX_INTERMEDIATE: number;
  81768. readonly RING_PHALANX_DISTAL: number;
  81769. readonly RING_PHALANX_TIP: number;
  81770. readonly LITTLE_METACARPAL: number;
  81771. readonly LITTLE_PHALANX_PROXIMAL: number;
  81772. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  81773. readonly LITTLE_PHALANX_DISTAL: number;
  81774. readonly LITTLE_PHALANX_TIP: number;
  81775. }
  81776. type XRImageTrackingState = "tracked" | "emulated";
  81777. type XRImageTrackingScore = "untrackable" | "trackable";
  81778. interface XRTrackedImageInit {
  81779. image: ImageBitmap;
  81780. widthInMeters: number;
  81781. }
  81782. interface XRImageTrackingResult {
  81783. readonly imageSpace: XRSpace;
  81784. readonly index: number;
  81785. readonly trackingState: XRImageTrackingState;
  81786. readonly measuredWidthInMeters: number;
  81787. }
  81788. // This file contains native only extensions for WebXR. These APIs are not supported in the browser yet.
  81789. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  81790. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  81791. type XRSceneObjectType = "unknown" | "background" | "wall" | "floor" | "ceiling" | "platform";
  81792. interface XRSceneObject {
  81793. type: XRSceneObjectType;
  81794. }
  81795. interface XRFieldOfView {
  81796. angleLeft: number;
  81797. angleRight: number;
  81798. angleUp: number;
  81799. angleDown: number;
  81800. }
  81801. interface XRFrustum {
  81802. position: DOMPointReadOnly;
  81803. orientation: DOMPointReadOnly;
  81804. fieldOfView: XRFieldOfView;
  81805. farDistance: number;
  81806. }
  81807. interface XRPlane {
  81808. parentSceneObject?: XRSceneObject;
  81809. }
  81810. interface XRMesh {
  81811. meshSpace: XRSpace;
  81812. positions: Float32Array;
  81813. indices: Uint32Array;
  81814. normals?: Float32Array;
  81815. lastChangedTime: number;
  81816. parentSceneObject?: XRSceneObject;
  81817. }
  81818. interface XRFrustumDetectionBoundary {
  81819. type: "frustum";
  81820. frustum: XRFrustum;
  81821. }
  81822. interface XRSphereDetectionBoundary {
  81823. type: "sphere";
  81824. radius: number;
  81825. }
  81826. interface XRBoxDetectionBoundary {
  81827. type: "box";
  81828. extent: DOMPointReadOnly;
  81829. }
  81830. type XRDetectionBoundary = XRFrustumDetectionBoundary | XRSphereDetectionBoundary | XRBoxDetectionBoundary;
  81831. interface XRGeometryDetectorOptions {
  81832. detectionBoundary?: XRDetectionBoundary;
  81833. updateInterval?: number;
  81834. }
  81835. interface XRSession {
  81836. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  81837. trySetPreferredPlaneDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81838. trySetMeshDetectorEnabled(enabled: boolean): boolean;
  81839. trySetPreferredMeshDetectorOptions(preferredOptions: XRGeometryDetectorOptions): boolean;
  81840. }
  81841. interface XRFrame {
  81842. featurePointCloud?: Array<number>;
  81843. }
  81844. type XRMeshSet = Set<XRMesh>;
  81845. interface XRWorldInformation {
  81846. detectedMeshes?: XRMeshSet;
  81847. }
  81848. /**
  81849. * @ignore
  81850. */
  81851. declare module BABYLON.GLTF2.Exporter {
  81852. }
  81853. /**
  81854. * @ignore
  81855. */
  81856. declare module BABYLON.GLTF1 {
  81857. }
  81858. declare module BABYLON.GUI {
  81859. /**
  81860. * Interface used to define a control that can receive focus
  81861. */
  81862. export interface IFocusableControl {
  81863. /**
  81864. * Function called when the control receives the focus
  81865. */
  81866. onFocus(): void;
  81867. /**
  81868. * Function called when the control loses the focus
  81869. */
  81870. onBlur(): void;
  81871. /**
  81872. * Function called to let the control handle keyboard events
  81873. * @param evt defines the current keyboard event
  81874. */
  81875. processKeyboard(evt: KeyboardEvent): void;
  81876. /**
  81877. * Function called to get the list of controls that should not steal the focus from this control
  81878. * @returns an array of controls
  81879. */
  81880. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  81881. /**
  81882. * Function to focus the control programmatically
  81883. */
  81884. focus(): void;
  81885. /**
  81886. * Function to unfocus the control programmatically
  81887. */
  81888. blur(): void;
  81889. }
  81890. }
  81891. declare module BABYLON.GUI {
  81892. /**
  81893. * Class used to specific a value and its associated unit
  81894. */
  81895. export class ValueAndUnit {
  81896. /** defines the unit to store */
  81897. unit: number;
  81898. /** defines a boolean indicating if the value can be negative */
  81899. negativeValueAllowed: boolean;
  81900. private _value;
  81901. private _originalUnit;
  81902. /**
  81903. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  81904. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  81905. */
  81906. ignoreAdaptiveScaling: boolean;
  81907. /**
  81908. * Creates a new ValueAndUnit
  81909. * @param value defines the value to store
  81910. * @param unit defines the unit to store
  81911. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  81912. */
  81913. constructor(value: number,
  81914. /** defines the unit to store */
  81915. unit?: number,
  81916. /** defines a boolean indicating if the value can be negative */
  81917. negativeValueAllowed?: boolean);
  81918. /** Gets a boolean indicating if the value is a percentage */
  81919. get isPercentage(): boolean;
  81920. /** Gets a boolean indicating if the value is store as pixel */
  81921. get isPixel(): boolean;
  81922. /** Gets direct internal value */
  81923. get internalValue(): number;
  81924. /**
  81925. * Gets value as pixel
  81926. * @param host defines the root host
  81927. * @param refValue defines the reference value for percentages
  81928. * @returns the value as pixel
  81929. */
  81930. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  81931. /**
  81932. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  81933. * @param value defines the value to store
  81934. * @param unit defines the unit to store
  81935. * @returns the current ValueAndUnit
  81936. */
  81937. updateInPlace(value: number, unit?: number): ValueAndUnit;
  81938. /**
  81939. * Gets the value accordingly to its unit
  81940. * @param host defines the root host
  81941. * @returns the value
  81942. */
  81943. getValue(host: AdvancedDynamicTexture): number;
  81944. /**
  81945. * Gets a string representation of the value
  81946. * @param host defines the root host
  81947. * @param decimals defines an optional number of decimals to display
  81948. * @returns a string
  81949. */
  81950. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  81951. /**
  81952. * Store a value parsed from a string
  81953. * @param source defines the source string
  81954. * @returns true if the value was successfully parsed
  81955. */
  81956. fromString(source: string | number): boolean;
  81957. private static _Regex;
  81958. private static _UNITMODE_PERCENTAGE;
  81959. private static _UNITMODE_PIXEL;
  81960. /** UNITMODE_PERCENTAGE */
  81961. static get UNITMODE_PERCENTAGE(): number;
  81962. /** UNITMODE_PIXEL */
  81963. static get UNITMODE_PIXEL(): number;
  81964. }
  81965. }
  81966. declare module BABYLON.GUI {
  81967. /**
  81968. * Define a style used by control to automatically setup properties based on a template.
  81969. * Only support font related properties so far
  81970. */
  81971. export class Style implements BABYLON.IDisposable {
  81972. private _fontFamily;
  81973. private _fontStyle;
  81974. private _fontWeight;
  81975. /** @hidden */
  81976. _host: AdvancedDynamicTexture;
  81977. /** @hidden */
  81978. _fontSize: ValueAndUnit;
  81979. /**
  81980. * BABYLON.Observable raised when the style values are changed
  81981. */
  81982. onChangedObservable: BABYLON.Observable<Style>;
  81983. /**
  81984. * Creates a new style object
  81985. * @param host defines the AdvancedDynamicTexture which hosts this style
  81986. */
  81987. constructor(host: AdvancedDynamicTexture);
  81988. /**
  81989. * Gets or sets the font size
  81990. */
  81991. get fontSize(): string | number;
  81992. set fontSize(value: string | number);
  81993. /**
  81994. * Gets or sets the font family
  81995. */
  81996. get fontFamily(): string;
  81997. set fontFamily(value: string);
  81998. /**
  81999. * Gets or sets the font style
  82000. */
  82001. get fontStyle(): string;
  82002. set fontStyle(value: string);
  82003. /** Gets or sets font weight */
  82004. get fontWeight(): string;
  82005. set fontWeight(value: string);
  82006. /** Dispose all associated resources */
  82007. dispose(): void;
  82008. }
  82009. }
  82010. declare module BABYLON.GUI {
  82011. /**
  82012. * Class used to transport BABYLON.Vector2 information for pointer events
  82013. */
  82014. export class Vector2WithInfo extends BABYLON.Vector2 {
  82015. /** defines the current mouse button index */
  82016. buttonIndex: number;
  82017. /**
  82018. * Creates a new Vector2WithInfo
  82019. * @param source defines the vector2 data to transport
  82020. * @param buttonIndex defines the current mouse button index
  82021. */
  82022. constructor(source: BABYLON.Vector2,
  82023. /** defines the current mouse button index */
  82024. buttonIndex?: number);
  82025. }
  82026. /** Class used to provide 2D matrix features */
  82027. export class Matrix2D {
  82028. /** Gets the internal array of 6 floats used to store matrix data */
  82029. m: Float32Array;
  82030. /**
  82031. * Creates a new matrix
  82032. * @param m00 defines value for (0, 0)
  82033. * @param m01 defines value for (0, 1)
  82034. * @param m10 defines value for (1, 0)
  82035. * @param m11 defines value for (1, 1)
  82036. * @param m20 defines value for (2, 0)
  82037. * @param m21 defines value for (2, 1)
  82038. */
  82039. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  82040. /**
  82041. * Fills the matrix from direct values
  82042. * @param m00 defines value for (0, 0)
  82043. * @param m01 defines value for (0, 1)
  82044. * @param m10 defines value for (1, 0)
  82045. * @param m11 defines value for (1, 1)
  82046. * @param m20 defines value for (2, 0)
  82047. * @param m21 defines value for (2, 1)
  82048. * @returns the current modified matrix
  82049. */
  82050. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  82051. /**
  82052. * Gets matrix determinant
  82053. * @returns the determinant
  82054. */
  82055. determinant(): number;
  82056. /**
  82057. * Inverses the matrix and stores it in a target matrix
  82058. * @param result defines the target matrix
  82059. * @returns the current matrix
  82060. */
  82061. invertToRef(result: Matrix2D): Matrix2D;
  82062. /**
  82063. * Multiplies the current matrix with another one
  82064. * @param other defines the second operand
  82065. * @param result defines the target matrix
  82066. * @returns the current matrix
  82067. */
  82068. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  82069. /**
  82070. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  82071. * @param x defines the x coordinate to transform
  82072. * @param y defines the x coordinate to transform
  82073. * @param result defines the target vector2
  82074. * @returns the current matrix
  82075. */
  82076. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  82077. /**
  82078. * Creates an identity matrix
  82079. * @returns a new matrix
  82080. */
  82081. static Identity(): Matrix2D;
  82082. /**
  82083. * Creates a translation matrix and stores it in a target matrix
  82084. * @param x defines the x coordinate of the translation
  82085. * @param y defines the y coordinate of the translation
  82086. * @param result defines the target matrix
  82087. */
  82088. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  82089. /**
  82090. * Creates a scaling matrix and stores it in a target matrix
  82091. * @param x defines the x coordinate of the scaling
  82092. * @param y defines the y coordinate of the scaling
  82093. * @param result defines the target matrix
  82094. */
  82095. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  82096. /**
  82097. * Creates a rotation matrix and stores it in a target matrix
  82098. * @param angle defines the rotation angle
  82099. * @param result defines the target matrix
  82100. */
  82101. static RotationToRef(angle: number, result: Matrix2D): void;
  82102. private static _TempPreTranslationMatrix;
  82103. private static _TempPostTranslationMatrix;
  82104. private static _TempRotationMatrix;
  82105. private static _TempScalingMatrix;
  82106. private static _TempCompose0;
  82107. private static _TempCompose1;
  82108. private static _TempCompose2;
  82109. /**
  82110. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  82111. * @param tx defines the x coordinate of the translation
  82112. * @param ty defines the y coordinate of the translation
  82113. * @param angle defines the rotation angle
  82114. * @param scaleX defines the x coordinate of the scaling
  82115. * @param scaleY defines the y coordinate of the scaling
  82116. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  82117. * @param result defines the target matrix
  82118. */
  82119. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  82120. }
  82121. }
  82122. declare module BABYLON.GUI {
  82123. /**
  82124. * Class used to store 2D control sizes
  82125. */
  82126. export class Measure {
  82127. /** defines left coordinate */
  82128. left: number;
  82129. /** defines top coordinate */
  82130. top: number;
  82131. /** defines width dimension */
  82132. width: number;
  82133. /** defines height dimension */
  82134. height: number;
  82135. /**
  82136. * Creates a new measure
  82137. * @param left defines left coordinate
  82138. * @param top defines top coordinate
  82139. * @param width defines width dimension
  82140. * @param height defines height dimension
  82141. */
  82142. constructor(
  82143. /** defines left coordinate */
  82144. left: number,
  82145. /** defines top coordinate */
  82146. top: number,
  82147. /** defines width dimension */
  82148. width: number,
  82149. /** defines height dimension */
  82150. height: number);
  82151. /**
  82152. * Copy from another measure
  82153. * @param other defines the other measure to copy from
  82154. */
  82155. copyFrom(other: Measure): void;
  82156. /**
  82157. * Copy from a group of 4 floats
  82158. * @param left defines left coordinate
  82159. * @param top defines top coordinate
  82160. * @param width defines width dimension
  82161. * @param height defines height dimension
  82162. */
  82163. copyFromFloats(left: number, top: number, width: number, height: number): void;
  82164. /**
  82165. * Computes the axis aligned bounding box measure for two given measures
  82166. * @param a Input measure
  82167. * @param b Input measure
  82168. * @param result the resulting bounding measure
  82169. */
  82170. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  82171. /**
  82172. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82173. * @param transform the matrix to transform the measure before computing the AABB
  82174. * @param addX number to add to left
  82175. * @param addY number to add to top
  82176. * @param addWidth number to add to width
  82177. * @param addHeight number to add to height
  82178. * @param result the resulting AABB
  82179. */
  82180. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  82181. /**
  82182. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  82183. * @param transform the matrix to transform the measure before computing the AABB
  82184. * @param result the resulting AABB
  82185. */
  82186. transformToRef(transform: Matrix2D, result: Measure): void;
  82187. /**
  82188. * Check equality between this measure and another one
  82189. * @param other defines the other measures
  82190. * @returns true if both measures are equals
  82191. */
  82192. isEqualsTo(other: Measure): boolean;
  82193. /**
  82194. * Creates an empty measure
  82195. * @returns a new measure
  82196. */
  82197. static Empty(): Measure;
  82198. }
  82199. }
  82200. declare module BABYLON.GUI {
  82201. /**
  82202. * Class used to create texture to support 2D GUI elements
  82203. * @see https://doc.babylonjs.com/how_to/gui
  82204. */
  82205. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  82206. private _isDirty;
  82207. private _renderObserver;
  82208. private _resizeObserver;
  82209. private _preKeyboardObserver;
  82210. private _pointerMoveObserver;
  82211. private _pointerObserver;
  82212. private _canvasPointerOutObserver;
  82213. private _canvasBlurObserver;
  82214. private _background;
  82215. /** @hidden */
  82216. _rootContainer: Container;
  82217. /** @hidden */
  82218. _lastPickedControl: Control;
  82219. /** @hidden */
  82220. _lastControlOver: {
  82221. [pointerId: number]: Control;
  82222. };
  82223. /** @hidden */
  82224. _lastControlDown: {
  82225. [pointerId: number]: Control;
  82226. };
  82227. /** @hidden */
  82228. _capturingControl: {
  82229. [pointerId: number]: Control;
  82230. };
  82231. /** @hidden */
  82232. _shouldBlockPointer: boolean;
  82233. /** @hidden */
  82234. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  82235. /** @hidden */
  82236. _linkedControls: Control[];
  82237. private _isFullscreen;
  82238. private _fullscreenViewport;
  82239. private _idealWidth;
  82240. private _idealHeight;
  82241. private _useSmallestIdeal;
  82242. private _renderAtIdealSize;
  82243. private _focusedControl;
  82244. private _blockNextFocusCheck;
  82245. private _renderScale;
  82246. private _rootElement;
  82247. private _cursorChanged;
  82248. private _defaultMousePointerId;
  82249. /** @hidden */
  82250. _numLayoutCalls: number;
  82251. /** Gets the number of layout calls made the last time the ADT has been rendered */
  82252. get numLayoutCalls(): number;
  82253. /** @hidden */
  82254. _numRenderCalls: number;
  82255. /** Gets the number of render calls made the last time the ADT has been rendered */
  82256. get numRenderCalls(): number;
  82257. /**
  82258. * Define type to string to ensure compatibility across browsers
  82259. * Safari doesn't support DataTransfer constructor
  82260. */
  82261. private _clipboardData;
  82262. /**
  82263. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  82264. */
  82265. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  82266. /**
  82267. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  82268. */
  82269. onControlPickedObservable: BABYLON.Observable<Control>;
  82270. /**
  82271. * BABYLON.Observable event triggered before layout is evaluated
  82272. */
  82273. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82274. /**
  82275. * BABYLON.Observable event triggered after the layout was evaluated
  82276. */
  82277. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82278. /**
  82279. * BABYLON.Observable event triggered before the texture is rendered
  82280. */
  82281. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82282. /**
  82283. * BABYLON.Observable event triggered after the texture was rendered
  82284. */
  82285. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  82286. /**
  82287. * Gets or sets a boolean defining if alpha is stored as premultiplied
  82288. */
  82289. premulAlpha: boolean;
  82290. /**
  82291. * Gets or sets a boolean indicating that the canvas must be reverted on Y when updating the texture
  82292. */
  82293. applyYInversionOnUpdate: boolean;
  82294. /**
  82295. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  82296. * Useful when you want more antialiasing
  82297. */
  82298. get renderScale(): number;
  82299. set renderScale(value: number);
  82300. /** Gets or sets the background color */
  82301. get background(): string;
  82302. set background(value: string);
  82303. /**
  82304. * Gets or sets the ideal width used to design controls.
  82305. * The GUI will then rescale everything accordingly
  82306. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82307. */
  82308. get idealWidth(): number;
  82309. set idealWidth(value: number);
  82310. /**
  82311. * Gets or sets the ideal height used to design controls.
  82312. * The GUI will then rescale everything accordingly
  82313. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82314. */
  82315. get idealHeight(): number;
  82316. set idealHeight(value: number);
  82317. /**
  82318. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  82319. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82320. */
  82321. get useSmallestIdeal(): boolean;
  82322. set useSmallestIdeal(value: boolean);
  82323. /**
  82324. * Gets or sets a boolean indicating if adaptive scaling must be used
  82325. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82326. */
  82327. get renderAtIdealSize(): boolean;
  82328. set renderAtIdealSize(value: boolean);
  82329. /**
  82330. * Gets the ratio used when in "ideal mode"
  82331. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  82332. * */
  82333. get idealRatio(): number;
  82334. /**
  82335. * Gets the underlying layer used to render the texture when in fullscreen mode
  82336. */
  82337. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  82338. /**
  82339. * Gets the root container control
  82340. */
  82341. get rootContainer(): Container;
  82342. /**
  82343. * Returns an array containing the root container.
  82344. * This is mostly used to let the Inspector introspects the ADT
  82345. * @returns an array containing the rootContainer
  82346. */
  82347. getChildren(): Array<Container>;
  82348. /**
  82349. * Will return all controls that are inside this texture
  82350. * @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
  82351. * @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
  82352. * @return all child controls
  82353. */
  82354. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  82355. /**
  82356. * Gets or sets the current focused control
  82357. */
  82358. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  82359. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  82360. /**
  82361. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  82362. */
  82363. get isForeground(): boolean;
  82364. set isForeground(value: boolean);
  82365. /**
  82366. * Gets or set information about clipboardData
  82367. */
  82368. get clipboardData(): string;
  82369. set clipboardData(value: string);
  82370. /**
  82371. * Creates a new AdvancedDynamicTexture
  82372. * @param name defines the name of the texture
  82373. * @param width defines the width of the texture
  82374. * @param height defines the height of the texture
  82375. * @param scene defines the hosting scene
  82376. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  82377. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82378. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82379. */
  82380. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  82381. /**
  82382. * Get the current class name of the texture useful for serialization or dynamic coding.
  82383. * @returns "AdvancedDynamicTexture"
  82384. */
  82385. getClassName(): string;
  82386. /**
  82387. * Function used to execute a function on all controls
  82388. * @param func defines the function to execute
  82389. * @param container defines the container where controls belong. If null the root container will be used
  82390. */
  82391. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  82392. private _useInvalidateRectOptimization;
  82393. /**
  82394. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  82395. */
  82396. get useInvalidateRectOptimization(): boolean;
  82397. set useInvalidateRectOptimization(value: boolean);
  82398. private _invalidatedRectangle;
  82399. /**
  82400. * Invalidates a rectangle area on the gui texture
  82401. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  82402. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  82403. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  82404. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  82405. */
  82406. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  82407. /**
  82408. * Marks the texture as dirty forcing a complete update
  82409. */
  82410. markAsDirty(): void;
  82411. /**
  82412. * Helper function used to create a new style
  82413. * @returns a new style
  82414. * @see https://doc.babylonjs.com/how_to/gui#styles
  82415. */
  82416. createStyle(): Style;
  82417. /**
  82418. * Adds a new control to the root container
  82419. * @param control defines the control to add
  82420. * @returns the current texture
  82421. */
  82422. addControl(control: Control): AdvancedDynamicTexture;
  82423. /**
  82424. * Removes a control from the root container
  82425. * @param control defines the control to remove
  82426. * @returns the current texture
  82427. */
  82428. removeControl(control: Control): AdvancedDynamicTexture;
  82429. /**
  82430. * Release all resources
  82431. */
  82432. dispose(): void;
  82433. private _onResize;
  82434. /** @hidden */
  82435. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  82436. /**
  82437. * Get screen coordinates for a vector3
  82438. * @param position defines the position to project
  82439. * @param worldMatrix defines the world matrix to use
  82440. * @returns the projected position
  82441. */
  82442. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  82443. /**
  82444. * Get screen coordinates for a vector3
  82445. * @param position defines the position to project
  82446. * @param worldMatrix defines the world matrix to use
  82447. * @returns the projected position with Z
  82448. */
  82449. getProjectedPositionWithZ(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector3;
  82450. private _checkUpdate;
  82451. private _clearMeasure;
  82452. private _render;
  82453. /** @hidden */
  82454. _changeCursor(cursor: string): void;
  82455. /** @hidden */
  82456. _registerLastControlDown(control: Control, pointerId: number): void;
  82457. private _doPicking;
  82458. /** @hidden */
  82459. _cleanControlAfterRemovalFromList(list: {
  82460. [pointerId: number]: Control;
  82461. }, control: Control): void;
  82462. /** @hidden */
  82463. _cleanControlAfterRemoval(control: Control): void;
  82464. /** Attach to all scene events required to support pointer events */
  82465. attach(): void;
  82466. /** @hidden */
  82467. private onClipboardCopy;
  82468. /** @hidden */
  82469. private onClipboardCut;
  82470. /** @hidden */
  82471. private onClipboardPaste;
  82472. /**
  82473. * Register the clipboard Events onto the canvas
  82474. */
  82475. registerClipboardEvents(): void;
  82476. /**
  82477. * Unregister the clipboard Events from the canvas
  82478. */
  82479. unRegisterClipboardEvents(): void;
  82480. /**
  82481. * Connect the texture to a hosting mesh to enable interactions
  82482. * @param mesh defines the mesh to attach to
  82483. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  82484. */
  82485. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  82486. /**
  82487. * Move the focus to a specific control
  82488. * @param control defines the control which will receive the focus
  82489. */
  82490. moveFocusToControl(control: IFocusableControl): void;
  82491. private _manageFocus;
  82492. private _attachToOnPointerOut;
  82493. private _attachToOnBlur;
  82494. /**
  82495. * Serializes the entire GUI system
  82496. * @returns an object with the JSON serialized data
  82497. */
  82498. serializeContent(): any;
  82499. /**
  82500. * Recreate the content of the ADT from a JSON object
  82501. * @param serializedObject define the JSON serialized object to restore from
  82502. */
  82503. parseContent(serializedObject: any): void;
  82504. /**
  82505. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  82506. * @param mesh defines the mesh which will receive the texture
  82507. * @param width defines the texture width (1024 by default)
  82508. * @param height defines the texture height (1024 by default)
  82509. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82510. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  82511. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82512. * @returns a new AdvancedDynamicTexture
  82513. */
  82514. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82515. /**
  82516. * 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
  82517. * @param mesh defines the mesh which will receive the texture
  82518. * @param width defines the texture width (1024 by default)
  82519. * @param height defines the texture height (1024 by default)
  82520. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  82521. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  82522. * @returns a new AdvancedDynamicTexture
  82523. */
  82524. static CreateForMeshTexture(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  82525. /**
  82526. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  82527. * In this mode the texture will rely on a layer for its rendering.
  82528. * This allows it to be treated like any other layer.
  82529. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  82530. * LayerMask is set through advancedTexture.layer.layerMask
  82531. * @param name defines name for the texture
  82532. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  82533. * @param scene defines the hsoting scene
  82534. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  82535. * @returns a new AdvancedDynamicTexture
  82536. */
  82537. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  82538. }
  82539. }
  82540. declare module BABYLON.GUI {
  82541. /**
  82542. * Root class used for all 2D controls
  82543. * @see https://doc.babylonjs.com/how_to/gui#controls
  82544. */
  82545. export class Control {
  82546. /** defines the name of the control */
  82547. name?: string | undefined;
  82548. /**
  82549. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  82550. */
  82551. static AllowAlphaInheritance: boolean;
  82552. private _alpha;
  82553. private _alphaSet;
  82554. private _zIndex;
  82555. /** @hidden */
  82556. _host: AdvancedDynamicTexture;
  82557. /** Gets or sets the control parent */
  82558. parent: BABYLON.Nullable<Container>;
  82559. /** @hidden */
  82560. _currentMeasure: Measure;
  82561. private _fontFamily;
  82562. private _fontStyle;
  82563. private _fontWeight;
  82564. private _fontSize;
  82565. private _font;
  82566. /** @hidden */
  82567. _width: ValueAndUnit;
  82568. /** @hidden */
  82569. _height: ValueAndUnit;
  82570. /** @hidden */
  82571. protected _fontOffset: {
  82572. ascent: number;
  82573. height: number;
  82574. descent: number;
  82575. };
  82576. private _color;
  82577. private _style;
  82578. private _styleObserver;
  82579. /** @hidden */
  82580. protected _horizontalAlignment: number;
  82581. /** @hidden */
  82582. protected _verticalAlignment: number;
  82583. /** @hidden */
  82584. protected _isDirty: boolean;
  82585. /** @hidden */
  82586. protected _wasDirty: boolean;
  82587. /** @hidden */
  82588. _tempParentMeasure: Measure;
  82589. /** @hidden */
  82590. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  82591. /** @hidden */
  82592. protected _cachedParentMeasure: Measure;
  82593. private _paddingLeft;
  82594. private _paddingRight;
  82595. private _paddingTop;
  82596. private _paddingBottom;
  82597. /** @hidden */
  82598. _left: ValueAndUnit;
  82599. /** @hidden */
  82600. _top: ValueAndUnit;
  82601. private _scaleX;
  82602. private _scaleY;
  82603. private _rotation;
  82604. private _transformCenterX;
  82605. private _transformCenterY;
  82606. /** @hidden */
  82607. _transformMatrix: Matrix2D;
  82608. /** @hidden */
  82609. protected _invertTransformMatrix: Matrix2D;
  82610. /** @hidden */
  82611. protected _transformedPosition: BABYLON.Vector2;
  82612. private _isMatrixDirty;
  82613. private _cachedOffsetX;
  82614. private _cachedOffsetY;
  82615. private _isVisible;
  82616. private _isHighlighted;
  82617. /** @hidden */
  82618. _linkedMesh: BABYLON.Nullable<BABYLON.TransformNode>;
  82619. private _fontSet;
  82620. private _dummyVector2;
  82621. private _downCount;
  82622. private _enterCount;
  82623. private _doNotRender;
  82624. private _downPointerIds;
  82625. protected _isEnabled: boolean;
  82626. protected _disabledColor: string;
  82627. protected _disabledColorItem: string;
  82628. /** @hidden */
  82629. protected _rebuildLayout: boolean;
  82630. /** @hidden */
  82631. _customData: any;
  82632. /** @hidden */
  82633. _isClipped: boolean;
  82634. /** @hidden */
  82635. _automaticSize: boolean;
  82636. /** @hidden */
  82637. _tag: any;
  82638. /**
  82639. * 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
  82640. */
  82641. uniqueId: number;
  82642. /**
  82643. * Gets or sets an object used to store user defined information for the node
  82644. */
  82645. metadata: any;
  82646. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  82647. isHitTestVisible: boolean;
  82648. /** Gets or sets a boolean indicating if the control can block pointer events */
  82649. isPointerBlocker: boolean;
  82650. /** Gets or sets a boolean indicating if the control can be focusable */
  82651. isFocusInvisible: boolean;
  82652. /**
  82653. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  82654. * 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
  82655. */
  82656. clipChildren: boolean;
  82657. /**
  82658. * Gets or sets a boolean indicating that control content must be clipped
  82659. * 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
  82660. */
  82661. clipContent: boolean;
  82662. /**
  82663. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  82664. */
  82665. useBitmapCache: boolean;
  82666. private _cacheData;
  82667. private _shadowOffsetX;
  82668. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  82669. get shadowOffsetX(): number;
  82670. set shadowOffsetX(value: number);
  82671. private _shadowOffsetY;
  82672. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  82673. get shadowOffsetY(): number;
  82674. set shadowOffsetY(value: number);
  82675. private _shadowBlur;
  82676. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  82677. get shadowBlur(): number;
  82678. set shadowBlur(value: number);
  82679. private _shadowColor;
  82680. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  82681. get shadowColor(): string;
  82682. set shadowColor(value: string);
  82683. /** Gets or sets the cursor to use when the control is hovered */
  82684. hoverCursor: string;
  82685. /** @hidden */
  82686. protected _linkOffsetX: ValueAndUnit;
  82687. /** @hidden */
  82688. protected _linkOffsetY: ValueAndUnit;
  82689. /** Gets the control type name */
  82690. get typeName(): string;
  82691. /**
  82692. * Get the current class name of the control.
  82693. * @returns current class name
  82694. */
  82695. getClassName(): string;
  82696. /**
  82697. * An event triggered when pointer wheel is scrolled
  82698. */
  82699. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  82700. /**
  82701. * An event triggered when the pointer move over the control.
  82702. */
  82703. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  82704. /**
  82705. * An event triggered when the pointer move out of the control.
  82706. */
  82707. onPointerOutObservable: BABYLON.Observable<Control>;
  82708. /**
  82709. * An event triggered when the pointer taps the control
  82710. */
  82711. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  82712. /**
  82713. * An event triggered when pointer up
  82714. */
  82715. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  82716. /**
  82717. * An event triggered when a control is clicked on
  82718. */
  82719. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  82720. /**
  82721. * An event triggered when pointer enters the control
  82722. */
  82723. onPointerEnterObservable: BABYLON.Observable<Control>;
  82724. /**
  82725. * An event triggered when the control is marked as dirty
  82726. */
  82727. onDirtyObservable: BABYLON.Observable<Control>;
  82728. /**
  82729. * An event triggered before drawing the control
  82730. */
  82731. onBeforeDrawObservable: BABYLON.Observable<Control>;
  82732. /**
  82733. * An event triggered after the control was drawn
  82734. */
  82735. onAfterDrawObservable: BABYLON.Observable<Control>;
  82736. /**
  82737. * An event triggered when the control has been disposed
  82738. */
  82739. onDisposeObservable: BABYLON.Observable<Control>;
  82740. /**
  82741. * Get the hosting AdvancedDynamicTexture
  82742. */
  82743. get host(): AdvancedDynamicTexture;
  82744. /** Gets or set information about font offsets (used to render and align text) */
  82745. get fontOffset(): {
  82746. ascent: number;
  82747. height: number;
  82748. descent: number;
  82749. };
  82750. set fontOffset(offset: {
  82751. ascent: number;
  82752. height: number;
  82753. descent: number;
  82754. });
  82755. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  82756. get alpha(): number;
  82757. set alpha(value: number);
  82758. /**
  82759. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  82760. */
  82761. get isHighlighted(): boolean;
  82762. set isHighlighted(value: boolean);
  82763. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  82764. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82765. */
  82766. get scaleX(): number;
  82767. set scaleX(value: number);
  82768. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  82769. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82770. */
  82771. get scaleY(): number;
  82772. set scaleY(value: number);
  82773. /** Gets or sets the rotation angle (0 by default)
  82774. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82775. */
  82776. get rotation(): number;
  82777. set rotation(value: number);
  82778. /** Gets or sets the transformation center on Y axis (0 by default)
  82779. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82780. */
  82781. get transformCenterY(): number;
  82782. set transformCenterY(value: number);
  82783. /** Gets or sets the transformation center on X axis (0 by default)
  82784. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  82785. */
  82786. get transformCenterX(): number;
  82787. set transformCenterX(value: number);
  82788. /**
  82789. * Gets or sets the horizontal alignment
  82790. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82791. */
  82792. get horizontalAlignment(): number;
  82793. set horizontalAlignment(value: number);
  82794. /**
  82795. * Gets or sets the vertical alignment
  82796. * @see https://doc.babylonjs.com/how_to/gui#alignments
  82797. */
  82798. get verticalAlignment(): number;
  82799. set verticalAlignment(value: number);
  82800. /**
  82801. * Gets or sets a fixed ratio for this control.
  82802. * When different from 0, the ratio is used to compute the "second" dimension.
  82803. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  82804. * second dimension is computed as first dimension * fixedRatio
  82805. */
  82806. fixedRatio: number;
  82807. private _fixedRatioMasterIsWidth;
  82808. /**
  82809. * Gets or sets control width
  82810. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82811. */
  82812. get width(): string | number;
  82813. set width(value: string | number);
  82814. /**
  82815. * Gets or sets the control width in pixel
  82816. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82817. */
  82818. get widthInPixels(): number;
  82819. set widthInPixels(value: number);
  82820. /**
  82821. * Gets or sets control height
  82822. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82823. */
  82824. get height(): string | number;
  82825. set height(value: string | number);
  82826. /**
  82827. * Gets or sets control height in pixel
  82828. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82829. */
  82830. get heightInPixels(): number;
  82831. set heightInPixels(value: number);
  82832. /** Gets or set font family */
  82833. get fontFamily(): string;
  82834. set fontFamily(value: string);
  82835. /** Gets or sets font style */
  82836. get fontStyle(): string;
  82837. set fontStyle(value: string);
  82838. /** Gets or sets font weight */
  82839. get fontWeight(): string;
  82840. set fontWeight(value: string);
  82841. /**
  82842. * Gets or sets style
  82843. * @see https://doc.babylonjs.com/how_to/gui#styles
  82844. */
  82845. get style(): BABYLON.Nullable<Style>;
  82846. set style(value: BABYLON.Nullable<Style>);
  82847. /** @hidden */
  82848. get _isFontSizeInPercentage(): boolean;
  82849. /** Gets or sets font size in pixels */
  82850. get fontSizeInPixels(): number;
  82851. set fontSizeInPixels(value: number);
  82852. /** Gets or sets font size */
  82853. get fontSize(): string | number;
  82854. set fontSize(value: string | number);
  82855. /** Gets or sets foreground color */
  82856. get color(): string;
  82857. set color(value: string);
  82858. /** Gets or sets z index which is used to reorder controls on the z axis */
  82859. get zIndex(): number;
  82860. set zIndex(value: number);
  82861. /** Gets or sets a boolean indicating if the control can be rendered */
  82862. get notRenderable(): boolean;
  82863. set notRenderable(value: boolean);
  82864. /** Gets or sets a boolean indicating if the control is visible */
  82865. get isVisible(): boolean;
  82866. set isVisible(value: boolean);
  82867. /** Gets a boolean indicating that the control needs to update its rendering */
  82868. get isDirty(): boolean;
  82869. /**
  82870. * Gets the current linked mesh (or null if none)
  82871. */
  82872. get linkedMesh(): BABYLON.Nullable<BABYLON.TransformNode>;
  82873. /**
  82874. * Gets or sets a value indicating the padding to use on the left of the control
  82875. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82876. */
  82877. get paddingLeft(): string | number;
  82878. set paddingLeft(value: string | number);
  82879. /**
  82880. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  82881. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82882. */
  82883. get paddingLeftInPixels(): number;
  82884. set paddingLeftInPixels(value: number);
  82885. /**
  82886. * Gets or sets a value indicating the padding to use on the right of the control
  82887. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82888. */
  82889. get paddingRight(): string | number;
  82890. set paddingRight(value: string | number);
  82891. /**
  82892. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  82893. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82894. */
  82895. get paddingRightInPixels(): number;
  82896. set paddingRightInPixels(value: number);
  82897. /**
  82898. * Gets or sets a value indicating the padding to use on the top of the control
  82899. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82900. */
  82901. get paddingTop(): string | number;
  82902. set paddingTop(value: string | number);
  82903. /**
  82904. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  82905. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82906. */
  82907. get paddingTopInPixels(): number;
  82908. set paddingTopInPixels(value: number);
  82909. /**
  82910. * Gets or sets a value indicating the padding to use on the bottom of the control
  82911. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82912. */
  82913. get paddingBottom(): string | number;
  82914. set paddingBottom(value: string | number);
  82915. /**
  82916. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  82917. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82918. */
  82919. get paddingBottomInPixels(): number;
  82920. set paddingBottomInPixels(value: number);
  82921. /**
  82922. * Gets or sets a value indicating the left coordinate of the control
  82923. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82924. */
  82925. get left(): string | number;
  82926. set left(value: string | number);
  82927. /**
  82928. * Gets or sets a value indicating the left coordinate in pixels of the control
  82929. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82930. */
  82931. get leftInPixels(): number;
  82932. set leftInPixels(value: number);
  82933. /**
  82934. * Gets or sets a value indicating the top coordinate of the control
  82935. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82936. */
  82937. get top(): string | number;
  82938. set top(value: string | number);
  82939. /**
  82940. * Gets or sets a value indicating the top coordinate in pixels of the control
  82941. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  82942. */
  82943. get topInPixels(): number;
  82944. set topInPixels(value: number);
  82945. /**
  82946. * Gets or sets a value indicating the offset on X axis to the linked mesh
  82947. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82948. */
  82949. get linkOffsetX(): string | number;
  82950. set linkOffsetX(value: string | number);
  82951. /**
  82952. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  82953. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82954. */
  82955. get linkOffsetXInPixels(): number;
  82956. set linkOffsetXInPixels(value: number);
  82957. /**
  82958. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  82959. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82960. */
  82961. get linkOffsetY(): string | number;
  82962. set linkOffsetY(value: string | number);
  82963. /**
  82964. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  82965. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  82966. */
  82967. get linkOffsetYInPixels(): number;
  82968. set linkOffsetYInPixels(value: number);
  82969. /** Gets the center coordinate on X axis */
  82970. get centerX(): number;
  82971. /** Gets the center coordinate on Y axis */
  82972. get centerY(): number;
  82973. /** Gets or sets if control is Enabled */
  82974. get isEnabled(): boolean;
  82975. set isEnabled(value: boolean);
  82976. /** Gets or sets background color of control if it's disabled */
  82977. get disabledColor(): string;
  82978. set disabledColor(value: string);
  82979. /** Gets or sets front color of control if it's disabled */
  82980. get disabledColorItem(): string;
  82981. set disabledColorItem(value: string);
  82982. /**
  82983. * Creates a new control
  82984. * @param name defines the name of the control
  82985. */
  82986. constructor(
  82987. /** defines the name of the control */
  82988. name?: string | undefined);
  82989. /** @hidden */
  82990. protected _getTypeName(): string;
  82991. /**
  82992. * Gets the first ascendant in the hierarchy of the given type
  82993. * @param className defines the required type
  82994. * @returns the ascendant or null if not found
  82995. */
  82996. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  82997. /** @hidden */
  82998. _resetFontCache(): void;
  82999. /**
  83000. * Determines if a container is an ascendant of the current control
  83001. * @param container defines the container to look for
  83002. * @returns true if the container is one of the ascendant of the control
  83003. */
  83004. isAscendant(container: Control): boolean;
  83005. /**
  83006. * Gets coordinates in local control space
  83007. * @param globalCoordinates defines the coordinates to transform
  83008. * @returns the new coordinates in local space
  83009. */
  83010. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83011. /**
  83012. * Gets coordinates in local control space
  83013. * @param globalCoordinates defines the coordinates to transform
  83014. * @param result defines the target vector2 where to store the result
  83015. * @returns the current control
  83016. */
  83017. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  83018. /**
  83019. * Gets coordinates in parent local control space
  83020. * @param globalCoordinates defines the coordinates to transform
  83021. * @returns the new coordinates in parent local space
  83022. */
  83023. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  83024. /**
  83025. * Move the current control to a vector3 position projected onto the screen.
  83026. * @param position defines the target position
  83027. * @param scene defines the hosting scene
  83028. */
  83029. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  83030. /**
  83031. * Will store all controls that have this control as ascendant in a given array
  83032. * @param results defines the array where to store the descendants
  83033. * @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
  83034. * @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
  83035. */
  83036. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83037. /**
  83038. * Will return all controls that have this control as ascendant
  83039. * @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
  83040. * @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
  83041. * @return all child controls
  83042. */
  83043. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  83044. /**
  83045. * Link current control with a target mesh
  83046. * @param mesh defines the mesh to link with
  83047. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  83048. */
  83049. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.TransformNode>): void;
  83050. /**
  83051. * Shorthand funtion to set the top, right, bottom, and left padding values on the control.
  83052. * @param { string | number} paddingTop - The value of the top padding.
  83053. * @param { string | number} paddingRight - The value of the right padding. If omitted, top is used.
  83054. * @param { string | number} paddingBottom - The value of the bottom padding. If omitted, top is used.
  83055. * @param { string | number} paddingLeft - The value of the left padding. If omitted, right is used.
  83056. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83057. */
  83058. setPadding(paddingTop: string | number, paddingRight?: string | number, paddingBottom?: string | number, paddingLeft?: string | number): void;
  83059. /**
  83060. * Shorthand funtion to set the top, right, bottom, and left padding values in pixels on the control.
  83061. * @param { number} paddingTop - The value in pixels of the top padding.
  83062. * @param { number} paddingRight - The value in pixels of the right padding. If omitted, top is used.
  83063. * @param { number} paddingBottom - The value in pixels of the bottom padding. If omitted, top is used.
  83064. * @param { number} paddingLeft - The value in pixels of the left padding. If omitted, right is used.
  83065. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  83066. */
  83067. setPaddingInPixels(paddingTop: number, paddingRight?: number, paddingBottom?: number, paddingLeft?: number): void;
  83068. /** @hidden */
  83069. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  83070. /** @hidden */
  83071. _offsetLeft(offset: number): void;
  83072. /** @hidden */
  83073. _offsetTop(offset: number): void;
  83074. /** @hidden */
  83075. _markMatrixAsDirty(): void;
  83076. /** @hidden */
  83077. _flagDescendantsAsMatrixDirty(): void;
  83078. /** @hidden */
  83079. _intersectsRect(rect: Measure): boolean;
  83080. /** @hidden */
  83081. protected invalidateRect(): void;
  83082. /** @hidden */
  83083. _markAsDirty(force?: boolean): void;
  83084. /** @hidden */
  83085. _markAllAsDirty(): void;
  83086. /** @hidden */
  83087. _link(host: AdvancedDynamicTexture): void;
  83088. /** @hidden */
  83089. protected _transform(context?: CanvasRenderingContext2D): void;
  83090. /** @hidden */
  83091. _renderHighlight(context: CanvasRenderingContext2D): void;
  83092. /** @hidden */
  83093. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  83094. /** @hidden */
  83095. protected _applyStates(context: CanvasRenderingContext2D): void;
  83096. /** @hidden */
  83097. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83098. /** @hidden */
  83099. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83100. protected _evaluateClippingState(parentMeasure: Measure): void;
  83101. /** @hidden */
  83102. _measure(): void;
  83103. /** @hidden */
  83104. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83105. /** @hidden */
  83106. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83107. /** @hidden */
  83108. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83109. /** @hidden */
  83110. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83111. private static _ClipMeasure;
  83112. private _tmpMeasureA;
  83113. private _clip;
  83114. /** @hidden */
  83115. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  83116. /** @hidden */
  83117. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83118. /**
  83119. * Tests if a given coordinates belong to the current control
  83120. * @param x defines x coordinate to test
  83121. * @param y defines y coordinate to test
  83122. * @returns true if the coordinates are inside the control
  83123. */
  83124. contains(x: number, y: number): boolean;
  83125. /** @hidden */
  83126. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83127. /** @hidden */
  83128. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  83129. /** @hidden */
  83130. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83131. /** @hidden */
  83132. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  83133. /** @hidden */
  83134. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83135. /** @hidden */
  83136. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  83137. /** @hidden */
  83138. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  83139. /** @hidden */
  83140. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  83141. /** @hidden */
  83142. _onCanvasBlur(): void;
  83143. /** @hidden */
  83144. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83145. private _prepareFont;
  83146. /**
  83147. * Serializes the current control
  83148. * @param serializationObject defined the JSON serialized object
  83149. */
  83150. serialize(serializationObject: any): void;
  83151. /** @hidden */
  83152. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83153. /** Releases associated resources */
  83154. dispose(): void;
  83155. private static _HORIZONTAL_ALIGNMENT_LEFT;
  83156. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  83157. private static _HORIZONTAL_ALIGNMENT_CENTER;
  83158. private static _VERTICAL_ALIGNMENT_TOP;
  83159. private static _VERTICAL_ALIGNMENT_BOTTOM;
  83160. private static _VERTICAL_ALIGNMENT_CENTER;
  83161. /** HORIZONTAL_ALIGNMENT_LEFT */
  83162. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  83163. /** HORIZONTAL_ALIGNMENT_RIGHT */
  83164. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  83165. /** HORIZONTAL_ALIGNMENT_CENTER */
  83166. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  83167. /** VERTICAL_ALIGNMENT_TOP */
  83168. static get VERTICAL_ALIGNMENT_TOP(): number;
  83169. /** VERTICAL_ALIGNMENT_BOTTOM */
  83170. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  83171. /** VERTICAL_ALIGNMENT_CENTER */
  83172. static get VERTICAL_ALIGNMENT_CENTER(): number;
  83173. private static _FontHeightSizes;
  83174. /** @hidden */
  83175. static _GetFontOffset(font: string): {
  83176. ascent: number;
  83177. height: number;
  83178. descent: number;
  83179. };
  83180. /**
  83181. * Creates a Control from parsed data
  83182. * @param serializedObject defines parsed data
  83183. * @param host defines the hosting AdvancedDynamicTexture
  83184. * @returns a new Control
  83185. */
  83186. static Parse(serializedObject: any, host: AdvancedDynamicTexture): Control;
  83187. /**
  83188. * Creates a stack panel that can be used to render headers
  83189. * @param control defines the control to associate with the header
  83190. * @param text defines the text of the header
  83191. * @param size defines the size of the header
  83192. * @param options defines options used to configure the header
  83193. * @returns a new StackPanel
  83194. * @ignore
  83195. * @hidden
  83196. */
  83197. static AddHeader: (control: Control, text: string, size: string | number, options: {
  83198. isHorizontal: boolean;
  83199. controlFirst: boolean;
  83200. }) => any;
  83201. /** @hidden */
  83202. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  83203. }
  83204. }
  83205. declare module BABYLON.GUI {
  83206. /**
  83207. * Root class for 2D containers
  83208. * @see https://doc.babylonjs.com/how_to/gui#containers
  83209. */
  83210. export class Container extends Control {
  83211. name?: string | undefined;
  83212. /** @hidden */
  83213. _children: Control[];
  83214. /** @hidden */
  83215. protected _measureForChildren: Measure;
  83216. /** @hidden */
  83217. protected _background: string;
  83218. /** @hidden */
  83219. protected _adaptWidthToChildren: boolean;
  83220. /** @hidden */
  83221. protected _adaptHeightToChildren: boolean;
  83222. /**
  83223. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  83224. */
  83225. logLayoutCycleErrors: boolean;
  83226. /**
  83227. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  83228. */
  83229. maxLayoutCycle: number;
  83230. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  83231. get adaptHeightToChildren(): boolean;
  83232. set adaptHeightToChildren(value: boolean);
  83233. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  83234. get adaptWidthToChildren(): boolean;
  83235. set adaptWidthToChildren(value: boolean);
  83236. /** Gets or sets background color */
  83237. get background(): string;
  83238. set background(value: string);
  83239. /** Gets the list of children */
  83240. get children(): Control[];
  83241. /**
  83242. * Creates a new Container
  83243. * @param name defines the name of the container
  83244. */
  83245. constructor(name?: string | undefined);
  83246. protected _getTypeName(): string;
  83247. _flagDescendantsAsMatrixDirty(): void;
  83248. /**
  83249. * Gets a child using its name
  83250. * @param name defines the child name to look for
  83251. * @returns the child control if found
  83252. */
  83253. getChildByName(name: string): BABYLON.Nullable<Control>;
  83254. /**
  83255. * Gets a child using its type and its name
  83256. * @param name defines the child name to look for
  83257. * @param type defines the child type to look for
  83258. * @returns the child control if found
  83259. */
  83260. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  83261. /**
  83262. * Search for a specific control in children
  83263. * @param control defines the control to look for
  83264. * @returns true if the control is in child list
  83265. */
  83266. containsControl(control: Control): boolean;
  83267. /**
  83268. * Adds a new control to the current container
  83269. * @param control defines the control to add
  83270. * @returns the current container
  83271. */
  83272. addControl(control: BABYLON.Nullable<Control>): Container;
  83273. /**
  83274. * Removes all controls from the current container
  83275. * @returns the current container
  83276. */
  83277. clearControls(): Container;
  83278. /**
  83279. * Removes a control from the current container
  83280. * @param control defines the control to remove
  83281. * @returns the current container
  83282. */
  83283. removeControl(control: Control): Container;
  83284. /** @hidden */
  83285. _reOrderControl(control: Control): void;
  83286. /** @hidden */
  83287. _offsetLeft(offset: number): void;
  83288. /** @hidden */
  83289. _offsetTop(offset: number): void;
  83290. /** @hidden */
  83291. _markAllAsDirty(): void;
  83292. /** @hidden */
  83293. protected _localDraw(context: CanvasRenderingContext2D): void;
  83294. /** @hidden */
  83295. _link(host: AdvancedDynamicTexture): void;
  83296. /** @hidden */
  83297. protected _beforeLayout(): void;
  83298. /** @hidden */
  83299. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83300. /** @hidden */
  83301. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  83302. protected _postMeasure(): void;
  83303. /** @hidden */
  83304. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  83305. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  83306. /** @hidden */
  83307. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83308. /** @hidden */
  83309. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83310. /**
  83311. * Serializes the current control
  83312. * @param serializationObject defined the JSON serialized object
  83313. */
  83314. serialize(serializationObject: any): void;
  83315. /** Releases associated resources */
  83316. dispose(): void;
  83317. /** @hidden */
  83318. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83319. }
  83320. }
  83321. declare module BABYLON.GUI {
  83322. /** Class used to create rectangle container */
  83323. export class Rectangle extends Container {
  83324. name?: string | undefined;
  83325. private _thickness;
  83326. private _cornerRadius;
  83327. /** Gets or sets border thickness */
  83328. get thickness(): number;
  83329. set thickness(value: number);
  83330. /** Gets or sets the corner radius angle */
  83331. get cornerRadius(): number;
  83332. set cornerRadius(value: number);
  83333. /**
  83334. * Creates a new Rectangle
  83335. * @param name defines the control name
  83336. */
  83337. constructor(name?: string | undefined);
  83338. protected _getTypeName(): string;
  83339. protected _localDraw(context: CanvasRenderingContext2D): void;
  83340. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83341. private _drawRoundedRect;
  83342. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  83343. }
  83344. }
  83345. declare module BABYLON.GUI {
  83346. /**
  83347. * Enum that determines the text-wrapping mode to use.
  83348. */
  83349. export enum TextWrapping {
  83350. /**
  83351. * Clip the text when it's larger than Control.width; this is the default mode.
  83352. */
  83353. Clip = 0,
  83354. /**
  83355. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  83356. */
  83357. WordWrap = 1,
  83358. /**
  83359. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  83360. */
  83361. Ellipsis = 2
  83362. }
  83363. /**
  83364. * Class used to create text block control
  83365. */
  83366. export class TextBlock extends Control {
  83367. /**
  83368. * Defines the name of the control
  83369. */
  83370. name?: string | undefined;
  83371. private _text;
  83372. private _textWrapping;
  83373. private _textHorizontalAlignment;
  83374. private _textVerticalAlignment;
  83375. private _lines;
  83376. private _resizeToFit;
  83377. private _lineSpacing;
  83378. private _outlineWidth;
  83379. private _outlineColor;
  83380. private _underline;
  83381. private _lineThrough;
  83382. /**
  83383. * An event triggered after the text is changed
  83384. */
  83385. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  83386. /**
  83387. * An event triggered after the text was broken up into lines
  83388. */
  83389. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  83390. /**
  83391. * Function used to split a string into words. By default, a string is split at each space character found
  83392. */
  83393. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  83394. /**
  83395. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  83396. */
  83397. get lines(): any[];
  83398. /**
  83399. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83400. */
  83401. get resizeToFit(): boolean;
  83402. /**
  83403. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  83404. */
  83405. set resizeToFit(value: boolean);
  83406. /**
  83407. * Gets or sets a boolean indicating if text must be wrapped
  83408. */
  83409. get textWrapping(): TextWrapping | boolean;
  83410. /**
  83411. * Gets or sets a boolean indicating if text must be wrapped
  83412. */
  83413. set textWrapping(value: TextWrapping | boolean);
  83414. /**
  83415. * Gets or sets text to display
  83416. */
  83417. get text(): string;
  83418. /**
  83419. * Gets or sets text to display
  83420. */
  83421. set text(value: string);
  83422. /**
  83423. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83424. */
  83425. get textHorizontalAlignment(): number;
  83426. /**
  83427. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  83428. */
  83429. set textHorizontalAlignment(value: number);
  83430. /**
  83431. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83432. */
  83433. get textVerticalAlignment(): number;
  83434. /**
  83435. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  83436. */
  83437. set textVerticalAlignment(value: number);
  83438. /**
  83439. * Gets or sets line spacing value
  83440. */
  83441. set lineSpacing(value: string | number);
  83442. /**
  83443. * Gets or sets line spacing value
  83444. */
  83445. get lineSpacing(): string | number;
  83446. /**
  83447. * Gets or sets outlineWidth of the text to display
  83448. */
  83449. get outlineWidth(): number;
  83450. /**
  83451. * Gets or sets outlineWidth of the text to display
  83452. */
  83453. set outlineWidth(value: number);
  83454. /**
  83455. * Gets or sets a boolean indicating that text must have underline
  83456. */
  83457. get underline(): boolean;
  83458. /**
  83459. * Gets or sets a boolean indicating that text must have underline
  83460. */
  83461. set underline(value: boolean);
  83462. /**
  83463. * Gets or sets an boolean indicating that text must be crossed out
  83464. */
  83465. get lineThrough(): boolean;
  83466. /**
  83467. * Gets or sets an boolean indicating that text must be crossed out
  83468. */
  83469. set lineThrough(value: boolean);
  83470. /**
  83471. * Gets or sets outlineColor of the text to display
  83472. */
  83473. get outlineColor(): string;
  83474. /**
  83475. * Gets or sets outlineColor of the text to display
  83476. */
  83477. set outlineColor(value: string);
  83478. /**
  83479. * Creates a new TextBlock object
  83480. * @param name defines the name of the control
  83481. * @param text defines the text to display (emptry string by default)
  83482. */
  83483. constructor(
  83484. /**
  83485. * Defines the name of the control
  83486. */
  83487. name?: string | undefined, text?: string);
  83488. protected _getTypeName(): string;
  83489. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83490. private _drawText;
  83491. /** @hidden */
  83492. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83493. protected _applyStates(context: CanvasRenderingContext2D): void;
  83494. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  83495. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  83496. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  83497. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  83498. protected _renderLines(context: CanvasRenderingContext2D): void;
  83499. /**
  83500. * Given a width constraint applied on the text block, find the expected height
  83501. * @returns expected height
  83502. */
  83503. computeExpectedHeight(): number;
  83504. dispose(): void;
  83505. }
  83506. }
  83507. declare module BABYLON.GUI {
  83508. /**
  83509. * Class used to create 2D images
  83510. */
  83511. export class Image extends Control {
  83512. name?: string | undefined;
  83513. private _workingCanvas;
  83514. private _domImage;
  83515. private _imageWidth;
  83516. private _imageHeight;
  83517. private _loaded;
  83518. private _stretch;
  83519. private _source;
  83520. private _autoScale;
  83521. private _sourceLeft;
  83522. private _sourceTop;
  83523. private _sourceWidth;
  83524. private _sourceHeight;
  83525. private _svgAttributesComputationCompleted;
  83526. private _isSVG;
  83527. private _cellWidth;
  83528. private _cellHeight;
  83529. private _cellId;
  83530. private _populateNinePatchSlicesFromImage;
  83531. private _sliceLeft;
  83532. private _sliceRight;
  83533. private _sliceTop;
  83534. private _sliceBottom;
  83535. private _detectPointerOnOpaqueOnly;
  83536. private _imageDataCache;
  83537. /**
  83538. * BABYLON.Observable notified when the content is loaded
  83539. */
  83540. onImageLoadedObservable: BABYLON.Observable<Image>;
  83541. /**
  83542. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  83543. */
  83544. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  83545. /**
  83546. * Gets a boolean indicating that the content is loaded
  83547. */
  83548. get isLoaded(): boolean;
  83549. /**
  83550. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  83551. */
  83552. get populateNinePatchSlicesFromImage(): boolean;
  83553. set populateNinePatchSlicesFromImage(value: boolean);
  83554. /**
  83555. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  83556. * Beware using this as this will comsume more memory as the image has to be stored twice
  83557. */
  83558. get detectPointerOnOpaqueOnly(): boolean;
  83559. set detectPointerOnOpaqueOnly(value: boolean);
  83560. /**
  83561. * Gets or sets the left value for slicing (9-patch)
  83562. */
  83563. get sliceLeft(): number;
  83564. set sliceLeft(value: number);
  83565. /**
  83566. * Gets or sets the right value for slicing (9-patch)
  83567. */
  83568. get sliceRight(): number;
  83569. set sliceRight(value: number);
  83570. /**
  83571. * Gets or sets the top value for slicing (9-patch)
  83572. */
  83573. get sliceTop(): number;
  83574. set sliceTop(value: number);
  83575. /**
  83576. * Gets or sets the bottom value for slicing (9-patch)
  83577. */
  83578. get sliceBottom(): number;
  83579. set sliceBottom(value: number);
  83580. /**
  83581. * Gets or sets the left coordinate in the source image
  83582. */
  83583. get sourceLeft(): number;
  83584. set sourceLeft(value: number);
  83585. /**
  83586. * Gets or sets the top coordinate in the source image
  83587. */
  83588. get sourceTop(): number;
  83589. set sourceTop(value: number);
  83590. /**
  83591. * Gets or sets the width to capture in the source image
  83592. */
  83593. get sourceWidth(): number;
  83594. set sourceWidth(value: number);
  83595. /**
  83596. * Gets or sets the height to capture in the source image
  83597. */
  83598. get sourceHeight(): number;
  83599. set sourceHeight(value: number);
  83600. /** Indicates if the format of the image is SVG */
  83601. get isSVG(): boolean;
  83602. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  83603. get svgAttributesComputationCompleted(): boolean;
  83604. /**
  83605. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  83606. * @see https://doc.babylonjs.com/how_to/gui#image
  83607. */
  83608. get autoScale(): boolean;
  83609. set autoScale(value: boolean);
  83610. /** Gets or sets the streching mode used by the image */
  83611. get stretch(): number;
  83612. set stretch(value: number);
  83613. /** @hidden */
  83614. _rotate90(n: number, preserveProperties?: boolean): Image;
  83615. private _handleRotationForSVGImage;
  83616. private _rotate90SourceProperties;
  83617. /**
  83618. * Gets or sets the internal DOM image used to render the control
  83619. */
  83620. set domImage(value: HTMLImageElement);
  83621. get domImage(): HTMLImageElement;
  83622. private _onImageLoaded;
  83623. private _extractNinePatchSliceDataFromImage;
  83624. /**
  83625. * Gets the image source url
  83626. */
  83627. get source(): BABYLON.Nullable<string>;
  83628. /**
  83629. * Gets or sets image source url
  83630. */
  83631. set source(value: BABYLON.Nullable<string>);
  83632. /**
  83633. * Checks for svg document with icon id present
  83634. */
  83635. private _svgCheck;
  83636. /**
  83637. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  83638. * given external svg file and icon id
  83639. */
  83640. private _getSVGAttribs;
  83641. /**
  83642. * Gets or sets the cell width to use when animation sheet is enabled
  83643. * @see https://doc.babylonjs.com/how_to/gui#image
  83644. */
  83645. get cellWidth(): number;
  83646. set cellWidth(value: number);
  83647. /**
  83648. * Gets or sets the cell height to use when animation sheet is enabled
  83649. * @see https://doc.babylonjs.com/how_to/gui#image
  83650. */
  83651. get cellHeight(): number;
  83652. set cellHeight(value: number);
  83653. /**
  83654. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  83655. * @see https://doc.babylonjs.com/how_to/gui#image
  83656. */
  83657. get cellId(): number;
  83658. set cellId(value: number);
  83659. /**
  83660. * Creates a new Image
  83661. * @param name defines the control name
  83662. * @param url defines the image url
  83663. */
  83664. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  83665. /**
  83666. * Tests if a given coordinates belong to the current control
  83667. * @param x defines x coordinate to test
  83668. * @param y defines y coordinate to test
  83669. * @returns true if the coordinates are inside the control
  83670. */
  83671. contains(x: number, y: number): boolean;
  83672. protected _getTypeName(): string;
  83673. /** Force the control to synchronize with its content */
  83674. synchronizeSizeWithContent(): void;
  83675. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83676. private _prepareWorkingCanvasForOpaqueDetection;
  83677. private _drawImage;
  83678. _draw(context: CanvasRenderingContext2D): void;
  83679. private _renderCornerPatch;
  83680. private _renderNinePatch;
  83681. dispose(): void;
  83682. /** STRETCH_NONE */
  83683. static readonly STRETCH_NONE: number;
  83684. /** STRETCH_FILL */
  83685. static readonly STRETCH_FILL: number;
  83686. /** STRETCH_UNIFORM */
  83687. static readonly STRETCH_UNIFORM: number;
  83688. /** STRETCH_EXTEND */
  83689. static readonly STRETCH_EXTEND: number;
  83690. /** NINE_PATCH */
  83691. static readonly STRETCH_NINE_PATCH: number;
  83692. }
  83693. }
  83694. declare module BABYLON.GUI {
  83695. /**
  83696. * Class used to create 2D buttons
  83697. */
  83698. export class Button extends Rectangle {
  83699. name?: string | undefined;
  83700. /**
  83701. * Function called to generate a pointer enter animation
  83702. */
  83703. pointerEnterAnimation: () => void;
  83704. /**
  83705. * Function called to generate a pointer out animation
  83706. */
  83707. pointerOutAnimation: () => void;
  83708. /**
  83709. * Function called to generate a pointer down animation
  83710. */
  83711. pointerDownAnimation: () => void;
  83712. /**
  83713. * Function called to generate a pointer up animation
  83714. */
  83715. pointerUpAnimation: () => void;
  83716. /**
  83717. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  83718. */
  83719. delegatePickingToChildren: boolean;
  83720. private _image;
  83721. /**
  83722. * Returns the image part of the button (if any)
  83723. */
  83724. get image(): BABYLON.Nullable<Image>;
  83725. private _textBlock;
  83726. /**
  83727. * Returns the image part of the button (if any)
  83728. */
  83729. get textBlock(): BABYLON.Nullable<TextBlock>;
  83730. /**
  83731. * Creates a new Button
  83732. * @param name defines the name of the button
  83733. */
  83734. constructor(name?: string | undefined);
  83735. protected _getTypeName(): string;
  83736. /** @hidden */
  83737. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  83738. /** @hidden */
  83739. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  83740. /** @hidden */
  83741. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  83742. /** @hidden */
  83743. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83744. /** @hidden */
  83745. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  83746. /**
  83747. * Creates a new button made with an image and a text
  83748. * @param name defines the name of the button
  83749. * @param text defines the text of the button
  83750. * @param imageUrl defines the url of the image
  83751. * @returns a new Button
  83752. */
  83753. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  83754. /**
  83755. * Creates a new button made with an image
  83756. * @param name defines the name of the button
  83757. * @param imageUrl defines the url of the image
  83758. * @returns a new Button
  83759. */
  83760. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  83761. /**
  83762. * Creates a new button made with a text
  83763. * @param name defines the name of the button
  83764. * @param text defines the text of the button
  83765. * @returns a new Button
  83766. */
  83767. static CreateSimpleButton(name: string, text: string): Button;
  83768. /**
  83769. * Creates a new button made with an image and a centered text
  83770. * @param name defines the name of the button
  83771. * @param text defines the text of the button
  83772. * @param imageUrl defines the url of the image
  83773. * @returns a new Button
  83774. */
  83775. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  83776. }
  83777. }
  83778. declare module BABYLON.GUI {
  83779. /**
  83780. * Class used to create a 2D stack panel container
  83781. */
  83782. export class StackPanel extends Container {
  83783. name?: string | undefined;
  83784. private _isVertical;
  83785. private _manualWidth;
  83786. private _manualHeight;
  83787. private _doNotTrackManualChanges;
  83788. /**
  83789. * Gets or sets a boolean indicating that layou warnings should be ignored
  83790. */
  83791. ignoreLayoutWarnings: boolean;
  83792. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  83793. get isVertical(): boolean;
  83794. set isVertical(value: boolean);
  83795. /**
  83796. * Gets or sets panel width.
  83797. * This value should not be set when in horizontal mode as it will be computed automatically
  83798. */
  83799. set width(value: string | number);
  83800. get width(): string | number;
  83801. /**
  83802. * Gets or sets panel height.
  83803. * This value should not be set when in vertical mode as it will be computed automatically
  83804. */
  83805. set height(value: string | number);
  83806. get height(): string | number;
  83807. /**
  83808. * Creates a new StackPanel
  83809. * @param name defines control name
  83810. */
  83811. constructor(name?: string | undefined);
  83812. protected _getTypeName(): string;
  83813. /** @hidden */
  83814. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83815. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  83816. protected _postMeasure(): void;
  83817. /**
  83818. * Serializes the current control
  83819. * @param serializationObject defined the JSON serialized object
  83820. */
  83821. serialize(serializationObject: any): void;
  83822. /** @hidden */
  83823. _parseFromContent(serializedObject: any, host: AdvancedDynamicTexture): void;
  83824. }
  83825. }
  83826. declare module BABYLON.GUI {
  83827. /**
  83828. * Class used to represent a 2D checkbox
  83829. */
  83830. export class Checkbox extends Control {
  83831. name?: string | undefined;
  83832. private _isChecked;
  83833. private _background;
  83834. private _checkSizeRatio;
  83835. private _thickness;
  83836. /** Gets or sets border thickness */
  83837. get thickness(): number;
  83838. set thickness(value: number);
  83839. /**
  83840. * BABYLON.Observable raised when isChecked property changes
  83841. */
  83842. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  83843. /** Gets or sets a value indicating the ratio between overall size and check size */
  83844. get checkSizeRatio(): number;
  83845. set checkSizeRatio(value: number);
  83846. /** Gets or sets background color */
  83847. get background(): string;
  83848. set background(value: string);
  83849. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  83850. get isChecked(): boolean;
  83851. set isChecked(value: boolean);
  83852. /**
  83853. * Creates a new CheckBox
  83854. * @param name defines the control name
  83855. */
  83856. constructor(name?: string | undefined);
  83857. protected _getTypeName(): string;
  83858. /** @hidden */
  83859. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  83860. /** @hidden */
  83861. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  83862. /**
  83863. * Utility function to easily create a checkbox with a header
  83864. * @param title defines the label to use for the header
  83865. * @param onValueChanged defines the callback to call when value changes
  83866. * @returns a StackPanel containing the checkbox and a textBlock
  83867. */
  83868. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  83869. }
  83870. }
  83871. declare module BABYLON.GUI {
  83872. /**
  83873. * Class used to store key control properties
  83874. */
  83875. export class KeyPropertySet {
  83876. /** Width */
  83877. width?: string;
  83878. /** Height */
  83879. height?: string;
  83880. /** Left padding */
  83881. paddingLeft?: string;
  83882. /** Right padding */
  83883. paddingRight?: string;
  83884. /** Top padding */
  83885. paddingTop?: string;
  83886. /** Bottom padding */
  83887. paddingBottom?: string;
  83888. /** Foreground color */
  83889. color?: string;
  83890. /** Background color */
  83891. background?: string;
  83892. }
  83893. /**
  83894. * Class used to create virtual keyboard
  83895. */
  83896. export class VirtualKeyboard extends StackPanel {
  83897. /** BABYLON.Observable raised when a key is pressed */
  83898. onKeyPressObservable: BABYLON.Observable<string>;
  83899. /** Gets or sets default key button width */
  83900. defaultButtonWidth: string;
  83901. /** Gets or sets default key button height */
  83902. defaultButtonHeight: string;
  83903. /** Gets or sets default key button left padding */
  83904. defaultButtonPaddingLeft: string;
  83905. /** Gets or sets default key button right padding */
  83906. defaultButtonPaddingRight: string;
  83907. /** Gets or sets default key button top padding */
  83908. defaultButtonPaddingTop: string;
  83909. /** Gets or sets default key button bottom padding */
  83910. defaultButtonPaddingBottom: string;
  83911. /** Gets or sets default key button foreground color */
  83912. defaultButtonColor: string;
  83913. /** Gets or sets default key button background color */
  83914. defaultButtonBackground: string;
  83915. /** Gets or sets shift button foreground color */
  83916. shiftButtonColor: string;
  83917. /** Gets or sets shift button thickness*/
  83918. selectedShiftThickness: number;
  83919. /** Gets shift key state */
  83920. shiftState: number;
  83921. protected _getTypeName(): string;
  83922. private _createKey;
  83923. /**
  83924. * Adds a new row of keys
  83925. * @param keys defines the list of keys to add
  83926. * @param propertySets defines the associated property sets
  83927. */
  83928. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  83929. /**
  83930. * Set the shift key to a specific state
  83931. * @param shiftState defines the new shift state
  83932. */
  83933. applyShiftState(shiftState: number): void;
  83934. private _currentlyConnectedInputText;
  83935. private _connectedInputTexts;
  83936. private _onKeyPressObserver;
  83937. /** Gets the input text control currently attached to the keyboard */
  83938. get connectedInputText(): BABYLON.Nullable<InputText>;
  83939. /**
  83940. * Connects the keyboard with an input text control
  83941. *
  83942. * @param input defines the target control
  83943. */
  83944. connect(input: InputText): void;
  83945. /**
  83946. * Disconnects the keyboard from connected InputText controls
  83947. *
  83948. * @param input optionally defines a target control, otherwise all are disconnected
  83949. */
  83950. disconnect(input?: InputText): void;
  83951. private _removeConnectedInputObservables;
  83952. /**
  83953. * Release all resources
  83954. */
  83955. dispose(): void;
  83956. /**
  83957. * Creates a new keyboard using a default layout
  83958. *
  83959. * @param name defines control name
  83960. * @returns a new VirtualKeyboard
  83961. */
  83962. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  83963. }
  83964. }
  83965. declare module BABYLON.GUI {
  83966. /** @hidden */
  83967. export class TextWrapper {
  83968. private _text;
  83969. private _characters;
  83970. get text(): string;
  83971. set text(txt: string);
  83972. get length(): number;
  83973. removePart(idxStart: number, idxEnd: number, insertTxt?: string): void;
  83974. charAt(idx: number): string;
  83975. substr(from: number, length?: number): string;
  83976. substring(from: number, to?: number): string;
  83977. isWord(index: number): boolean;
  83978. }
  83979. }
  83980. declare module BABYLON.GUI {
  83981. /**
  83982. * Class used to create input text control
  83983. */
  83984. export class InputText extends Control implements IFocusableControl {
  83985. name?: string | undefined;
  83986. private _textWrapper;
  83987. private _placeholderText;
  83988. private _background;
  83989. private _focusedBackground;
  83990. private _focusedColor;
  83991. private _placeholderColor;
  83992. private _thickness;
  83993. private _margin;
  83994. private _autoStretchWidth;
  83995. private _maxWidth;
  83996. private _isFocused;
  83997. private _blinkTimeout;
  83998. private _blinkIsEven;
  83999. private _cursorOffset;
  84000. private _scrollLeft;
  84001. private _textWidth;
  84002. private _clickedCoordinate;
  84003. private _deadKey;
  84004. private _addKey;
  84005. private _currentKey;
  84006. private _isTextHighlightOn;
  84007. private _textHighlightColor;
  84008. private _highligherOpacity;
  84009. private _highlightedText;
  84010. private _startHighlightIndex;
  84011. private _endHighlightIndex;
  84012. private _cursorIndex;
  84013. private _onFocusSelectAll;
  84014. private _isPointerDown;
  84015. private _onClipboardObserver;
  84016. private _onPointerDblTapObserver;
  84017. /** @hidden */
  84018. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  84019. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  84020. promptMessage: string;
  84021. /** Force disable prompt on mobile device */
  84022. disableMobilePrompt: boolean;
  84023. /** BABYLON.Observable raised when the text changes */
  84024. onTextChangedObservable: BABYLON.Observable<InputText>;
  84025. /** BABYLON.Observable raised just before an entered character is to be added */
  84026. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  84027. /** BABYLON.Observable raised when the control gets the focus */
  84028. onFocusObservable: BABYLON.Observable<InputText>;
  84029. /** BABYLON.Observable raised when the control loses the focus */
  84030. onBlurObservable: BABYLON.Observable<InputText>;
  84031. /**Observable raised when the text is highlighted */
  84032. onTextHighlightObservable: BABYLON.Observable<InputText>;
  84033. /**Observable raised when copy event is triggered */
  84034. onTextCopyObservable: BABYLON.Observable<InputText>;
  84035. /** BABYLON.Observable raised when cut event is triggered */
  84036. onTextCutObservable: BABYLON.Observable<InputText>;
  84037. /** BABYLON.Observable raised when paste event is triggered */
  84038. onTextPasteObservable: BABYLON.Observable<InputText>;
  84039. /** BABYLON.Observable raised when a key event was processed */
  84040. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84041. /** Gets or sets the maximum width allowed by the control */
  84042. get maxWidth(): string | number;
  84043. /** Gets the maximum width allowed by the control in pixels */
  84044. get maxWidthInPixels(): number;
  84045. set maxWidth(value: string | number);
  84046. /** Gets or sets the text highlighter transparency; default: 0.4 */
  84047. get highligherOpacity(): number;
  84048. set highligherOpacity(value: number);
  84049. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  84050. get onFocusSelectAll(): boolean;
  84051. set onFocusSelectAll(value: boolean);
  84052. /** Gets or sets the text hightlight color */
  84053. get textHighlightColor(): string;
  84054. set textHighlightColor(value: string);
  84055. /** Gets or sets control margin */
  84056. get margin(): string;
  84057. /** Gets control margin in pixels */
  84058. get marginInPixels(): number;
  84059. set margin(value: string);
  84060. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  84061. get autoStretchWidth(): boolean;
  84062. set autoStretchWidth(value: boolean);
  84063. /** Gets or sets border thickness */
  84064. get thickness(): number;
  84065. set thickness(value: number);
  84066. /** Gets or sets the background color when focused */
  84067. get focusedBackground(): string;
  84068. set focusedBackground(value: string);
  84069. /** Gets or sets the background color when focused */
  84070. get focusedColor(): string;
  84071. set focusedColor(value: string);
  84072. /** Gets or sets the background color */
  84073. get background(): string;
  84074. set background(value: string);
  84075. /** Gets or sets the placeholder color */
  84076. get placeholderColor(): string;
  84077. set placeholderColor(value: string);
  84078. /** Gets or sets the text displayed when the control is empty */
  84079. get placeholderText(): string;
  84080. set placeholderText(value: string);
  84081. /** Gets or sets the dead key flag */
  84082. get deadKey(): boolean;
  84083. set deadKey(flag: boolean);
  84084. /** Gets or sets the highlight text */
  84085. get highlightedText(): string;
  84086. set highlightedText(text: string);
  84087. /** Gets or sets if the current key should be added */
  84088. get addKey(): boolean;
  84089. set addKey(flag: boolean);
  84090. /** Gets or sets the value of the current key being entered */
  84091. get currentKey(): string;
  84092. set currentKey(key: string);
  84093. /** Gets or sets the text displayed in the control */
  84094. get text(): string;
  84095. set text(value: string);
  84096. private _textHasChanged;
  84097. /** Gets or sets control width */
  84098. get width(): string | number;
  84099. set width(value: string | number);
  84100. /**
  84101. * Creates a new InputText
  84102. * @param name defines the control name
  84103. * @param text defines the text of the control
  84104. */
  84105. constructor(name?: string | undefined, text?: string);
  84106. /** @hidden */
  84107. onBlur(): void;
  84108. /** @hidden */
  84109. onFocus(): void;
  84110. /**
  84111. * Function to focus an inputText programmatically
  84112. */
  84113. focus(): void;
  84114. /**
  84115. * Function to unfocus an inputText programmatically
  84116. */
  84117. blur(): void;
  84118. protected _getTypeName(): string;
  84119. /**
  84120. * Function called to get the list of controls that should not steal the focus from this control
  84121. * @returns an array of controls
  84122. */
  84123. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84124. /** @hidden */
  84125. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  84126. /** @hidden */
  84127. private _updateValueFromCursorIndex;
  84128. /** @hidden */
  84129. private _processDblClick;
  84130. /** @hidden */
  84131. private _selectAllText;
  84132. /**
  84133. * Handles the keyboard event
  84134. * @param evt Defines the KeyboardEvent
  84135. */
  84136. processKeyboard(evt: KeyboardEvent): void;
  84137. /** @hidden */
  84138. private _onCopyText;
  84139. /** @hidden */
  84140. private _onCutText;
  84141. /** @hidden */
  84142. private _onPasteText;
  84143. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84144. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84145. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84146. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84147. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84148. dispose(): void;
  84149. }
  84150. }
  84151. declare module BABYLON.GUI {
  84152. /**
  84153. * Class used to create a 2D grid container
  84154. */
  84155. export class Grid extends Container {
  84156. name?: string | undefined;
  84157. private _rowDefinitions;
  84158. private _columnDefinitions;
  84159. private _cells;
  84160. private _childControls;
  84161. /**
  84162. * Gets the number of columns
  84163. */
  84164. get columnCount(): number;
  84165. /**
  84166. * Gets the number of rows
  84167. */
  84168. get rowCount(): number;
  84169. /** Gets the list of children */
  84170. get children(): Control[];
  84171. /** Gets the list of cells (e.g. the containers) */
  84172. get cells(): {
  84173. [key: string]: Container;
  84174. };
  84175. /**
  84176. * Gets the definition of a specific row
  84177. * @param index defines the index of the row
  84178. * @returns the row definition
  84179. */
  84180. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84181. /**
  84182. * Gets the definition of a specific column
  84183. * @param index defines the index of the column
  84184. * @returns the column definition
  84185. */
  84186. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  84187. /**
  84188. * Adds a new row to the grid
  84189. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84190. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  84191. * @returns the current grid
  84192. */
  84193. addRowDefinition(height: number, isPixel?: boolean): Grid;
  84194. /**
  84195. * Adds a new column to the grid
  84196. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84197. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84198. * @returns the current grid
  84199. */
  84200. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  84201. /**
  84202. * Update a row definition
  84203. * @param index defines the index of the row to update
  84204. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  84205. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  84206. * @returns the current grid
  84207. */
  84208. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  84209. /**
  84210. * Update a column definition
  84211. * @param index defines the index of the column to update
  84212. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  84213. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  84214. * @returns the current grid
  84215. */
  84216. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  84217. /**
  84218. * Gets the list of children stored in a specific cell
  84219. * @param row defines the row to check
  84220. * @param column defines the column to check
  84221. * @returns the list of controls
  84222. */
  84223. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  84224. /**
  84225. * Gets a string representing the child cell info (row x column)
  84226. * @param child defines the control to get info from
  84227. * @returns a string containing the child cell info (row x column)
  84228. */
  84229. getChildCellInfo(child: Control): string;
  84230. private _removeCell;
  84231. private _offsetCell;
  84232. /**
  84233. * Remove a column definition at specified index
  84234. * @param index defines the index of the column to remove
  84235. * @returns the current grid
  84236. */
  84237. removeColumnDefinition(index: number): Grid;
  84238. /**
  84239. * Remove a row definition at specified index
  84240. * @param index defines the index of the row to remove
  84241. * @returns the current grid
  84242. */
  84243. removeRowDefinition(index: number): Grid;
  84244. /**
  84245. * Adds a new control to the current grid
  84246. * @param control defines the control to add
  84247. * @param row defines the row where to add the control (0 by default)
  84248. * @param column defines the column where to add the control (0 by default)
  84249. * @returns the current grid
  84250. */
  84251. addControl(control: Control, row?: number, column?: number): Grid;
  84252. /**
  84253. * Removes a control from the current container
  84254. * @param control defines the control to remove
  84255. * @returns the current container
  84256. */
  84257. removeControl(control: Control): Container;
  84258. /**
  84259. * Creates a new Grid
  84260. * @param name defines control name
  84261. */
  84262. constructor(name?: string | undefined);
  84263. protected _getTypeName(): string;
  84264. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  84265. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84266. _flagDescendantsAsMatrixDirty(): void;
  84267. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  84268. /** Releases associated resources */
  84269. dispose(): void;
  84270. }
  84271. }
  84272. declare module BABYLON.GUI {
  84273. /** Class used to create color pickers */
  84274. export class ColorPicker extends Control {
  84275. name?: string | undefined;
  84276. private static _Epsilon;
  84277. private _colorWheelCanvas;
  84278. private _value;
  84279. private _tmpColor;
  84280. private _pointerStartedOnSquare;
  84281. private _pointerStartedOnWheel;
  84282. private _squareLeft;
  84283. private _squareTop;
  84284. private _squareSize;
  84285. private _h;
  84286. private _s;
  84287. private _v;
  84288. private _lastPointerDownID;
  84289. /**
  84290. * BABYLON.Observable raised when the value changes
  84291. */
  84292. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  84293. /** Gets or sets the color of the color picker */
  84294. get value(): BABYLON.Color3;
  84295. set value(value: BABYLON.Color3);
  84296. /**
  84297. * Gets or sets control width
  84298. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84299. */
  84300. get width(): string | number;
  84301. set width(value: string | number);
  84302. /**
  84303. * Gets or sets control height
  84304. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  84305. */
  84306. get height(): string | number;
  84307. /** Gets or sets control height */
  84308. set height(value: string | number);
  84309. /** Gets or sets control size */
  84310. get size(): string | number;
  84311. set size(value: string | number);
  84312. /**
  84313. * Creates a new ColorPicker
  84314. * @param name defines the control name
  84315. */
  84316. constructor(name?: string | undefined);
  84317. protected _getTypeName(): string;
  84318. /** @hidden */
  84319. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84320. private _updateSquareProps;
  84321. private _drawGradientSquare;
  84322. private _drawCircle;
  84323. private _createColorWheelCanvas;
  84324. /** @hidden */
  84325. _draw(context: CanvasRenderingContext2D): void;
  84326. private _pointerIsDown;
  84327. private _updateValueFromPointer;
  84328. private _isPointOnSquare;
  84329. private _isPointOnWheel;
  84330. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84331. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84332. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  84333. _onCanvasBlur(): void;
  84334. /**
  84335. * This function expands the color picker by creating a color picker dialog with manual
  84336. * color value input and the ability to save colors into an array to be used later in
  84337. * subsequent launches of the dialogue.
  84338. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  84339. * @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.
  84340. * @returns picked color as a hex string and the saved colors array as hex strings.
  84341. */
  84342. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  84343. pickerWidth?: string;
  84344. pickerHeight?: string;
  84345. headerHeight?: string;
  84346. lastColor?: string;
  84347. swatchLimit?: number;
  84348. numSwatchesPerLine?: number;
  84349. savedColors?: Array<string>;
  84350. }): Promise<{
  84351. savedColors?: string[];
  84352. pickedColor: string;
  84353. }>;
  84354. }
  84355. }
  84356. declare module BABYLON.GUI {
  84357. /** Class used to create 2D ellipse containers */
  84358. export class Ellipse extends Container {
  84359. name?: string | undefined;
  84360. private _thickness;
  84361. /** Gets or sets border thickness */
  84362. get thickness(): number;
  84363. set thickness(value: number);
  84364. /**
  84365. * Creates a new Ellipse
  84366. * @param name defines the control name
  84367. */
  84368. constructor(name?: string | undefined);
  84369. protected _getTypeName(): string;
  84370. protected _localDraw(context: CanvasRenderingContext2D): void;
  84371. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84372. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  84373. }
  84374. }
  84375. declare module BABYLON.GUI {
  84376. /**
  84377. * Class used to create a focusable button that can easily handle keyboard events
  84378. */
  84379. export class FocusableButton extends Button implements IFocusableControl {
  84380. name?: string | undefined;
  84381. /** Highlight color when button is focused */
  84382. focusedColor: BABYLON.Nullable<string>;
  84383. private _isFocused;
  84384. private _unfocusedColor;
  84385. /** BABYLON.Observable raised when the control gets the focus */
  84386. onFocusObservable: BABYLON.Observable<Button>;
  84387. /** BABYLON.Observable raised when the control loses the focus */
  84388. onBlurObservable: BABYLON.Observable<Button>;
  84389. /** BABYLON.Observable raised when a key event was processed */
  84390. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  84391. constructor(name?: string | undefined);
  84392. /** @hidden */
  84393. onBlur(): void;
  84394. /** @hidden */
  84395. onFocus(): void;
  84396. /**
  84397. * Function called to get the list of controls that should not steal the focus from this control
  84398. * @returns an array of controls
  84399. */
  84400. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  84401. /**
  84402. * Function to focus a button programmatically
  84403. */
  84404. focus(): void;
  84405. /**
  84406. * Function to unfocus a button programmatically
  84407. */
  84408. blur(): void;
  84409. /**
  84410. * Handles the keyboard event
  84411. * @param evt Defines the KeyboardEvent
  84412. */
  84413. processKeyboard(evt: KeyboardEvent): void;
  84414. /** @hidden */
  84415. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84416. /** @hidden */
  84417. displose(): void;
  84418. }
  84419. }
  84420. declare module BABYLON.GUI {
  84421. /**
  84422. * Class used to create a password control
  84423. */
  84424. export class InputPassword extends InputText {
  84425. protected _beforeRenderText(textWrapper: TextWrapper): TextWrapper;
  84426. }
  84427. }
  84428. declare module BABYLON.GUI {
  84429. /** Class used to render 2D lines */
  84430. export class Line extends Control {
  84431. name?: string | undefined;
  84432. private _lineWidth;
  84433. private _x1;
  84434. private _y1;
  84435. private _x2;
  84436. private _y2;
  84437. private _dash;
  84438. private _connectedControl;
  84439. private _connectedControlDirtyObserver;
  84440. /** Gets or sets the dash pattern */
  84441. get dash(): Array<number>;
  84442. set dash(value: Array<number>);
  84443. /** Gets or sets the control connected with the line end */
  84444. get connectedControl(): Control;
  84445. set connectedControl(value: Control);
  84446. /** Gets or sets start coordinates on X axis */
  84447. get x1(): string | number;
  84448. set x1(value: string | number);
  84449. /** Gets or sets start coordinates on Y axis */
  84450. get y1(): string | number;
  84451. set y1(value: string | number);
  84452. /** Gets or sets end coordinates on X axis */
  84453. get x2(): string | number;
  84454. set x2(value: string | number);
  84455. /** Gets or sets end coordinates on Y axis */
  84456. get y2(): string | number;
  84457. set y2(value: string | number);
  84458. /** Gets or sets line width */
  84459. get lineWidth(): number;
  84460. set lineWidth(value: number);
  84461. /** Gets or sets horizontal alignment */
  84462. set horizontalAlignment(value: number);
  84463. /** Gets or sets vertical alignment */
  84464. set verticalAlignment(value: number);
  84465. private get _effectiveX2();
  84466. private get _effectiveY2();
  84467. /**
  84468. * Creates a new Line
  84469. * @param name defines the control name
  84470. */
  84471. constructor(name?: string | undefined);
  84472. protected _getTypeName(): string;
  84473. _draw(context: CanvasRenderingContext2D): void;
  84474. _measure(): void;
  84475. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84476. /**
  84477. * Move one end of the line given 3D cartesian coordinates.
  84478. * @param position Targeted world position
  84479. * @param scene BABYLON.Scene
  84480. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84481. */
  84482. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  84483. /**
  84484. * Move one end of the line to a position in screen absolute space.
  84485. * @param projectedPosition Position in screen absolute space (X, Y)
  84486. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  84487. */
  84488. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  84489. }
  84490. }
  84491. declare module BABYLON.GUI {
  84492. /**
  84493. * Class used to store a point for a MultiLine object.
  84494. * The point can be pure 2D coordinates, a mesh or a control
  84495. */
  84496. export class MultiLinePoint {
  84497. private _multiLine;
  84498. private _x;
  84499. private _y;
  84500. private _control;
  84501. private _mesh;
  84502. private _controlObserver;
  84503. private _meshObserver;
  84504. /** @hidden */
  84505. _point: BABYLON.Vector3;
  84506. /**
  84507. * Creates a new MultiLinePoint
  84508. * @param multiLine defines the source MultiLine object
  84509. */
  84510. constructor(multiLine: MultiLine);
  84511. /** Gets or sets x coordinate */
  84512. get x(): string | number;
  84513. set x(value: string | number);
  84514. /** Gets or sets y coordinate */
  84515. get y(): string | number;
  84516. set y(value: string | number);
  84517. /** Gets or sets the control associated with this point */
  84518. get control(): BABYLON.Nullable<Control>;
  84519. set control(value: BABYLON.Nullable<Control>);
  84520. /** Gets or sets the mesh associated with this point */
  84521. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  84522. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  84523. /** Resets links */
  84524. resetLinks(): void;
  84525. /**
  84526. * Gets a translation vector with Z component
  84527. * @returns the translation vector
  84528. */
  84529. translate(): BABYLON.Vector3;
  84530. private _translatePoint;
  84531. /** Release associated resources */
  84532. dispose(): void;
  84533. }
  84534. }
  84535. declare module BABYLON.GUI {
  84536. /**
  84537. * Class used to create multi line control
  84538. */
  84539. export class MultiLine extends Control {
  84540. name?: string | undefined;
  84541. private _lineWidth;
  84542. private _dash;
  84543. private _points;
  84544. private _minX;
  84545. private _minY;
  84546. private _maxX;
  84547. private _maxY;
  84548. /**
  84549. * Creates a new MultiLine
  84550. * @param name defines the control name
  84551. */
  84552. constructor(name?: string | undefined);
  84553. /** Gets or sets dash pattern */
  84554. get dash(): Array<number>;
  84555. set dash(value: Array<number>);
  84556. /**
  84557. * Gets point stored at specified index
  84558. * @param index defines the index to look for
  84559. * @returns the requested point if found
  84560. */
  84561. getAt(index: number): MultiLinePoint;
  84562. /** Function called when a point is updated */
  84563. onPointUpdate: () => void;
  84564. /**
  84565. * Adds new points to the point collection
  84566. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  84567. * @returns the list of created MultiLinePoint
  84568. */
  84569. add(...items: (AbstractMesh | Control | {
  84570. x: string | number;
  84571. y: string | number;
  84572. })[]): MultiLinePoint[];
  84573. /**
  84574. * Adds a new point to the point collection
  84575. * @param item defines the item (mesh, control or 2d coordiantes) to add
  84576. * @returns the created MultiLinePoint
  84577. */
  84578. push(item?: (AbstractMesh | Control | {
  84579. x: string | number;
  84580. y: string | number;
  84581. })): MultiLinePoint;
  84582. /**
  84583. * Remove a specific value or point from the active point collection
  84584. * @param value defines the value or point to remove
  84585. */
  84586. remove(value: number | MultiLinePoint): void;
  84587. /**
  84588. * Resets this object to initial state (no point)
  84589. */
  84590. reset(): void;
  84591. /**
  84592. * Resets all links
  84593. */
  84594. resetLinks(): void;
  84595. /** Gets or sets line width */
  84596. get lineWidth(): number;
  84597. set lineWidth(value: number);
  84598. set horizontalAlignment(value: number);
  84599. set verticalAlignment(value: number);
  84600. protected _getTypeName(): string;
  84601. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84602. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84603. _measure(): void;
  84604. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  84605. dispose(): void;
  84606. }
  84607. }
  84608. declare module BABYLON.GUI {
  84609. /**
  84610. * Class used to create radio button controls
  84611. */
  84612. export class RadioButton extends Control {
  84613. name?: string | undefined;
  84614. private _isChecked;
  84615. private _background;
  84616. private _checkSizeRatio;
  84617. private _thickness;
  84618. /** Gets or sets border thickness */
  84619. get thickness(): number;
  84620. set thickness(value: number);
  84621. /** Gets or sets group name */
  84622. group: string;
  84623. /** BABYLON.Observable raised when isChecked is changed */
  84624. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  84625. /** Gets or sets a value indicating the ratio between overall size and check size */
  84626. get checkSizeRatio(): number;
  84627. set checkSizeRatio(value: number);
  84628. /** Gets or sets background color */
  84629. get background(): string;
  84630. set background(value: string);
  84631. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  84632. get isChecked(): boolean;
  84633. set isChecked(value: boolean);
  84634. /**
  84635. * Creates a new RadioButton
  84636. * @param name defines the control name
  84637. */
  84638. constructor(name?: string | undefined);
  84639. protected _getTypeName(): string;
  84640. _draw(context: CanvasRenderingContext2D): void;
  84641. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84642. /**
  84643. * Utility function to easily create a radio button with a header
  84644. * @param title defines the label to use for the header
  84645. * @param group defines the group to use for the radio button
  84646. * @param isChecked defines the initial state of the radio button
  84647. * @param onValueChanged defines the callback to call when value changes
  84648. * @returns a StackPanel containing the radio button and a textBlock
  84649. */
  84650. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  84651. }
  84652. }
  84653. declare module BABYLON.GUI {
  84654. /**
  84655. * Class used to create slider controls
  84656. */
  84657. export class BaseSlider extends Control {
  84658. name?: string | undefined;
  84659. protected _thumbWidth: ValueAndUnit;
  84660. private _minimum;
  84661. private _maximum;
  84662. private _value;
  84663. private _isVertical;
  84664. protected _barOffset: ValueAndUnit;
  84665. private _isThumbClamped;
  84666. protected _displayThumb: boolean;
  84667. private _step;
  84668. private _lastPointerDownID;
  84669. protected _effectiveBarOffset: number;
  84670. protected _renderLeft: number;
  84671. protected _renderTop: number;
  84672. protected _renderWidth: number;
  84673. protected _renderHeight: number;
  84674. protected _backgroundBoxLength: number;
  84675. protected _backgroundBoxThickness: number;
  84676. protected _effectiveThumbThickness: number;
  84677. /** BABYLON.Observable raised when the sldier value changes */
  84678. onValueChangedObservable: BABYLON.Observable<number>;
  84679. /** Gets or sets a boolean indicating if the thumb must be rendered */
  84680. get displayThumb(): boolean;
  84681. set displayThumb(value: boolean);
  84682. /** Gets or sets a step to apply to values (0 by default) */
  84683. get step(): number;
  84684. set step(value: number);
  84685. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  84686. get barOffset(): string | number;
  84687. /** Gets main bar offset in pixels*/
  84688. get barOffsetInPixels(): number;
  84689. set barOffset(value: string | number);
  84690. /** Gets or sets thumb width */
  84691. get thumbWidth(): string | number;
  84692. /** Gets thumb width in pixels */
  84693. get thumbWidthInPixels(): number;
  84694. set thumbWidth(value: string | number);
  84695. /** Gets or sets minimum value */
  84696. get minimum(): number;
  84697. set minimum(value: number);
  84698. /** Gets or sets maximum value */
  84699. get maximum(): number;
  84700. set maximum(value: number);
  84701. /** Gets or sets current value */
  84702. get value(): number;
  84703. set value(value: number);
  84704. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  84705. get isVertical(): boolean;
  84706. set isVertical(value: boolean);
  84707. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  84708. get isThumbClamped(): boolean;
  84709. set isThumbClamped(value: boolean);
  84710. /**
  84711. * Creates a new BaseSlider
  84712. * @param name defines the control name
  84713. */
  84714. constructor(name?: string | undefined);
  84715. protected _getTypeName(): string;
  84716. protected _getThumbPosition(): number;
  84717. protected _getThumbThickness(type: string): number;
  84718. protected _prepareRenderingData(type: string): void;
  84719. private _pointerIsDown;
  84720. /** @hidden */
  84721. protected _updateValueFromPointer(x: number, y: number): void;
  84722. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  84723. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  84724. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  84725. _onCanvasBlur(): void;
  84726. }
  84727. }
  84728. declare module BABYLON.GUI {
  84729. /**
  84730. * Class used to create slider controls
  84731. */
  84732. export class Slider extends BaseSlider {
  84733. name?: string | undefined;
  84734. private _background;
  84735. private _borderColor;
  84736. private _thumbColor;
  84737. private _isThumbCircle;
  84738. protected _displayValueBar: boolean;
  84739. /** Gets or sets a boolean indicating if the value bar must be rendered */
  84740. get displayValueBar(): boolean;
  84741. set displayValueBar(value: boolean);
  84742. /** Gets or sets border color */
  84743. get borderColor(): string;
  84744. set borderColor(value: string);
  84745. /** Gets or sets background color */
  84746. get background(): string;
  84747. set background(value: string);
  84748. /** Gets or sets thumb's color */
  84749. get thumbColor(): string;
  84750. set thumbColor(value: string);
  84751. /** Gets or sets a boolean indicating if the thumb should be round or square */
  84752. get isThumbCircle(): boolean;
  84753. set isThumbCircle(value: boolean);
  84754. /**
  84755. * Creates a new Slider
  84756. * @param name defines the control name
  84757. */
  84758. constructor(name?: string | undefined);
  84759. protected _getTypeName(): string;
  84760. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  84761. }
  84762. }
  84763. declare module BABYLON.GUI {
  84764. /** Class used to create a RadioGroup
  84765. * which contains groups of radio buttons
  84766. */
  84767. export class SelectorGroup {
  84768. /** name of SelectorGroup */
  84769. name: string;
  84770. private _groupPanel;
  84771. private _selectors;
  84772. private _groupHeader;
  84773. /**
  84774. * Creates a new SelectorGroup
  84775. * @param name of group, used as a group heading
  84776. */
  84777. constructor(
  84778. /** name of SelectorGroup */
  84779. name: string);
  84780. /** Gets the groupPanel of the SelectorGroup */
  84781. get groupPanel(): StackPanel;
  84782. /** Gets the selectors array */
  84783. get selectors(): StackPanel[];
  84784. /** Gets and sets the group header */
  84785. get header(): string;
  84786. set header(label: string);
  84787. /** @hidden */
  84788. private _addGroupHeader;
  84789. /** @hidden*/
  84790. _getSelector(selectorNb: number): StackPanel | undefined;
  84791. /** Removes the selector at the given position
  84792. * @param selectorNb the position of the selector within the group
  84793. */
  84794. removeSelector(selectorNb: number): void;
  84795. }
  84796. /** Class used to create a CheckboxGroup
  84797. * which contains groups of checkbox buttons
  84798. */
  84799. export class CheckboxGroup extends SelectorGroup {
  84800. /** Adds a checkbox as a control
  84801. * @param text is the label for the selector
  84802. * @param func is the function called when the Selector is checked
  84803. * @param checked is true when Selector is checked
  84804. */
  84805. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  84806. /** @hidden */
  84807. _setSelectorLabel(selectorNb: number, label: string): void;
  84808. /** @hidden */
  84809. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84810. /** @hidden */
  84811. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84812. /** @hidden */
  84813. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84814. }
  84815. /** Class used to create a RadioGroup
  84816. * which contains groups of radio buttons
  84817. */
  84818. export class RadioGroup extends SelectorGroup {
  84819. private _selectNb;
  84820. /** Adds a radio button as a control
  84821. * @param label is the label for the selector
  84822. * @param func is the function called when the Selector is checked
  84823. * @param checked is true when Selector is checked
  84824. */
  84825. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  84826. /** @hidden */
  84827. _setSelectorLabel(selectorNb: number, label: string): void;
  84828. /** @hidden */
  84829. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84830. /** @hidden */
  84831. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84832. /** @hidden */
  84833. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84834. }
  84835. /** Class used to create a SliderGroup
  84836. * which contains groups of slider buttons
  84837. */
  84838. export class SliderGroup extends SelectorGroup {
  84839. /**
  84840. * Adds a slider to the SelectorGroup
  84841. * @param label is the label for the SliderBar
  84842. * @param func is the function called when the Slider moves
  84843. * @param unit is a string describing the units used, eg degrees or metres
  84844. * @param min is the minimum value for the Slider
  84845. * @param max is the maximum value for the Slider
  84846. * @param value is the start value for the Slider between min and max
  84847. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  84848. */
  84849. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  84850. /** @hidden */
  84851. _setSelectorLabel(selectorNb: number, label: string): void;
  84852. /** @hidden */
  84853. _setSelectorLabelColor(selectorNb: number, color: string): void;
  84854. /** @hidden */
  84855. _setSelectorButtonColor(selectorNb: number, color: string): void;
  84856. /** @hidden */
  84857. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  84858. }
  84859. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  84860. * @see https://doc.babylonjs.com/how_to/selector
  84861. */
  84862. export class SelectionPanel extends Rectangle {
  84863. /** name of SelectionPanel */
  84864. name: string;
  84865. /** an array of SelectionGroups */
  84866. groups: SelectorGroup[];
  84867. private _panel;
  84868. private _buttonColor;
  84869. private _buttonBackground;
  84870. private _headerColor;
  84871. private _barColor;
  84872. private _barHeight;
  84873. private _spacerHeight;
  84874. private _labelColor;
  84875. private _groups;
  84876. private _bars;
  84877. /**
  84878. * Creates a new SelectionPanel
  84879. * @param name of SelectionPanel
  84880. * @param groups is an array of SelectionGroups
  84881. */
  84882. constructor(
  84883. /** name of SelectionPanel */
  84884. name: string,
  84885. /** an array of SelectionGroups */
  84886. groups?: SelectorGroup[]);
  84887. protected _getTypeName(): string;
  84888. /** Gets the (stack) panel of the SelectionPanel */
  84889. get panel(): StackPanel;
  84890. /** Gets or sets the headerColor */
  84891. get headerColor(): string;
  84892. set headerColor(color: string);
  84893. private _setHeaderColor;
  84894. /** Gets or sets the button color */
  84895. get buttonColor(): string;
  84896. set buttonColor(color: string);
  84897. private _setbuttonColor;
  84898. /** Gets or sets the label color */
  84899. get labelColor(): string;
  84900. set labelColor(color: string);
  84901. private _setLabelColor;
  84902. /** Gets or sets the button background */
  84903. get buttonBackground(): string;
  84904. set buttonBackground(color: string);
  84905. private _setButtonBackground;
  84906. /** Gets or sets the color of separator bar */
  84907. get barColor(): string;
  84908. set barColor(color: string);
  84909. private _setBarColor;
  84910. /** Gets or sets the height of separator bar */
  84911. get barHeight(): string;
  84912. set barHeight(value: string);
  84913. private _setBarHeight;
  84914. /** Gets or sets the height of spacers*/
  84915. get spacerHeight(): string;
  84916. set spacerHeight(value: string);
  84917. private _setSpacerHeight;
  84918. /** Adds a bar between groups */
  84919. private _addSpacer;
  84920. /** Add a group to the selection panel
  84921. * @param group is the selector group to add
  84922. */
  84923. addGroup(group: SelectorGroup): void;
  84924. /** Remove the group from the given position
  84925. * @param groupNb is the position of the group in the list
  84926. */
  84927. removeGroup(groupNb: number): void;
  84928. /** Change a group header label
  84929. * @param label is the new group header label
  84930. * @param groupNb is the number of the group to relabel
  84931. * */
  84932. setHeaderName(label: string, groupNb: number): void;
  84933. /** Change selector label to the one given
  84934. * @param label is the new selector label
  84935. * @param groupNb is the number of the groupcontaining the selector
  84936. * @param selectorNb is the number of the selector within a group to relabel
  84937. * */
  84938. relabel(label: string, groupNb: number, selectorNb: number): void;
  84939. /** For a given group position remove the selector at the given position
  84940. * @param groupNb is the number of the group to remove the selector from
  84941. * @param selectorNb is the number of the selector within the group
  84942. */
  84943. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  84944. /** For a given group position of correct type add a checkbox button
  84945. * @param groupNb is the number of the group to remove the selector from
  84946. * @param label is the label for the selector
  84947. * @param func is the function called when the Selector is checked
  84948. * @param checked is true when Selector is checked
  84949. */
  84950. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84951. /** For a given group position of correct type add a radio button
  84952. * @param groupNb is the number of the group to remove the selector from
  84953. * @param label is the label for the selector
  84954. * @param func is the function called when the Selector is checked
  84955. * @param checked is true when Selector is checked
  84956. */
  84957. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  84958. /**
  84959. * For a given slider group add a slider
  84960. * @param groupNb is the number of the group to add the slider to
  84961. * @param label is the label for the Slider
  84962. * @param func is the function called when the Slider moves
  84963. * @param unit is a string describing the units used, eg degrees or metres
  84964. * @param min is the minimum value for the Slider
  84965. * @param max is the maximum value for the Slider
  84966. * @param value is the start value for the Slider between min and max
  84967. * @param onVal is the function used to format the value displayed, eg radians to degrees
  84968. */
  84969. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  84970. }
  84971. }
  84972. declare module BABYLON.GUI {
  84973. /**
  84974. * Class used to hold a the container for ScrollViewer
  84975. * @hidden
  84976. */
  84977. export class _ScrollViewerWindow extends Container {
  84978. parentClientWidth: number;
  84979. parentClientHeight: number;
  84980. private _freezeControls;
  84981. private _parentMeasure;
  84982. private _oldLeft;
  84983. private _oldTop;
  84984. get freezeControls(): boolean;
  84985. set freezeControls(value: boolean);
  84986. private _bucketWidth;
  84987. private _bucketHeight;
  84988. private _buckets;
  84989. private _bucketLen;
  84990. get bucketWidth(): number;
  84991. get bucketHeight(): number;
  84992. setBucketSizes(width: number, height: number): void;
  84993. private _useBuckets;
  84994. private _makeBuckets;
  84995. private _dispatchInBuckets;
  84996. private _updateMeasures;
  84997. private _updateChildrenMeasures;
  84998. private _restoreMeasures;
  84999. /**
  85000. * Creates a new ScrollViewerWindow
  85001. * @param name of ScrollViewerWindow
  85002. */
  85003. constructor(name?: string);
  85004. protected _getTypeName(): string;
  85005. /** @hidden */
  85006. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85007. /** @hidden */
  85008. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  85009. private _scrollChildren;
  85010. private _scrollChildrenWithBuckets;
  85011. /** @hidden */
  85012. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  85013. protected _postMeasure(): void;
  85014. }
  85015. }
  85016. declare module BABYLON.GUI {
  85017. /**
  85018. * Class used to create slider controls
  85019. */
  85020. export class ScrollBar extends BaseSlider {
  85021. name?: string | undefined;
  85022. private _background;
  85023. private _borderColor;
  85024. private _tempMeasure;
  85025. /** Gets or sets border color */
  85026. get borderColor(): string;
  85027. set borderColor(value: string);
  85028. /** Gets or sets background color */
  85029. get background(): string;
  85030. set background(value: string);
  85031. /**
  85032. * Creates a new Slider
  85033. * @param name defines the control name
  85034. */
  85035. constructor(name?: string | undefined);
  85036. protected _getTypeName(): string;
  85037. protected _getThumbThickness(): number;
  85038. _draw(context: CanvasRenderingContext2D): void;
  85039. private _first;
  85040. private _originX;
  85041. private _originY;
  85042. /** @hidden */
  85043. protected _updateValueFromPointer(x: number, y: number): void;
  85044. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85045. }
  85046. }
  85047. declare module BABYLON.GUI {
  85048. /**
  85049. * Class used to create slider controls
  85050. */
  85051. export class ImageScrollBar extends BaseSlider {
  85052. name?: string | undefined;
  85053. private _backgroundBaseImage;
  85054. private _backgroundImage;
  85055. private _thumbImage;
  85056. private _thumbBaseImage;
  85057. private _thumbLength;
  85058. private _thumbHeight;
  85059. private _barImageHeight;
  85060. private _tempMeasure;
  85061. /** Number of 90° rotation to apply on the images when in vertical mode */
  85062. num90RotationInVerticalMode: number;
  85063. /**
  85064. * Gets or sets the image used to render the background for horizontal bar
  85065. */
  85066. get backgroundImage(): Image;
  85067. set backgroundImage(value: Image);
  85068. /**
  85069. * Gets or sets the image used to render the thumb
  85070. */
  85071. get thumbImage(): Image;
  85072. set thumbImage(value: Image);
  85073. /**
  85074. * Gets or sets the length of the thumb
  85075. */
  85076. get thumbLength(): number;
  85077. set thumbLength(value: number);
  85078. /**
  85079. * Gets or sets the height of the thumb
  85080. */
  85081. get thumbHeight(): number;
  85082. set thumbHeight(value: number);
  85083. /**
  85084. * Gets or sets the height of the bar image
  85085. */
  85086. get barImageHeight(): number;
  85087. set barImageHeight(value: number);
  85088. /**
  85089. * Creates a new ImageScrollBar
  85090. * @param name defines the control name
  85091. */
  85092. constructor(name?: string | undefined);
  85093. protected _getTypeName(): string;
  85094. protected _getThumbThickness(): number;
  85095. _draw(context: CanvasRenderingContext2D): void;
  85096. private _first;
  85097. private _originX;
  85098. private _originY;
  85099. /** @hidden */
  85100. protected _updateValueFromPointer(x: number, y: number): void;
  85101. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85102. }
  85103. }
  85104. declare module BABYLON.GUI {
  85105. /**
  85106. * Class used to hold a viewer window and sliders in a grid
  85107. */
  85108. export class ScrollViewer extends Rectangle {
  85109. private _grid;
  85110. private _horizontalBarSpace;
  85111. private _verticalBarSpace;
  85112. private _dragSpace;
  85113. private _horizontalBar;
  85114. private _verticalBar;
  85115. private _barColor;
  85116. private _barBackground;
  85117. private _barImage;
  85118. private _horizontalBarImage;
  85119. private _verticalBarImage;
  85120. private _barBackgroundImage;
  85121. private _horizontalBarBackgroundImage;
  85122. private _verticalBarBackgroundImage;
  85123. private _barSize;
  85124. private _window;
  85125. private _pointerIsOver;
  85126. private _wheelPrecision;
  85127. private _onWheelObserver;
  85128. private _clientWidth;
  85129. private _clientHeight;
  85130. private _useImageBar;
  85131. private _thumbLength;
  85132. private _thumbHeight;
  85133. private _barImageHeight;
  85134. private _horizontalBarImageHeight;
  85135. private _verticalBarImageHeight;
  85136. private _oldWindowContentsWidth;
  85137. private _oldWindowContentsHeight;
  85138. /**
  85139. * Gets the horizontal scrollbar
  85140. */
  85141. get horizontalBar(): ScrollBar | ImageScrollBar;
  85142. /**
  85143. * Gets the vertical scrollbar
  85144. */
  85145. get verticalBar(): ScrollBar | ImageScrollBar;
  85146. /**
  85147. * Adds a new control to the current container
  85148. * @param control defines the control to add
  85149. * @returns the current container
  85150. */
  85151. addControl(control: BABYLON.Nullable<Control>): Container;
  85152. /**
  85153. * Removes a control from the current container
  85154. * @param control defines the control to remove
  85155. * @returns the current container
  85156. */
  85157. removeControl(control: Control): Container;
  85158. /** Gets the list of children */
  85159. get children(): Control[];
  85160. _flagDescendantsAsMatrixDirty(): void;
  85161. /**
  85162. * Freezes or unfreezes the controls in the window.
  85163. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  85164. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  85165. */
  85166. get freezeControls(): boolean;
  85167. set freezeControls(value: boolean);
  85168. /** Gets the bucket width */
  85169. get bucketWidth(): number;
  85170. /** Gets the bucket height */
  85171. get bucketHeight(): number;
  85172. /**
  85173. * Sets the bucket sizes.
  85174. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  85175. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  85176. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  85177. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  85178. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  85179. * used), that's why it is not enabled by default.
  85180. * @param width width of the bucket
  85181. * @param height height of the bucket
  85182. */
  85183. setBucketSizes(width: number, height: number): void;
  85184. private _forceHorizontalBar;
  85185. private _forceVerticalBar;
  85186. /**
  85187. * Forces the horizontal scroll bar to be displayed
  85188. */
  85189. get forceHorizontalBar(): boolean;
  85190. set forceHorizontalBar(value: boolean);
  85191. /**
  85192. * Forces the vertical scroll bar to be displayed
  85193. */
  85194. get forceVerticalBar(): boolean;
  85195. set forceVerticalBar(value: boolean);
  85196. /**
  85197. * Creates a new ScrollViewer
  85198. * @param name of ScrollViewer
  85199. */
  85200. constructor(name?: string, isImageBased?: boolean);
  85201. /** Reset the scroll viewer window to initial size */
  85202. resetWindow(): void;
  85203. protected _getTypeName(): string;
  85204. private _buildClientSizes;
  85205. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  85206. protected _postMeasure(): void;
  85207. /**
  85208. * Gets or sets the mouse wheel precision
  85209. * from 0 to 1 with a default value of 0.05
  85210. * */
  85211. get wheelPrecision(): number;
  85212. set wheelPrecision(value: number);
  85213. /** Gets or sets the scroll bar container background color */
  85214. get scrollBackground(): string;
  85215. set scrollBackground(color: string);
  85216. /** Gets or sets the bar color */
  85217. get barColor(): string;
  85218. set barColor(color: string);
  85219. /** Gets or sets the bar image */
  85220. get thumbImage(): Image;
  85221. set thumbImage(value: Image);
  85222. /** Gets or sets the horizontal bar image */
  85223. get horizontalThumbImage(): Image;
  85224. set horizontalThumbImage(value: Image);
  85225. /** Gets or sets the vertical bar image */
  85226. get verticalThumbImage(): Image;
  85227. set verticalThumbImage(value: Image);
  85228. /** Gets or sets the size of the bar */
  85229. get barSize(): number;
  85230. set barSize(value: number);
  85231. /** Gets or sets the length of the thumb */
  85232. get thumbLength(): number;
  85233. set thumbLength(value: number);
  85234. /** Gets or sets the height of the thumb */
  85235. get thumbHeight(): number;
  85236. set thumbHeight(value: number);
  85237. /** Gets or sets the height of the bar image */
  85238. get barImageHeight(): number;
  85239. set barImageHeight(value: number);
  85240. /** Gets or sets the height of the horizontal bar image */
  85241. get horizontalBarImageHeight(): number;
  85242. set horizontalBarImageHeight(value: number);
  85243. /** Gets or sets the height of the vertical bar image */
  85244. get verticalBarImageHeight(): number;
  85245. set verticalBarImageHeight(value: number);
  85246. /** Gets or sets the bar background */
  85247. get barBackground(): string;
  85248. set barBackground(color: string);
  85249. /** Gets or sets the bar background image */
  85250. get barImage(): Image;
  85251. set barImage(value: Image);
  85252. /** Gets or sets the horizontal bar background image */
  85253. get horizontalBarImage(): Image;
  85254. set horizontalBarImage(value: Image);
  85255. /** Gets or sets the vertical bar background image */
  85256. get verticalBarImage(): Image;
  85257. set verticalBarImage(value: Image);
  85258. private _setWindowPosition;
  85259. /** @hidden */
  85260. private _updateScroller;
  85261. _link(host: AdvancedDynamicTexture): void;
  85262. /** @hidden */
  85263. private _addBar;
  85264. /** @hidden */
  85265. private _attachWheel;
  85266. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  85267. /** Releases associated resources */
  85268. dispose(): void;
  85269. }
  85270. }
  85271. declare module BABYLON.GUI {
  85272. /**
  85273. * Class used to create toggle buttons
  85274. */
  85275. export class ToggleButton extends Rectangle {
  85276. name?: string | undefined;
  85277. /**
  85278. * Function called to generate the toActive animation
  85279. */
  85280. toActiveAnimation: () => void;
  85281. /**
  85282. * Function called to generate the toInactive animation
  85283. */
  85284. toInactiveAnimation: () => void;
  85285. /**
  85286. * Function called to generate a pointer enter animation when the toggle button is active.
  85287. */
  85288. pointerEnterActiveAnimation: () => void;
  85289. /**
  85290. * Function called to generate a pointer out animation when the toggle button is active.
  85291. */
  85292. pointerOutActiveAnimation: () => void;
  85293. /**
  85294. * Function called to generate a pointer down animation when the toggle button is active.
  85295. */
  85296. pointerDownActiveAnimation: () => void;
  85297. /**
  85298. * Function called to generate a pointer up animation when the toggle button is active.
  85299. */
  85300. pointerUpActiveAnimation: () => void;
  85301. /**
  85302. * Function called to generate a pointer enter animation when the toggle button is inactive.
  85303. */
  85304. pointerEnterInactiveAnimation: () => void;
  85305. /**
  85306. * Function called to generate a pointer out animation when the toggle button is inactive.
  85307. */
  85308. pointerOutInactiveAnimation: () => void;
  85309. /**
  85310. * Function called to generate a pointer down animation when the toggle button is inactive.
  85311. */
  85312. pointerDownInactiveAnimation: () => void;
  85313. /**
  85314. * Function called to generate a pointer up animation when the toggle button is inactive.
  85315. */
  85316. pointerUpInactiveAnimation: () => void;
  85317. /** BABYLON.Observable raised when isActive is changed */
  85318. onIsActiveChangedObservable: BABYLON.Observable<boolean>;
  85319. /**
  85320. * 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
  85321. */
  85322. delegatePickingToChildren: boolean;
  85323. private _image;
  85324. /**
  85325. * Returns the ToggleButton's image control if it exists
  85326. */
  85327. get image(): BABYLON.Nullable<Image>;
  85328. private _textBlock;
  85329. /**
  85330. * Returns the ToggleButton's child TextBlock control if it exists
  85331. */
  85332. get textBlock(): BABYLON.Nullable<TextBlock>;
  85333. private _group;
  85334. /** Gets or sets group name this toggle button belongs to */
  85335. get group(): string;
  85336. set group(value: string);
  85337. private _isActive;
  85338. /** Gets or sets a boolean indicating if the toogle button is active or not */
  85339. get isActive(): boolean;
  85340. set isActive(value: boolean);
  85341. /**
  85342. * Creates a new ToggleButton
  85343. * @param name defines the control name
  85344. * @param group defines the toggle group this toggle belongs to
  85345. */
  85346. constructor(name?: string | undefined, group?: string);
  85347. protected _getTypeName(): string;
  85348. /** @hidden */
  85349. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  85350. /** @hidden */
  85351. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  85352. /** @hidden */
  85353. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  85354. /** @hidden */
  85355. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  85356. /** @hidden */
  85357. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  85358. }
  85359. }
  85360. declare module BABYLON.GUI {
  85361. /** Class used to render a grid */
  85362. export class DisplayGrid extends Control {
  85363. name?: string | undefined;
  85364. private _cellWidth;
  85365. private _cellHeight;
  85366. private _minorLineTickness;
  85367. private _minorLineColor;
  85368. private _majorLineTickness;
  85369. private _majorLineColor;
  85370. private _majorLineFrequency;
  85371. private _background;
  85372. private _displayMajorLines;
  85373. private _displayMinorLines;
  85374. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  85375. get displayMinorLines(): boolean;
  85376. set displayMinorLines(value: boolean);
  85377. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  85378. get displayMajorLines(): boolean;
  85379. set displayMajorLines(value: boolean);
  85380. /** Gets or sets background color (Black by default) */
  85381. get background(): string;
  85382. set background(value: string);
  85383. /** Gets or sets the width of each cell (20 by default) */
  85384. get cellWidth(): number;
  85385. set cellWidth(value: number);
  85386. /** Gets or sets the height of each cell (20 by default) */
  85387. get cellHeight(): number;
  85388. set cellHeight(value: number);
  85389. /** Gets or sets the tickness of minor lines (1 by default) */
  85390. get minorLineTickness(): number;
  85391. set minorLineTickness(value: number);
  85392. /** Gets or sets the color of minor lines (DarkGray by default) */
  85393. get minorLineColor(): string;
  85394. set minorLineColor(value: string);
  85395. /** Gets or sets the tickness of major lines (2 by default) */
  85396. get majorLineTickness(): number;
  85397. set majorLineTickness(value: number);
  85398. /** Gets or sets the color of major lines (White by default) */
  85399. get majorLineColor(): string;
  85400. set majorLineColor(value: string);
  85401. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  85402. get majorLineFrequency(): number;
  85403. set majorLineFrequency(value: number);
  85404. /**
  85405. * Creates a new GridDisplayRectangle
  85406. * @param name defines the control name
  85407. */
  85408. constructor(name?: string | undefined);
  85409. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85410. protected _getTypeName(): string;
  85411. }
  85412. }
  85413. declare module BABYLON.GUI {
  85414. /**
  85415. * Class used to create slider controls based on images
  85416. */
  85417. export class ImageBasedSlider extends BaseSlider {
  85418. name?: string | undefined;
  85419. private _backgroundImage;
  85420. private _thumbImage;
  85421. private _valueBarImage;
  85422. private _tempMeasure;
  85423. get displayThumb(): boolean;
  85424. set displayThumb(value: boolean);
  85425. /**
  85426. * Gets or sets the image used to render the background
  85427. */
  85428. get backgroundImage(): Image;
  85429. set backgroundImage(value: Image);
  85430. /**
  85431. * Gets or sets the image used to render the value bar
  85432. */
  85433. get valueBarImage(): Image;
  85434. set valueBarImage(value: Image);
  85435. /**
  85436. * Gets or sets the image used to render the thumb
  85437. */
  85438. get thumbImage(): Image;
  85439. set thumbImage(value: Image);
  85440. /**
  85441. * Creates a new ImageBasedSlider
  85442. * @param name defines the control name
  85443. */
  85444. constructor(name?: string | undefined);
  85445. protected _getTypeName(): string;
  85446. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  85447. }
  85448. }
  85449. declare module BABYLON.GUI {
  85450. /**
  85451. * Forcing an export so that this code will execute
  85452. * @hidden
  85453. */
  85454. const name = "Statics";
  85455. }
  85456. declare module BABYLON.GUI {
  85457. /**
  85458. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  85459. */
  85460. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  85461. /**
  85462. * Define the instrumented AdvancedDynamicTexture.
  85463. */
  85464. texture: AdvancedDynamicTexture;
  85465. private _captureRenderTime;
  85466. private _renderTime;
  85467. private _captureLayoutTime;
  85468. private _layoutTime;
  85469. private _onBeginRenderObserver;
  85470. private _onEndRenderObserver;
  85471. private _onBeginLayoutObserver;
  85472. private _onEndLayoutObserver;
  85473. /**
  85474. * Gets the perf counter used to capture render time
  85475. */
  85476. get renderTimeCounter(): BABYLON.PerfCounter;
  85477. /**
  85478. * Gets the perf counter used to capture layout time
  85479. */
  85480. get layoutTimeCounter(): BABYLON.PerfCounter;
  85481. /**
  85482. * Enable or disable the render time capture
  85483. */
  85484. get captureRenderTime(): boolean;
  85485. set captureRenderTime(value: boolean);
  85486. /**
  85487. * Enable or disable the layout time capture
  85488. */
  85489. get captureLayoutTime(): boolean;
  85490. set captureLayoutTime(value: boolean);
  85491. /**
  85492. * Instantiates a new advanced dynamic texture instrumentation.
  85493. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  85494. * @param texture Defines the AdvancedDynamicTexture to instrument
  85495. */
  85496. constructor(
  85497. /**
  85498. * Define the instrumented AdvancedDynamicTexture.
  85499. */
  85500. texture: AdvancedDynamicTexture);
  85501. /**
  85502. * Dispose and release associated resources.
  85503. */
  85504. dispose(): void;
  85505. }
  85506. }
  85507. declare module BABYLON.GUI {
  85508. /**
  85509. * Class used to load GUI via XML.
  85510. */
  85511. export class XmlLoader {
  85512. private _nodes;
  85513. private _nodeTypes;
  85514. private _isLoaded;
  85515. private _objectAttributes;
  85516. private _parentClass;
  85517. /**
  85518. * Create a new xml loader
  85519. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  85520. */
  85521. constructor(parentClass?: null);
  85522. private _getChainElement;
  85523. private _getClassAttribute;
  85524. private _createGuiElement;
  85525. private _parseGrid;
  85526. private _parseElement;
  85527. private _prepareSourceElement;
  85528. private _parseElementsFromSource;
  85529. private _parseXml;
  85530. /**
  85531. * Gets if the loading has finished.
  85532. * @returns whether the loading has finished or not
  85533. */
  85534. isLoaded(): boolean;
  85535. /**
  85536. * Gets a loaded node / control by id.
  85537. * @param id the Controls id set in the xml
  85538. * @returns element of type Control
  85539. */
  85540. getNodeById(id: string): any;
  85541. /**
  85542. * Gets all loaded nodes / controls
  85543. * @returns Array of controls
  85544. */
  85545. getNodes(): any;
  85546. /**
  85547. * Initiates the xml layout loading
  85548. * @param xmlFile defines the xml layout to load
  85549. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  85550. * @param callback defines the callback called on layout load.
  85551. */
  85552. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  85553. }
  85554. }
  85555. declare module BABYLON.GUI {
  85556. /**
  85557. * Class used to create containers for controls
  85558. */
  85559. export class Container3D extends Control3D {
  85560. private _blockLayout;
  85561. /**
  85562. * Gets the list of child controls
  85563. */
  85564. protected _children: Control3D[];
  85565. /**
  85566. * Gets the list of child controls
  85567. */
  85568. get children(): Array<Control3D>;
  85569. /**
  85570. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  85571. * This is helpful to optimize layout operation when adding multiple children in a row
  85572. */
  85573. get blockLayout(): boolean;
  85574. set blockLayout(value: boolean);
  85575. /**
  85576. * Creates a new container
  85577. * @param name defines the container name
  85578. */
  85579. constructor(name?: string);
  85580. /**
  85581. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  85582. * @returns the current container
  85583. */
  85584. updateLayout(): Container3D;
  85585. /**
  85586. * Gets a boolean indicating if the given control is in the children of this control
  85587. * @param control defines the control to check
  85588. * @returns true if the control is in the child list
  85589. */
  85590. containsControl(control: Control3D): boolean;
  85591. /**
  85592. * Adds a control to the children of this control
  85593. * @param control defines the control to add
  85594. * @returns the current container
  85595. */
  85596. addControl(control: Control3D): Container3D;
  85597. /**
  85598. * This function will be called everytime a new control is added
  85599. */
  85600. protected _arrangeChildren(): void;
  85601. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85602. /**
  85603. * Removes a control from the children of this control
  85604. * @param control defines the control to remove
  85605. * @returns the current container
  85606. */
  85607. removeControl(control: Control3D): Container3D;
  85608. protected _getTypeName(): string;
  85609. /**
  85610. * Releases all associated resources
  85611. */
  85612. dispose(): void;
  85613. /** Control rotation will remain unchanged */
  85614. static readonly UNSET_ORIENTATION: number;
  85615. /** Control will rotate to make it look at sphere central axis */
  85616. static readonly FACEORIGIN_ORIENTATION: number;
  85617. /** Control will rotate to make it look back at sphere central axis */
  85618. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  85619. /** Control will rotate to look at z axis (0, 0, 1) */
  85620. static readonly FACEFORWARD_ORIENTATION: number;
  85621. /** Control will rotate to look at negative z axis (0, 0, -1) */
  85622. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  85623. }
  85624. }
  85625. declare module BABYLON.GUI {
  85626. /**
  85627. * Class used to manage 3D user interface
  85628. * @see https://doc.babylonjs.com/how_to/gui3d
  85629. */
  85630. export class GUI3DManager implements BABYLON.IDisposable {
  85631. private _scene;
  85632. private _sceneDisposeObserver;
  85633. private _utilityLayer;
  85634. private _rootContainer;
  85635. private _pointerObserver;
  85636. private _pointerOutObserver;
  85637. /** @hidden */
  85638. _lastPickedControl: Control3D;
  85639. /** @hidden */
  85640. _lastControlOver: {
  85641. [pointerId: number]: Control3D;
  85642. };
  85643. /** @hidden */
  85644. _lastControlDown: {
  85645. [pointerId: number]: Control3D;
  85646. };
  85647. /**
  85648. * BABYLON.Observable raised when the point picked by the pointer events changed
  85649. */
  85650. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  85651. /** @hidden */
  85652. _sharedMaterials: {
  85653. [key: string]: BABYLON.Material;
  85654. };
  85655. /** Gets the hosting scene */
  85656. get scene(): BABYLON.Scene;
  85657. /** Gets associated utility layer */
  85658. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  85659. /**
  85660. * Creates a new GUI3DManager
  85661. * @param scene
  85662. */
  85663. constructor(scene?: BABYLON.Scene);
  85664. private _handlePointerOut;
  85665. private _doPicking;
  85666. /**
  85667. * Gets the root container
  85668. */
  85669. get rootContainer(): Container3D;
  85670. /**
  85671. * Gets a boolean indicating if the given control is in the root child list
  85672. * @param control defines the control to check
  85673. * @returns true if the control is in the root child list
  85674. */
  85675. containsControl(control: Control3D): boolean;
  85676. /**
  85677. * Adds a control to the root child list
  85678. * @param control defines the control to add
  85679. * @returns the current manager
  85680. */
  85681. addControl(control: Control3D): GUI3DManager;
  85682. /**
  85683. * Removes a control from the root child list
  85684. * @param control defines the control to remove
  85685. * @returns the current container
  85686. */
  85687. removeControl(control: Control3D): GUI3DManager;
  85688. /**
  85689. * Releases all associated resources
  85690. */
  85691. dispose(): void;
  85692. }
  85693. }
  85694. declare module BABYLON.GUI {
  85695. /**
  85696. * Class used to transport BABYLON.Vector3 information for pointer events
  85697. */
  85698. export class Vector3WithInfo extends BABYLON.Vector3 {
  85699. /** defines the current mouse button index */
  85700. buttonIndex: number;
  85701. /**
  85702. * Creates a new Vector3WithInfo
  85703. * @param source defines the vector3 data to transport
  85704. * @param buttonIndex defines the current mouse button index
  85705. */
  85706. constructor(source: BABYLON.Vector3,
  85707. /** defines the current mouse button index */
  85708. buttonIndex?: number);
  85709. }
  85710. }
  85711. declare module BABYLON.GUI {
  85712. /**
  85713. * Class used as base class for controls
  85714. */
  85715. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  85716. /** Defines the control name */
  85717. name?: string | undefined;
  85718. /** @hidden */
  85719. _host: GUI3DManager;
  85720. private _node;
  85721. private _downCount;
  85722. private _enterCount;
  85723. private _downPointerIds;
  85724. private _isVisible;
  85725. /** Gets or sets the control position in world space */
  85726. get position(): BABYLON.Vector3;
  85727. set position(value: BABYLON.Vector3);
  85728. /** Gets or sets the control scaling in world space */
  85729. get scaling(): BABYLON.Vector3;
  85730. set scaling(value: BABYLON.Vector3);
  85731. /** Callback used to start pointer enter animation */
  85732. pointerEnterAnimation: () => void;
  85733. /** Callback used to start pointer out animation */
  85734. pointerOutAnimation: () => void;
  85735. /** Callback used to start pointer down animation */
  85736. pointerDownAnimation: () => void;
  85737. /** Callback used to start pointer up animation */
  85738. pointerUpAnimation: () => void;
  85739. /**
  85740. * An event triggered when the pointer move over the control
  85741. */
  85742. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  85743. /**
  85744. * An event triggered when the pointer move out of the control
  85745. */
  85746. onPointerOutObservable: BABYLON.Observable<Control3D>;
  85747. /**
  85748. * An event triggered when the pointer taps the control
  85749. */
  85750. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  85751. /**
  85752. * An event triggered when pointer is up
  85753. */
  85754. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  85755. /**
  85756. * An event triggered when a control is clicked on (with a mouse)
  85757. */
  85758. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  85759. /**
  85760. * An event triggered when pointer enters the control
  85761. */
  85762. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  85763. /**
  85764. * Gets or sets the parent container
  85765. */
  85766. parent: BABYLON.Nullable<Container3D>;
  85767. private _behaviors;
  85768. /**
  85769. * Gets the list of attached behaviors
  85770. * @see https://doc.babylonjs.com/features/behaviour
  85771. */
  85772. get behaviors(): BABYLON.Behavior<Control3D>[];
  85773. /**
  85774. * Attach a behavior to the control
  85775. * @see https://doc.babylonjs.com/features/behaviour
  85776. * @param behavior defines the behavior to attach
  85777. * @returns the current control
  85778. */
  85779. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85780. /**
  85781. * Remove an attached behavior
  85782. * @see https://doc.babylonjs.com/features/behaviour
  85783. * @param behavior defines the behavior to attach
  85784. * @returns the current control
  85785. */
  85786. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  85787. /**
  85788. * Gets an attached behavior by name
  85789. * @param name defines the name of the behavior to look for
  85790. * @see https://doc.babylonjs.com/features/behaviour
  85791. * @returns null if behavior was not found else the requested behavior
  85792. */
  85793. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  85794. /** Gets or sets a boolean indicating if the control is visible */
  85795. get isVisible(): boolean;
  85796. set isVisible(value: boolean);
  85797. /**
  85798. * Creates a new control
  85799. * @param name defines the control name
  85800. */
  85801. constructor(
  85802. /** Defines the control name */
  85803. name?: string | undefined);
  85804. /**
  85805. * Gets a string representing the class name
  85806. */
  85807. get typeName(): string;
  85808. /**
  85809. * Get the current class name of the control.
  85810. * @returns current class name
  85811. */
  85812. getClassName(): string;
  85813. protected _getTypeName(): string;
  85814. /**
  85815. * Gets the transform node used by this control
  85816. */
  85817. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  85818. /**
  85819. * Gets the mesh used to render this control
  85820. */
  85821. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  85822. /**
  85823. * Link the control as child of the given node
  85824. * @param node defines the node to link to. Use null to unlink the control
  85825. * @returns the current control
  85826. */
  85827. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  85828. /** @hidden **/
  85829. _prepareNode(scene: BABYLON.Scene): void;
  85830. /**
  85831. * Node creation.
  85832. * Can be overriden by children
  85833. * @param scene defines the scene where the node must be attached
  85834. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  85835. */
  85836. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  85837. /**
  85838. * Affect a material to the given mesh
  85839. * @param mesh defines the mesh which will represent the control
  85840. */
  85841. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85842. /** @hidden */
  85843. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  85844. /** @hidden */
  85845. _onPointerEnter(target: Control3D): boolean;
  85846. /** @hidden */
  85847. _onPointerOut(target: Control3D): void;
  85848. /** @hidden */
  85849. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85850. /** @hidden */
  85851. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  85852. /** @hidden */
  85853. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  85854. /** @hidden */
  85855. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  85856. /** @hidden */
  85857. _disposeNode(): void;
  85858. /**
  85859. * Releases all associated resources
  85860. */
  85861. dispose(): void;
  85862. }
  85863. }
  85864. declare module BABYLON.GUI {
  85865. /**
  85866. * Class used as a root to all buttons
  85867. */
  85868. export class AbstractButton3D extends Control3D {
  85869. /**
  85870. * Creates a new button
  85871. * @param name defines the control name
  85872. */
  85873. constructor(name?: string);
  85874. protected _getTypeName(): string;
  85875. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85876. }
  85877. }
  85878. declare module BABYLON.GUI {
  85879. /**
  85880. * Class used to create a button in 3D
  85881. */
  85882. export class Button3D extends AbstractButton3D {
  85883. /** @hidden */
  85884. protected _currentMaterial: BABYLON.Material;
  85885. private _facadeTexture;
  85886. private _content;
  85887. private _contentResolution;
  85888. private _contentScaleRatio;
  85889. /**
  85890. * Gets or sets the texture resolution used to render content (512 by default)
  85891. */
  85892. get contentResolution(): BABYLON.int;
  85893. set contentResolution(value: BABYLON.int);
  85894. /**
  85895. * Gets or sets the texture scale ratio used to render content (2 by default)
  85896. */
  85897. get contentScaleRatio(): number;
  85898. set contentScaleRatio(value: number);
  85899. protected _disposeFacadeTexture(): void;
  85900. protected _resetContent(): void;
  85901. /**
  85902. * Creates a new button
  85903. * @param name defines the control name
  85904. */
  85905. constructor(name?: string);
  85906. /**
  85907. * Gets or sets the GUI 2D content used to display the button's facade
  85908. */
  85909. get content(): Control;
  85910. set content(value: Control);
  85911. /**
  85912. * Apply the facade texture (created from the content property).
  85913. * This function can be overloaded by child classes
  85914. * @param facadeTexture defines the AdvancedDynamicTexture to use
  85915. */
  85916. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  85917. protected _getTypeName(): string;
  85918. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  85919. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  85920. /**
  85921. * Releases all associated resources
  85922. */
  85923. dispose(): void;
  85924. }
  85925. }
  85926. declare module BABYLON.GUI {
  85927. /**
  85928. * Abstract class used to create a container panel deployed on the surface of a volume
  85929. */
  85930. export abstract class VolumeBasedPanel extends Container3D {
  85931. private _columns;
  85932. private _rows;
  85933. private _rowThenColum;
  85934. private _orientation;
  85935. protected _cellWidth: number;
  85936. protected _cellHeight: number;
  85937. /**
  85938. * Gets or sets the distance between elements
  85939. */
  85940. margin: number;
  85941. /**
  85942. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  85943. * | Value | Type | Description |
  85944. * | ----- | ----------------------------------- | ----------- |
  85945. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  85946. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  85947. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  85948. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  85949. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  85950. */
  85951. get orientation(): number;
  85952. set orientation(value: number);
  85953. /**
  85954. * Gets or sets the number of columns requested (10 by default).
  85955. * The panel will automatically compute the number of rows based on number of child controls.
  85956. */
  85957. get columns(): BABYLON.int;
  85958. set columns(value: BABYLON.int);
  85959. /**
  85960. * Gets or sets a the number of rows requested.
  85961. * The panel will automatically compute the number of columns based on number of child controls.
  85962. */
  85963. get rows(): BABYLON.int;
  85964. set rows(value: BABYLON.int);
  85965. /**
  85966. * Creates new VolumeBasedPanel
  85967. */
  85968. constructor();
  85969. protected _arrangeChildren(): void;
  85970. /** Child classes must implement this function to provide correct control positioning */
  85971. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85972. /** Child classes can implement this function to provide additional processing */
  85973. protected _finalProcessing(): void;
  85974. }
  85975. }
  85976. declare module BABYLON.GUI {
  85977. /**
  85978. * Class used to create a container panel deployed on the surface of a cylinder
  85979. */
  85980. export class CylinderPanel extends VolumeBasedPanel {
  85981. private _radius;
  85982. /**
  85983. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  85984. */
  85985. get radius(): BABYLON.float;
  85986. set radius(value: BABYLON.float);
  85987. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  85988. private _cylindricalMapping;
  85989. }
  85990. }
  85991. declare module BABYLON.GUI {
  85992. /** @hidden */
  85993. export var fluentVertexShader: {
  85994. name: string;
  85995. shader: string;
  85996. };
  85997. }
  85998. declare module BABYLON.GUI {
  85999. /** @hidden */
  86000. export var fluentPixelShader: {
  86001. name: string;
  86002. shader: string;
  86003. };
  86004. }
  86005. declare module BABYLON.GUI {
  86006. /** @hidden */
  86007. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  86008. INNERGLOW: boolean;
  86009. BORDER: boolean;
  86010. HOVERLIGHT: boolean;
  86011. TEXTURE: boolean;
  86012. constructor();
  86013. }
  86014. /**
  86015. * Class used to render controls with fluent desgin
  86016. */
  86017. export class FluentMaterial extends BABYLON.PushMaterial {
  86018. /**
  86019. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  86020. */
  86021. innerGlowColorIntensity: number;
  86022. /**
  86023. * Gets or sets the inner glow color (white by default)
  86024. */
  86025. innerGlowColor: BABYLON.Color3;
  86026. /**
  86027. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  86028. */
  86029. albedoColor: BABYLON.Color3;
  86030. /**
  86031. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  86032. */
  86033. renderBorders: boolean;
  86034. /**
  86035. * Gets or sets border width (default is 0.5)
  86036. */
  86037. borderWidth: number;
  86038. /**
  86039. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  86040. */
  86041. edgeSmoothingValue: number;
  86042. /**
  86043. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  86044. */
  86045. borderMinValue: number;
  86046. /**
  86047. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  86048. */
  86049. renderHoverLight: boolean;
  86050. /**
  86051. * Gets or sets the radius used to render the hover light (default is 1.0)
  86052. */
  86053. hoverRadius: number;
  86054. /**
  86055. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  86056. */
  86057. hoverColor: BABYLON.Color4;
  86058. /**
  86059. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  86060. */
  86061. hoverPosition: BABYLON.Vector3;
  86062. private _albedoTexture;
  86063. /** Gets or sets the texture to use for albedo color */
  86064. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86065. /**
  86066. * Creates a new Fluent material
  86067. * @param name defines the name of the material
  86068. * @param scene defines the hosting scene
  86069. */
  86070. constructor(name: string, scene: BABYLON.Scene);
  86071. needAlphaBlending(): boolean;
  86072. needAlphaTesting(): boolean;
  86073. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86074. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86075. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86076. getActiveTextures(): BABYLON.BaseTexture[];
  86077. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86078. dispose(forceDisposeEffect?: boolean): void;
  86079. clone(name: string): FluentMaterial;
  86080. serialize(): any;
  86081. getClassName(): string;
  86082. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  86083. }
  86084. }
  86085. declare module BABYLON.GUI {
  86086. /**
  86087. * Class used to create a holographic button in 3D
  86088. */
  86089. export class HolographicButton extends Button3D {
  86090. private _backPlate;
  86091. private _textPlate;
  86092. private _frontPlate;
  86093. private _text;
  86094. private _imageUrl;
  86095. private _shareMaterials;
  86096. private _frontMaterial;
  86097. private _backMaterial;
  86098. private _plateMaterial;
  86099. private _pickedPointObserver;
  86100. private _tooltipFade;
  86101. private _tooltipTextBlock;
  86102. private _tooltipTexture;
  86103. private _tooltipMesh;
  86104. private _tooltipHoverObserver;
  86105. private _tooltipOutObserver;
  86106. private _disposeTooltip;
  86107. /**
  86108. * Rendering ground id of all the mesh in the button
  86109. */
  86110. set renderingGroupId(id: number);
  86111. get renderingGroupId(): number;
  86112. /**
  86113. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  86114. */
  86115. set tooltipText(text: BABYLON.Nullable<string>);
  86116. get tooltipText(): BABYLON.Nullable<string>;
  86117. /**
  86118. * Gets or sets text for the button
  86119. */
  86120. get text(): string;
  86121. set text(value: string);
  86122. /**
  86123. * Gets or sets the image url for the button
  86124. */
  86125. get imageUrl(): string;
  86126. set imageUrl(value: string);
  86127. /**
  86128. * Gets the back material used by this button
  86129. */
  86130. get backMaterial(): FluentMaterial;
  86131. /**
  86132. * Gets the front material used by this button
  86133. */
  86134. get frontMaterial(): FluentMaterial;
  86135. /**
  86136. * Gets the plate material used by this button
  86137. */
  86138. get plateMaterial(): BABYLON.StandardMaterial;
  86139. /**
  86140. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  86141. */
  86142. get shareMaterials(): boolean;
  86143. /**
  86144. * Creates a new button
  86145. * @param name defines the control name
  86146. */
  86147. constructor(name?: string, shareMaterials?: boolean);
  86148. protected _getTypeName(): string;
  86149. private _rebuildContent;
  86150. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86151. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  86152. private _createBackMaterial;
  86153. private _createFrontMaterial;
  86154. private _createPlateMaterial;
  86155. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  86156. /**
  86157. * Releases all associated resources
  86158. */
  86159. dispose(): void;
  86160. }
  86161. }
  86162. declare module BABYLON.GUI {
  86163. /**
  86164. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  86165. */
  86166. export class MeshButton3D extends Button3D {
  86167. /** @hidden */
  86168. protected _currentMesh: BABYLON.Mesh;
  86169. /**
  86170. * Creates a new 3D button based on a mesh
  86171. * @param mesh mesh to become a 3D button
  86172. * @param name defines the control name
  86173. */
  86174. constructor(mesh: BABYLON.Mesh, name?: string);
  86175. protected _getTypeName(): string;
  86176. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  86177. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  86178. }
  86179. }
  86180. declare module BABYLON.GUI {
  86181. /**
  86182. * Class used to create a container panel deployed on the surface of a plane
  86183. */
  86184. export class PlanePanel extends VolumeBasedPanel {
  86185. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86186. }
  86187. }
  86188. declare module BABYLON.GUI {
  86189. /**
  86190. * Class used to create a container panel where items get randomized planar mapping
  86191. */
  86192. export class ScatterPanel extends VolumeBasedPanel {
  86193. private _iteration;
  86194. /**
  86195. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  86196. */
  86197. get iteration(): BABYLON.float;
  86198. set iteration(value: BABYLON.float);
  86199. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86200. private _scatterMapping;
  86201. protected _finalProcessing(): void;
  86202. }
  86203. }
  86204. declare module BABYLON.GUI {
  86205. /**
  86206. * Class used to create a container panel deployed on the surface of a sphere
  86207. */
  86208. export class SpherePanel extends VolumeBasedPanel {
  86209. private _radius;
  86210. /**
  86211. * Gets or sets the radius of the sphere where to project controls (5 by default)
  86212. */
  86213. get radius(): BABYLON.float;
  86214. set radius(value: BABYLON.float);
  86215. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  86216. private _sphericalMapping;
  86217. }
  86218. }
  86219. declare module BABYLON.GUI {
  86220. /**
  86221. * Class used to create a stack panel in 3D on XY plane
  86222. */
  86223. export class StackPanel3D extends Container3D {
  86224. private _isVertical;
  86225. /**
  86226. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  86227. */
  86228. get isVertical(): boolean;
  86229. set isVertical(value: boolean);
  86230. /**
  86231. * Gets or sets the distance between elements
  86232. */
  86233. margin: number;
  86234. /**
  86235. * Creates new StackPanel
  86236. * @param isVertical
  86237. */
  86238. constructor(isVertical?: boolean);
  86239. protected _arrangeChildren(): void;
  86240. }
  86241. }
  86242. declare module BABYLON {
  86243. /**
  86244. * Configuration for glTF validation
  86245. */
  86246. export interface IGLTFValidationConfiguration {
  86247. /**
  86248. * The url of the glTF validator.
  86249. */
  86250. url: string;
  86251. }
  86252. /**
  86253. * glTF validation
  86254. */
  86255. export class GLTFValidation {
  86256. /**
  86257. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  86258. */
  86259. static Configuration: IGLTFValidationConfiguration;
  86260. private static _LoadScriptPromise;
  86261. /**
  86262. * Validate a glTF asset using the glTF-Validator.
  86263. * @param data The JSON of a glTF or the array buffer of a binary glTF
  86264. * @param rootUrl The root url for the glTF
  86265. * @param fileName The file name for the glTF
  86266. * @param getExternalResource The callback to get external resources for the glTF validator
  86267. * @returns A promise that resolves with the glTF validation results once complete
  86268. */
  86269. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  86270. }
  86271. }
  86272. declare module BABYLON {
  86273. /**
  86274. * Mode that determines the coordinate system to use.
  86275. */
  86276. export enum GLTFLoaderCoordinateSystemMode {
  86277. /**
  86278. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  86279. */
  86280. AUTO = 0,
  86281. /**
  86282. * Sets the useRightHandedSystem flag on the scene.
  86283. */
  86284. FORCE_RIGHT_HANDED = 1
  86285. }
  86286. /**
  86287. * Mode that determines what animations will start.
  86288. */
  86289. export enum GLTFLoaderAnimationStartMode {
  86290. /**
  86291. * No animation will start.
  86292. */
  86293. NONE = 0,
  86294. /**
  86295. * The first animation will start.
  86296. */
  86297. FIRST = 1,
  86298. /**
  86299. * All animations will start.
  86300. */
  86301. ALL = 2
  86302. }
  86303. /**
  86304. * Interface that contains the data for the glTF asset.
  86305. */
  86306. export interface IGLTFLoaderData {
  86307. /**
  86308. * The object that represents the glTF JSON.
  86309. */
  86310. json: Object;
  86311. /**
  86312. * The BIN chunk of a binary glTF.
  86313. */
  86314. bin: Nullable<IDataBuffer>;
  86315. }
  86316. /**
  86317. * Interface for extending the loader.
  86318. */
  86319. export interface IGLTFLoaderExtension {
  86320. /**
  86321. * The name of this extension.
  86322. */
  86323. readonly name: string;
  86324. /**
  86325. * Defines whether this extension is enabled.
  86326. */
  86327. enabled: boolean;
  86328. /**
  86329. * Defines the order of this extension.
  86330. * The loader sorts the extensions using these values when loading.
  86331. */
  86332. order?: number;
  86333. }
  86334. /**
  86335. * Loader state.
  86336. */
  86337. export enum GLTFLoaderState {
  86338. /**
  86339. * The asset is loading.
  86340. */
  86341. LOADING = 0,
  86342. /**
  86343. * The asset is ready for rendering.
  86344. */
  86345. READY = 1,
  86346. /**
  86347. * The asset is completely loaded.
  86348. */
  86349. COMPLETE = 2
  86350. }
  86351. /** @hidden */
  86352. export interface IGLTFLoader extends IDisposable {
  86353. readonly state: Nullable<GLTFLoaderState>;
  86354. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<ISceneLoaderAsyncResult>;
  86355. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  86356. }
  86357. /**
  86358. * File loader for loading glTF files into a scene.
  86359. */
  86360. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  86361. /** @hidden */
  86362. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86363. /** @hidden */
  86364. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  86365. /**
  86366. * Raised when the asset has been parsed
  86367. */
  86368. onParsedObservable: Observable<IGLTFLoaderData>;
  86369. private _onParsedObserver;
  86370. /**
  86371. * Raised when the asset has been parsed
  86372. */
  86373. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  86374. /**
  86375. * 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.
  86376. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  86377. * Defaults to true.
  86378. * @hidden
  86379. */
  86380. static IncrementalLoading: boolean;
  86381. /**
  86382. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  86383. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  86384. * @hidden
  86385. */
  86386. static HomogeneousCoordinates: boolean;
  86387. /**
  86388. * The coordinate system mode. Defaults to AUTO.
  86389. */
  86390. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  86391. /**
  86392. * The animation start mode. Defaults to FIRST.
  86393. */
  86394. animationStartMode: GLTFLoaderAnimationStartMode;
  86395. /**
  86396. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  86397. */
  86398. compileMaterials: boolean;
  86399. /**
  86400. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  86401. */
  86402. useClipPlane: boolean;
  86403. /**
  86404. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  86405. */
  86406. compileShadowGenerators: boolean;
  86407. /**
  86408. * Defines if the Alpha blended materials are only applied as coverage.
  86409. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  86410. * If true, no extra effects are applied to transparent pixels.
  86411. */
  86412. transparencyAsCoverage: boolean;
  86413. /**
  86414. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  86415. * Enabling will disable offline support and glTF validator.
  86416. * Defaults to false.
  86417. */
  86418. useRangeRequests: boolean;
  86419. /**
  86420. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  86421. */
  86422. createInstances: boolean;
  86423. /**
  86424. * 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.
  86425. */
  86426. alwaysComputeBoundingBox: boolean;
  86427. /**
  86428. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  86429. */
  86430. loadAllMaterials: boolean;
  86431. /**
  86432. * Function called before loading a url referenced by the asset.
  86433. */
  86434. preprocessUrlAsync: (url: string) => Promise<string>;
  86435. /**
  86436. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86437. * 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, ...)
  86438. */
  86439. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  86440. private _onMeshLoadedObserver;
  86441. /**
  86442. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  86443. * 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, ...)
  86444. */
  86445. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  86446. /**
  86447. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  86448. */
  86449. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  86450. private _onTextureLoadedObserver;
  86451. /**
  86452. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  86453. */
  86454. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  86455. /**
  86456. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  86457. */
  86458. readonly onMaterialLoadedObservable: Observable<Material>;
  86459. private _onMaterialLoadedObserver;
  86460. /**
  86461. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  86462. */
  86463. set onMaterialLoaded(callback: (material: Material) => void);
  86464. /**
  86465. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  86466. */
  86467. readonly onCameraLoadedObservable: Observable<Camera>;
  86468. private _onCameraLoadedObserver;
  86469. /**
  86470. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  86471. */
  86472. set onCameraLoaded(callback: (camera: Camera) => void);
  86473. /**
  86474. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  86475. * For assets with LODs, raised when all of the LODs are complete.
  86476. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86477. */
  86478. readonly onCompleteObservable: Observable<void>;
  86479. private _onCompleteObserver;
  86480. /**
  86481. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  86482. * For assets with LODs, raised when all of the LODs are complete.
  86483. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  86484. */
  86485. set onComplete(callback: () => void);
  86486. /**
  86487. * Observable raised when an error occurs.
  86488. */
  86489. readonly onErrorObservable: Observable<any>;
  86490. private _onErrorObserver;
  86491. /**
  86492. * Callback raised when an error occurs.
  86493. */
  86494. set onError(callback: (reason: any) => void);
  86495. /**
  86496. * Observable raised after the loader is disposed.
  86497. */
  86498. readonly onDisposeObservable: Observable<void>;
  86499. private _onDisposeObserver;
  86500. /**
  86501. * Callback raised after the loader is disposed.
  86502. */
  86503. set onDispose(callback: () => void);
  86504. /**
  86505. * Observable raised after a loader extension is created.
  86506. * Set additional options for a loader extension in this event.
  86507. */
  86508. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  86509. private _onExtensionLoadedObserver;
  86510. /**
  86511. * Callback raised after a loader extension is created.
  86512. */
  86513. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  86514. /**
  86515. * Defines if the loader logging is enabled.
  86516. */
  86517. get loggingEnabled(): boolean;
  86518. set loggingEnabled(value: boolean);
  86519. /**
  86520. * Defines if the loader should capture performance counters.
  86521. */
  86522. get capturePerformanceCounters(): boolean;
  86523. set capturePerformanceCounters(value: boolean);
  86524. /**
  86525. * Defines if the loader should validate the asset.
  86526. */
  86527. validate: boolean;
  86528. /**
  86529. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  86530. */
  86531. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  86532. private _onValidatedObserver;
  86533. /**
  86534. * Callback raised after a loader extension is created.
  86535. */
  86536. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  86537. private _loader;
  86538. private _progressCallback?;
  86539. private _requests;
  86540. private static magicBase64Encoded;
  86541. /**
  86542. * Name of the loader ("gltf")
  86543. */
  86544. name: string;
  86545. /** @hidden */
  86546. extensions: ISceneLoaderPluginExtensions;
  86547. /**
  86548. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  86549. */
  86550. dispose(): void;
  86551. /** @hidden */
  86552. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86553. /** @hidden */
  86554. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  86555. /** @hidden */
  86556. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  86557. /** @hidden */
  86558. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  86559. /** @hidden */
  86560. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  86561. /** @hidden */
  86562. canDirectLoad(data: string): boolean;
  86563. /** @hidden */
  86564. directLoad(scene: Scene, data: string): Promise<any>;
  86565. /**
  86566. * The callback that allows custom handling of the root url based on the response url.
  86567. * @param rootUrl the original root url
  86568. * @param responseURL the response url if available
  86569. * @returns the new root url
  86570. */
  86571. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  86572. /** @hidden */
  86573. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  86574. /**
  86575. * The loader state or null if the loader is not active.
  86576. */
  86577. get loaderState(): Nullable<GLTFLoaderState>;
  86578. /**
  86579. * Returns a promise that resolves when the asset is completely loaded.
  86580. * @returns a promise that resolves when the asset is completely loaded.
  86581. */
  86582. whenCompleteAsync(): Promise<void>;
  86583. /** @hidden */
  86584. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  86585. /** @hidden */
  86586. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  86587. private _onProgress;
  86588. private _validate;
  86589. private _getLoader;
  86590. private _parseJson;
  86591. private _unpackBinaryAsync;
  86592. private _unpackBinaryV1Async;
  86593. private _unpackBinaryV2Async;
  86594. private static _parseVersion;
  86595. private static _compareVersion;
  86596. private static readonly _logSpaces;
  86597. private _logIndentLevel;
  86598. private _loggingEnabled;
  86599. /** @hidden */
  86600. _log: (message: string) => void;
  86601. /** @hidden */
  86602. _logOpen(message: string): void;
  86603. /** @hidden */
  86604. _logClose(): void;
  86605. private _logEnabled;
  86606. private _logDisabled;
  86607. private _capturePerformanceCounters;
  86608. /** @hidden */
  86609. _startPerformanceCounter: (counterName: string) => void;
  86610. /** @hidden */
  86611. _endPerformanceCounter: (counterName: string) => void;
  86612. private _startPerformanceCounterEnabled;
  86613. private _startPerformanceCounterDisabled;
  86614. private _endPerformanceCounterEnabled;
  86615. private _endPerformanceCounterDisabled;
  86616. }
  86617. }
  86618. declare module BABYLON.GLTF1 {
  86619. /**
  86620. * Enums
  86621. * @hidden
  86622. */
  86623. export enum EComponentType {
  86624. BYTE = 5120,
  86625. UNSIGNED_BYTE = 5121,
  86626. SHORT = 5122,
  86627. UNSIGNED_SHORT = 5123,
  86628. FLOAT = 5126
  86629. }
  86630. /** @hidden */
  86631. export enum EShaderType {
  86632. FRAGMENT = 35632,
  86633. VERTEX = 35633
  86634. }
  86635. /** @hidden */
  86636. export enum EParameterType {
  86637. BYTE = 5120,
  86638. UNSIGNED_BYTE = 5121,
  86639. SHORT = 5122,
  86640. UNSIGNED_SHORT = 5123,
  86641. INT = 5124,
  86642. UNSIGNED_INT = 5125,
  86643. FLOAT = 5126,
  86644. FLOAT_VEC2 = 35664,
  86645. FLOAT_VEC3 = 35665,
  86646. FLOAT_VEC4 = 35666,
  86647. INT_VEC2 = 35667,
  86648. INT_VEC3 = 35668,
  86649. INT_VEC4 = 35669,
  86650. BOOL = 35670,
  86651. BOOL_VEC2 = 35671,
  86652. BOOL_VEC3 = 35672,
  86653. BOOL_VEC4 = 35673,
  86654. FLOAT_MAT2 = 35674,
  86655. FLOAT_MAT3 = 35675,
  86656. FLOAT_MAT4 = 35676,
  86657. SAMPLER_2D = 35678
  86658. }
  86659. /** @hidden */
  86660. export enum ETextureWrapMode {
  86661. CLAMP_TO_EDGE = 33071,
  86662. MIRRORED_REPEAT = 33648,
  86663. REPEAT = 10497
  86664. }
  86665. /** @hidden */
  86666. export enum ETextureFilterType {
  86667. NEAREST = 9728,
  86668. LINEAR = 9728,
  86669. NEAREST_MIPMAP_NEAREST = 9984,
  86670. LINEAR_MIPMAP_NEAREST = 9985,
  86671. NEAREST_MIPMAP_LINEAR = 9986,
  86672. LINEAR_MIPMAP_LINEAR = 9987
  86673. }
  86674. /** @hidden */
  86675. export enum ETextureFormat {
  86676. ALPHA = 6406,
  86677. RGB = 6407,
  86678. RGBA = 6408,
  86679. LUMINANCE = 6409,
  86680. LUMINANCE_ALPHA = 6410
  86681. }
  86682. /** @hidden */
  86683. export enum ECullingType {
  86684. FRONT = 1028,
  86685. BACK = 1029,
  86686. FRONT_AND_BACK = 1032
  86687. }
  86688. /** @hidden */
  86689. export enum EBlendingFunction {
  86690. ZERO = 0,
  86691. ONE = 1,
  86692. SRC_COLOR = 768,
  86693. ONE_MINUS_SRC_COLOR = 769,
  86694. DST_COLOR = 774,
  86695. ONE_MINUS_DST_COLOR = 775,
  86696. SRC_ALPHA = 770,
  86697. ONE_MINUS_SRC_ALPHA = 771,
  86698. DST_ALPHA = 772,
  86699. ONE_MINUS_DST_ALPHA = 773,
  86700. CONSTANT_COLOR = 32769,
  86701. ONE_MINUS_CONSTANT_COLOR = 32770,
  86702. CONSTANT_ALPHA = 32771,
  86703. ONE_MINUS_CONSTANT_ALPHA = 32772,
  86704. SRC_ALPHA_SATURATE = 776
  86705. }
  86706. /** @hidden */
  86707. export interface IGLTFProperty {
  86708. extensions?: {
  86709. [key: string]: any;
  86710. };
  86711. extras?: Object;
  86712. }
  86713. /** @hidden */
  86714. export interface IGLTFChildRootProperty extends IGLTFProperty {
  86715. name?: string;
  86716. }
  86717. /** @hidden */
  86718. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  86719. bufferView: string;
  86720. byteOffset: number;
  86721. byteStride: number;
  86722. count: number;
  86723. type: string;
  86724. componentType: EComponentType;
  86725. max?: number[];
  86726. min?: number[];
  86727. name?: string;
  86728. }
  86729. /** @hidden */
  86730. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  86731. buffer: string;
  86732. byteOffset: number;
  86733. byteLength: number;
  86734. byteStride: number;
  86735. target?: number;
  86736. }
  86737. /** @hidden */
  86738. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  86739. uri: string;
  86740. byteLength?: number;
  86741. type?: string;
  86742. }
  86743. /** @hidden */
  86744. export interface IGLTFShader extends IGLTFChildRootProperty {
  86745. uri: string;
  86746. type: EShaderType;
  86747. }
  86748. /** @hidden */
  86749. export interface IGLTFProgram extends IGLTFChildRootProperty {
  86750. attributes: string[];
  86751. fragmentShader: string;
  86752. vertexShader: string;
  86753. }
  86754. /** @hidden */
  86755. export interface IGLTFTechniqueParameter {
  86756. type: number;
  86757. count?: number;
  86758. semantic?: string;
  86759. node?: string;
  86760. value?: number | boolean | string | Array<any>;
  86761. source?: string;
  86762. babylonValue?: any;
  86763. }
  86764. /** @hidden */
  86765. export interface IGLTFTechniqueCommonProfile {
  86766. lightingModel: string;
  86767. texcoordBindings: Object;
  86768. parameters?: Array<any>;
  86769. }
  86770. /** @hidden */
  86771. export interface IGLTFTechniqueStatesFunctions {
  86772. blendColor?: number[];
  86773. blendEquationSeparate?: number[];
  86774. blendFuncSeparate?: number[];
  86775. colorMask: boolean[];
  86776. cullFace: number[];
  86777. }
  86778. /** @hidden */
  86779. export interface IGLTFTechniqueStates {
  86780. enable: number[];
  86781. functions: IGLTFTechniqueStatesFunctions;
  86782. }
  86783. /** @hidden */
  86784. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  86785. parameters: {
  86786. [key: string]: IGLTFTechniqueParameter;
  86787. };
  86788. program: string;
  86789. attributes: {
  86790. [key: string]: string;
  86791. };
  86792. uniforms: {
  86793. [key: string]: string;
  86794. };
  86795. states: IGLTFTechniqueStates;
  86796. }
  86797. /** @hidden */
  86798. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  86799. technique?: string;
  86800. values: string[];
  86801. }
  86802. /** @hidden */
  86803. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  86804. attributes: {
  86805. [key: string]: string;
  86806. };
  86807. indices: string;
  86808. material: string;
  86809. mode?: number;
  86810. }
  86811. /** @hidden */
  86812. export interface IGLTFMesh extends IGLTFChildRootProperty {
  86813. primitives: IGLTFMeshPrimitive[];
  86814. }
  86815. /** @hidden */
  86816. export interface IGLTFImage extends IGLTFChildRootProperty {
  86817. uri: string;
  86818. }
  86819. /** @hidden */
  86820. export interface IGLTFSampler extends IGLTFChildRootProperty {
  86821. magFilter?: number;
  86822. minFilter?: number;
  86823. wrapS?: number;
  86824. wrapT?: number;
  86825. }
  86826. /** @hidden */
  86827. export interface IGLTFTexture extends IGLTFChildRootProperty {
  86828. sampler: string;
  86829. source: string;
  86830. format?: ETextureFormat;
  86831. internalFormat?: ETextureFormat;
  86832. target?: number;
  86833. type?: number;
  86834. babylonTexture?: Texture;
  86835. }
  86836. /** @hidden */
  86837. export interface IGLTFAmbienLight {
  86838. color?: number[];
  86839. }
  86840. /** @hidden */
  86841. export interface IGLTFDirectionalLight {
  86842. color?: number[];
  86843. }
  86844. /** @hidden */
  86845. export interface IGLTFPointLight {
  86846. color?: number[];
  86847. constantAttenuation?: number;
  86848. linearAttenuation?: number;
  86849. quadraticAttenuation?: number;
  86850. }
  86851. /** @hidden */
  86852. export interface IGLTFSpotLight {
  86853. color?: number[];
  86854. constantAttenuation?: number;
  86855. fallOfAngle?: number;
  86856. fallOffExponent?: number;
  86857. linearAttenuation?: number;
  86858. quadraticAttenuation?: number;
  86859. }
  86860. /** @hidden */
  86861. export interface IGLTFLight extends IGLTFChildRootProperty {
  86862. type: string;
  86863. }
  86864. /** @hidden */
  86865. export interface IGLTFCameraOrthographic {
  86866. xmag: number;
  86867. ymag: number;
  86868. zfar: number;
  86869. znear: number;
  86870. }
  86871. /** @hidden */
  86872. export interface IGLTFCameraPerspective {
  86873. aspectRatio: number;
  86874. yfov: number;
  86875. zfar: number;
  86876. znear: number;
  86877. }
  86878. /** @hidden */
  86879. export interface IGLTFCamera extends IGLTFChildRootProperty {
  86880. type: string;
  86881. }
  86882. /** @hidden */
  86883. export interface IGLTFAnimationChannelTarget {
  86884. id: string;
  86885. path: string;
  86886. }
  86887. /** @hidden */
  86888. export interface IGLTFAnimationChannel {
  86889. sampler: string;
  86890. target: IGLTFAnimationChannelTarget;
  86891. }
  86892. /** @hidden */
  86893. export interface IGLTFAnimationSampler {
  86894. input: string;
  86895. output: string;
  86896. interpolation?: string;
  86897. }
  86898. /** @hidden */
  86899. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  86900. channels?: IGLTFAnimationChannel[];
  86901. parameters?: {
  86902. [key: string]: string;
  86903. };
  86904. samplers?: {
  86905. [key: string]: IGLTFAnimationSampler;
  86906. };
  86907. }
  86908. /** @hidden */
  86909. export interface IGLTFNodeInstanceSkin {
  86910. skeletons: string[];
  86911. skin: string;
  86912. meshes: string[];
  86913. }
  86914. /** @hidden */
  86915. export interface IGLTFSkins extends IGLTFChildRootProperty {
  86916. bindShapeMatrix: number[];
  86917. inverseBindMatrices: string;
  86918. jointNames: string[];
  86919. babylonSkeleton?: Skeleton;
  86920. }
  86921. /** @hidden */
  86922. export interface IGLTFNode extends IGLTFChildRootProperty {
  86923. camera?: string;
  86924. children: string[];
  86925. skin?: string;
  86926. jointName?: string;
  86927. light?: string;
  86928. matrix: number[];
  86929. mesh?: string;
  86930. meshes?: string[];
  86931. rotation?: number[];
  86932. scale?: number[];
  86933. translation?: number[];
  86934. babylonNode?: Node;
  86935. }
  86936. /** @hidden */
  86937. export interface IGLTFScene extends IGLTFChildRootProperty {
  86938. nodes: string[];
  86939. }
  86940. /** @hidden */
  86941. export interface IGLTFRuntime {
  86942. extensions: {
  86943. [key: string]: any;
  86944. };
  86945. accessors: {
  86946. [key: string]: IGLTFAccessor;
  86947. };
  86948. buffers: {
  86949. [key: string]: IGLTFBuffer;
  86950. };
  86951. bufferViews: {
  86952. [key: string]: IGLTFBufferView;
  86953. };
  86954. meshes: {
  86955. [key: string]: IGLTFMesh;
  86956. };
  86957. lights: {
  86958. [key: string]: IGLTFLight;
  86959. };
  86960. cameras: {
  86961. [key: string]: IGLTFCamera;
  86962. };
  86963. nodes: {
  86964. [key: string]: IGLTFNode;
  86965. };
  86966. images: {
  86967. [key: string]: IGLTFImage;
  86968. };
  86969. textures: {
  86970. [key: string]: IGLTFTexture;
  86971. };
  86972. shaders: {
  86973. [key: string]: IGLTFShader;
  86974. };
  86975. programs: {
  86976. [key: string]: IGLTFProgram;
  86977. };
  86978. samplers: {
  86979. [key: string]: IGLTFSampler;
  86980. };
  86981. techniques: {
  86982. [key: string]: IGLTFTechnique;
  86983. };
  86984. materials: {
  86985. [key: string]: IGLTFMaterial;
  86986. };
  86987. animations: {
  86988. [key: string]: IGLTFAnimation;
  86989. };
  86990. skins: {
  86991. [key: string]: IGLTFSkins;
  86992. };
  86993. currentScene?: Object;
  86994. scenes: {
  86995. [key: string]: IGLTFScene;
  86996. };
  86997. extensionsUsed: string[];
  86998. extensionsRequired?: string[];
  86999. buffersCount: number;
  87000. shaderscount: number;
  87001. scene: Scene;
  87002. rootUrl: string;
  87003. loadedBufferCount: number;
  87004. loadedBufferViews: {
  87005. [name: string]: ArrayBufferView;
  87006. };
  87007. loadedShaderCount: number;
  87008. importOnlyMeshes: boolean;
  87009. importMeshesNames?: string[];
  87010. dummyNodes: Node[];
  87011. forAssetContainer: boolean;
  87012. }
  87013. /** @hidden */
  87014. export interface INodeToRoot {
  87015. bone: Bone;
  87016. node: IGLTFNode;
  87017. id: string;
  87018. }
  87019. /** @hidden */
  87020. export interface IJointNode {
  87021. node: IGLTFNode;
  87022. id: string;
  87023. }
  87024. }
  87025. declare module BABYLON.GLTF1 {
  87026. /**
  87027. * Utils functions for GLTF
  87028. * @hidden
  87029. */
  87030. export class GLTFUtils {
  87031. /**
  87032. * Sets the given "parameter" matrix
  87033. * @param scene: the Scene object
  87034. * @param source: the source node where to pick the matrix
  87035. * @param parameter: the GLTF technique parameter
  87036. * @param uniformName: the name of the shader's uniform
  87037. * @param shaderMaterial: the shader material
  87038. */
  87039. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  87040. /**
  87041. * Sets the given "parameter" matrix
  87042. * @param shaderMaterial: the shader material
  87043. * @param uniform: the name of the shader's uniform
  87044. * @param value: the value of the uniform
  87045. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  87046. */
  87047. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  87048. /**
  87049. * Returns the wrap mode of the texture
  87050. * @param mode: the mode value
  87051. */
  87052. static GetWrapMode(mode: number): number;
  87053. /**
  87054. * Returns the byte stride giving an accessor
  87055. * @param accessor: the GLTF accessor objet
  87056. */
  87057. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  87058. /**
  87059. * Returns the texture filter mode giving a mode value
  87060. * @param mode: the filter mode value
  87061. */
  87062. static GetTextureFilterMode(mode: number): ETextureFilterType;
  87063. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  87064. /**
  87065. * Returns a buffer from its accessor
  87066. * @param gltfRuntime: the GLTF runtime
  87067. * @param accessor: the GLTF accessor
  87068. */
  87069. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  87070. /**
  87071. * Decodes a buffer view into a string
  87072. * @param view: the buffer view
  87073. */
  87074. static DecodeBufferToText(view: ArrayBufferView): string;
  87075. /**
  87076. * Returns the default material of gltf. Related to
  87077. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  87078. * @param scene: the Babylon.js scene
  87079. */
  87080. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  87081. private static _DefaultMaterial;
  87082. }
  87083. }
  87084. declare module BABYLON.GLTF1 {
  87085. /**
  87086. * Implementation of the base glTF spec
  87087. * @hidden
  87088. */
  87089. export class GLTFLoaderBase {
  87090. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  87091. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87092. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  87093. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87094. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  87095. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87096. }
  87097. /**
  87098. * glTF V1 Loader
  87099. * @hidden
  87100. */
  87101. export class GLTFLoader implements IGLTFLoader {
  87102. static Extensions: {
  87103. [name: string]: GLTFLoaderExtension;
  87104. };
  87105. static RegisterExtension(extension: GLTFLoaderExtension): void;
  87106. state: Nullable<GLTFLoaderState>;
  87107. dispose(): void;
  87108. private _importMeshAsync;
  87109. /**
  87110. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  87111. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  87112. * @param scene the scene the meshes should be added to
  87113. * @param forAssetContainer defines if the entities must be stored in the scene
  87114. * @param data gltf data containing information of the meshes in a loaded file
  87115. * @param rootUrl root url to load from
  87116. * @param onProgress event that fires when loading progress has occured
  87117. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  87118. */
  87119. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<ISceneLoaderAsyncResult>;
  87120. private _loadAsync;
  87121. /**
  87122. * Imports all objects from a loaded gltf file and adds them to the scene
  87123. * @param scene the scene the objects should be added to
  87124. * @param data gltf data containing information of the meshes in a loaded file
  87125. * @param rootUrl root url to load from
  87126. * @param onProgress event that fires when loading progress has occured
  87127. * @returns a promise which completes when objects have been loaded to the scene
  87128. */
  87129. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  87130. private _loadShadersAsync;
  87131. private _loadBuffersAsync;
  87132. private _createNodes;
  87133. }
  87134. /** @hidden */
  87135. export abstract class GLTFLoaderExtension {
  87136. private _name;
  87137. constructor(name: string);
  87138. get name(): string;
  87139. /**
  87140. * Defines an override for loading the runtime
  87141. * Return true to stop further extensions from loading the runtime
  87142. */
  87143. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  87144. /**
  87145. * Defines an onverride for creating gltf runtime
  87146. * Return true to stop further extensions from creating the runtime
  87147. */
  87148. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  87149. /**
  87150. * Defines an override for loading buffers
  87151. * Return true to stop further extensions from loading this buffer
  87152. */
  87153. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  87154. /**
  87155. * Defines an override for loading texture buffers
  87156. * Return true to stop further extensions from loading this texture data
  87157. */
  87158. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87159. /**
  87160. * Defines an override for creating textures
  87161. * Return true to stop further extensions from loading this texture
  87162. */
  87163. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  87164. /**
  87165. * Defines an override for loading shader strings
  87166. * Return true to stop further extensions from loading this shader data
  87167. */
  87168. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87169. /**
  87170. * Defines an override for loading materials
  87171. * Return true to stop further extensions from loading this material
  87172. */
  87173. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87174. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  87175. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  87176. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  87177. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  87178. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  87179. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  87180. private static LoadTextureBufferAsync;
  87181. private static CreateTextureAsync;
  87182. private static ApplyExtensions;
  87183. }
  87184. }
  87185. declare module BABYLON.GLTF1 {
  87186. /** @hidden */
  87187. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  87188. private _bin;
  87189. constructor();
  87190. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  87191. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87192. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  87193. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  87194. }
  87195. }
  87196. declare module BABYLON.GLTF1 {
  87197. /** @hidden */
  87198. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  87199. constructor();
  87200. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  87201. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  87202. private _loadTexture;
  87203. }
  87204. }
  87205. declare module BABYLON.GLTF2.Loader {
  87206. /**
  87207. * Loader interface with an index field.
  87208. */
  87209. export interface IArrayItem {
  87210. /**
  87211. * The index of this item in the array.
  87212. */
  87213. index: number;
  87214. }
  87215. /**
  87216. * Loader interface with additional members.
  87217. */
  87218. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  87219. /** @hidden */
  87220. _data?: Promise<ArrayBufferView>;
  87221. /** @hidden */
  87222. _babylonVertexBuffer?: Promise<VertexBuffer>;
  87223. }
  87224. /**
  87225. * Loader interface with additional members.
  87226. */
  87227. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  87228. }
  87229. /** @hidden */
  87230. export interface _IAnimationSamplerData {
  87231. input: Float32Array;
  87232. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  87233. output: Float32Array;
  87234. }
  87235. /**
  87236. * Loader interface with additional members.
  87237. */
  87238. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  87239. /** @hidden */
  87240. _data?: Promise<_IAnimationSamplerData>;
  87241. }
  87242. /**
  87243. * Loader interface with additional members.
  87244. */
  87245. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  87246. channels: IAnimationChannel[];
  87247. samplers: IAnimationSampler[];
  87248. /** @hidden */
  87249. _babylonAnimationGroup?: AnimationGroup;
  87250. }
  87251. /**
  87252. * Loader interface with additional members.
  87253. */
  87254. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  87255. /** @hidden */
  87256. _data?: Promise<ArrayBufferView>;
  87257. }
  87258. /**
  87259. * Loader interface with additional members.
  87260. */
  87261. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  87262. /** @hidden */
  87263. _data?: Promise<ArrayBufferView>;
  87264. /** @hidden */
  87265. _babylonBuffer?: Promise<Buffer>;
  87266. }
  87267. /**
  87268. * Loader interface with additional members.
  87269. */
  87270. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  87271. }
  87272. /**
  87273. * Loader interface with additional members.
  87274. */
  87275. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  87276. /** @hidden */
  87277. _data?: Promise<ArrayBufferView>;
  87278. }
  87279. /**
  87280. * Loader interface with additional members.
  87281. */
  87282. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  87283. }
  87284. /**
  87285. * Loader interface with additional members.
  87286. */
  87287. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  87288. }
  87289. /**
  87290. * Loader interface with additional members.
  87291. */
  87292. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  87293. baseColorTexture?: ITextureInfo;
  87294. metallicRoughnessTexture?: ITextureInfo;
  87295. }
  87296. /**
  87297. * Loader interface with additional members.
  87298. */
  87299. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  87300. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  87301. normalTexture?: IMaterialNormalTextureInfo;
  87302. occlusionTexture?: IMaterialOcclusionTextureInfo;
  87303. emissiveTexture?: ITextureInfo;
  87304. /** @hidden */
  87305. _data?: {
  87306. [babylonDrawMode: number]: {
  87307. babylonMaterial: Material;
  87308. babylonMeshes: AbstractMesh[];
  87309. promise: Promise<void>;
  87310. };
  87311. };
  87312. }
  87313. /**
  87314. * Loader interface with additional members.
  87315. */
  87316. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  87317. primitives: IMeshPrimitive[];
  87318. }
  87319. /**
  87320. * Loader interface with additional members.
  87321. */
  87322. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  87323. /** @hidden */
  87324. _instanceData?: {
  87325. babylonSourceMesh: Mesh;
  87326. promise: Promise<any>;
  87327. };
  87328. }
  87329. /**
  87330. * Loader interface with additional members.
  87331. */
  87332. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  87333. /**
  87334. * The parent glTF node.
  87335. */
  87336. parent?: INode;
  87337. /** @hidden */
  87338. _babylonTransformNode?: TransformNode;
  87339. /** @hidden */
  87340. _primitiveBabylonMeshes?: AbstractMesh[];
  87341. /** @hidden */
  87342. _babylonBones?: Bone[];
  87343. /** @hidden */
  87344. _numMorphTargets?: number;
  87345. }
  87346. /** @hidden */
  87347. export interface _ISamplerData {
  87348. noMipMaps: boolean;
  87349. samplingMode: number;
  87350. wrapU: number;
  87351. wrapV: number;
  87352. }
  87353. /**
  87354. * Loader interface with additional members.
  87355. */
  87356. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  87357. /** @hidden */
  87358. _data?: _ISamplerData;
  87359. }
  87360. /**
  87361. * Loader interface with additional members.
  87362. */
  87363. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  87364. }
  87365. /**
  87366. * Loader interface with additional members.
  87367. */
  87368. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  87369. /** @hidden */
  87370. _data?: {
  87371. babylonSkeleton: Skeleton;
  87372. promise: Promise<void>;
  87373. };
  87374. }
  87375. /**
  87376. * Loader interface with additional members.
  87377. */
  87378. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  87379. /** @hidden */
  87380. _textureInfo: ITextureInfo;
  87381. }
  87382. /**
  87383. * Loader interface with additional members.
  87384. */
  87385. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  87386. /** false or undefined if the texture holds color data (true if data are roughness, normal, ...) */
  87387. nonColorData?: boolean;
  87388. }
  87389. /**
  87390. * Loader interface with additional members.
  87391. */
  87392. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  87393. accessors?: IAccessor[];
  87394. animations?: IAnimation[];
  87395. buffers?: IBuffer[];
  87396. bufferViews?: IBufferView[];
  87397. cameras?: ICamera[];
  87398. images?: IImage[];
  87399. materials?: IMaterial[];
  87400. meshes?: IMesh[];
  87401. nodes?: INode[];
  87402. samplers?: ISampler[];
  87403. scenes?: IScene[];
  87404. skins?: ISkin[];
  87405. textures?: ITexture[];
  87406. }
  87407. }
  87408. declare module BABYLON.GLTF2 {
  87409. /**
  87410. * Interface for a glTF loader extension.
  87411. */
  87412. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  87413. /**
  87414. * Called after the loader state changes to LOADING.
  87415. */
  87416. onLoading?(): void;
  87417. /**
  87418. * Called after the loader state changes to READY.
  87419. */
  87420. onReady?(): void;
  87421. /**
  87422. * Define this method to modify the default behavior when loading scenes.
  87423. * @param context The context when loading the asset
  87424. * @param scene The glTF scene property
  87425. * @returns A promise that resolves when the load is complete or null if not handled
  87426. */
  87427. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  87428. /**
  87429. * Define this method to modify the default behavior when loading nodes.
  87430. * @param context The context when loading the asset
  87431. * @param node The glTF node property
  87432. * @param assign A function called synchronously after parsing the glTF properties
  87433. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  87434. */
  87435. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87436. /**
  87437. * Define this method to modify the default behavior when loading cameras.
  87438. * @param context The context when loading the asset
  87439. * @param camera The glTF camera property
  87440. * @param assign A function called synchronously after parsing the glTF properties
  87441. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  87442. */
  87443. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  87444. /**
  87445. * @hidden
  87446. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  87447. * @param context The context when loading the asset
  87448. * @param primitive The glTF mesh primitive property
  87449. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  87450. */
  87451. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  87452. /**
  87453. * @hidden
  87454. * Define this method to modify the default behavior when loading data for mesh primitives.
  87455. * @param context The context when loading the asset
  87456. * @param name The mesh name when loading the asset
  87457. * @param node The glTF node when loading the asset
  87458. * @param mesh The glTF mesh when loading the asset
  87459. * @param primitive The glTF mesh primitive property
  87460. * @param assign A function called synchronously after parsing the glTF properties
  87461. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87462. */
  87463. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  87464. /**
  87465. * @hidden
  87466. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  87467. * @param context The context when loading the asset
  87468. * @param material The glTF material property
  87469. * @param assign A function called synchronously after parsing the glTF properties
  87470. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  87471. */
  87472. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  87473. /**
  87474. * Define this method to modify the default behavior when creating materials.
  87475. * @param context The context when loading the asset
  87476. * @param material The glTF material property
  87477. * @param babylonDrawMode The draw mode for the Babylon material
  87478. * @returns The Babylon material or null if not handled
  87479. */
  87480. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  87481. /**
  87482. * Define this method to modify the default behavior when loading material properties.
  87483. * @param context The context when loading the asset
  87484. * @param material The glTF material property
  87485. * @param babylonMaterial The Babylon material
  87486. * @returns A promise that resolves when the load is complete or null if not handled
  87487. */
  87488. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  87489. /**
  87490. * Define this method to modify the default behavior when loading texture infos.
  87491. * @param context The context when loading the asset
  87492. * @param textureInfo The glTF texture info property
  87493. * @param assign A function called synchronously after parsing the glTF properties
  87494. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87495. */
  87496. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87497. /**
  87498. * @hidden
  87499. * Define this method to modify the default behavior when loading textures.
  87500. * @param context The context when loading the asset
  87501. * @param texture The glTF texture property
  87502. * @param assign A function called synchronously after parsing the glTF properties
  87503. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  87504. */
  87505. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87506. /**
  87507. * Define this method to modify the default behavior when loading animations.
  87508. * @param context The context when loading the asset
  87509. * @param animation The glTF animation property
  87510. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  87511. */
  87512. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  87513. /**
  87514. * @hidden
  87515. * Define this method to modify the default behavior when loading skins.
  87516. * @param context The context when loading the asset
  87517. * @param node The glTF node property
  87518. * @param skin The glTF skin property
  87519. * @returns A promise that resolves when the load is complete or null if not handled
  87520. */
  87521. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  87522. /**
  87523. * @hidden
  87524. * Define this method to modify the default behavior when loading uris.
  87525. * @param context The context when loading the asset
  87526. * @param property The glTF property associated with the uri
  87527. * @param uri The uri to load
  87528. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87529. */
  87530. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  87531. /**
  87532. * Define this method to modify the default behavior when loading buffer views.
  87533. * @param context The context when loading the asset
  87534. * @param bufferView The glTF buffer view property
  87535. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87536. */
  87537. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87538. /**
  87539. * Define this method to modify the default behavior when loading buffers.
  87540. * @param context The context when loading the asset
  87541. * @param buffer The glTF buffer property
  87542. * @param byteOffset The byte offset to load
  87543. * @param byteLength The byte length to load
  87544. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  87545. */
  87546. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  87547. }
  87548. }
  87549. declare module BABYLON.GLTF2 {
  87550. /**
  87551. * Helper class for working with arrays when loading the glTF asset
  87552. */
  87553. export class ArrayItem {
  87554. /**
  87555. * Gets an item from the given array.
  87556. * @param context The context when loading the asset
  87557. * @param array The array to get the item from
  87558. * @param index The index to the array
  87559. * @returns The array item
  87560. */
  87561. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  87562. /**
  87563. * Assign an `index` field to each item of the given array.
  87564. * @param array The array of items
  87565. */
  87566. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  87567. }
  87568. /**
  87569. * The glTF 2.0 loader
  87570. */
  87571. export class GLTFLoader implements IGLTFLoader {
  87572. /** @hidden */
  87573. _completePromises: Promise<any>[];
  87574. /** @hidden */
  87575. _forAssetContainer: boolean;
  87576. /** Storage */
  87577. _babylonLights: Light[];
  87578. /** @hidden */
  87579. _disableInstancedMesh: number;
  87580. private _disposed;
  87581. private _parent;
  87582. private _state;
  87583. private _extensions;
  87584. private _rootUrl;
  87585. private _fileName;
  87586. private _uniqueRootUrl;
  87587. private _gltf;
  87588. private _bin;
  87589. private _babylonScene;
  87590. private _rootBabylonMesh;
  87591. private _defaultBabylonMaterialData;
  87592. private static _RegisteredExtensions;
  87593. /**
  87594. * The default glTF sampler.
  87595. */
  87596. static readonly DefaultSampler: ISampler;
  87597. /**
  87598. * Registers a loader extension.
  87599. * @param name The name of the loader extension.
  87600. * @param factory The factory function that creates the loader extension.
  87601. */
  87602. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  87603. /**
  87604. * Unregisters a loader extension.
  87605. * @param name The name of the loader extension.
  87606. * @returns A boolean indicating whether the extension has been unregistered
  87607. */
  87608. static UnregisterExtension(name: string): boolean;
  87609. /**
  87610. * The loader state.
  87611. */
  87612. get state(): Nullable<GLTFLoaderState>;
  87613. /**
  87614. * The object that represents the glTF JSON.
  87615. */
  87616. get gltf(): IGLTF;
  87617. /**
  87618. * The BIN chunk of a binary glTF.
  87619. */
  87620. get bin(): Nullable<IDataBuffer>;
  87621. /**
  87622. * The parent file loader.
  87623. */
  87624. get parent(): GLTFFileLoader;
  87625. /**
  87626. * The Babylon scene when loading the asset.
  87627. */
  87628. get babylonScene(): Scene;
  87629. /**
  87630. * The root Babylon mesh when loading the asset.
  87631. */
  87632. get rootBabylonMesh(): Mesh;
  87633. /** @hidden */
  87634. constructor(parent: GLTFFileLoader);
  87635. /** @hidden */
  87636. dispose(): void;
  87637. /** @hidden */
  87638. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  87639. /** @hidden */
  87640. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  87641. private _loadAsync;
  87642. private _loadData;
  87643. private _setupData;
  87644. private _loadExtensions;
  87645. private _checkExtensions;
  87646. private _setState;
  87647. private _createRootNode;
  87648. /**
  87649. * Loads a glTF scene.
  87650. * @param context The context when loading the asset
  87651. * @param scene The glTF scene property
  87652. * @returns A promise that resolves when the load is complete
  87653. */
  87654. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  87655. private _forEachPrimitive;
  87656. private _getGeometries;
  87657. private _getMeshes;
  87658. private _getTransformNodes;
  87659. private _getSkeletons;
  87660. private _getAnimationGroups;
  87661. private _startAnimations;
  87662. /**
  87663. * Loads a glTF node.
  87664. * @param context The context when loading the asset
  87665. * @param node The glTF node property
  87666. * @param assign A function called synchronously after parsing the glTF properties
  87667. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  87668. */
  87669. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  87670. private _loadMeshAsync;
  87671. /**
  87672. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  87673. * @param context The context when loading the asset
  87674. * @param name The mesh name when loading the asset
  87675. * @param node The glTF node when loading the asset
  87676. * @param mesh The glTF mesh when loading the asset
  87677. * @param primitive The glTF mesh primitive property
  87678. * @param assign A function called synchronously after parsing the glTF properties
  87679. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  87680. */
  87681. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  87682. private _loadVertexDataAsync;
  87683. private _createMorphTargets;
  87684. private _loadMorphTargetsAsync;
  87685. private _loadMorphTargetVertexDataAsync;
  87686. private static _LoadTransform;
  87687. private _loadSkinAsync;
  87688. private _loadBones;
  87689. private _loadBone;
  87690. private _loadSkinInverseBindMatricesDataAsync;
  87691. private _updateBoneMatrices;
  87692. private _getNodeMatrix;
  87693. /**
  87694. * Loads a glTF camera.
  87695. * @param context The context when loading the asset
  87696. * @param camera The glTF camera property
  87697. * @param assign A function called synchronously after parsing the glTF properties
  87698. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  87699. */
  87700. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  87701. private _loadAnimationsAsync;
  87702. /**
  87703. * Loads a glTF animation.
  87704. * @param context The context when loading the asset
  87705. * @param animation The glTF animation property
  87706. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  87707. */
  87708. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  87709. /**
  87710. * @hidden Loads a glTF animation channel.
  87711. * @param context The context when loading the asset
  87712. * @param animationContext The context of the animation when loading the asset
  87713. * @param animation The glTF animation property
  87714. * @param channel The glTF animation channel property
  87715. * @param babylonAnimationGroup The babylon animation group property
  87716. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  87717. * @returns A void promise when the channel load is complete
  87718. */
  87719. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  87720. private _loadAnimationSamplerAsync;
  87721. /**
  87722. * Loads a glTF buffer.
  87723. * @param context The context when loading the asset
  87724. * @param buffer The glTF buffer property
  87725. * @param byteOffset The byte offset to use
  87726. * @param byteLength The byte length to use
  87727. * @returns A promise that resolves with the loaded data when the load is complete
  87728. */
  87729. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  87730. /**
  87731. * Loads a glTF buffer view.
  87732. * @param context The context when loading the asset
  87733. * @param bufferView The glTF buffer view property
  87734. * @returns A promise that resolves with the loaded data when the load is complete
  87735. */
  87736. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  87737. private _loadAccessorAsync;
  87738. /** @hidden */
  87739. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  87740. private _loadIndicesAccessorAsync;
  87741. private _loadVertexBufferViewAsync;
  87742. private _loadVertexAccessorAsync;
  87743. private _loadMaterialMetallicRoughnessPropertiesAsync;
  87744. /** @hidden */
  87745. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  87746. private _createDefaultMaterial;
  87747. /**
  87748. * Creates a Babylon material from a glTF material.
  87749. * @param context The context when loading the asset
  87750. * @param material The glTF material property
  87751. * @param babylonDrawMode The draw mode for the Babylon material
  87752. * @returns The Babylon material
  87753. */
  87754. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  87755. /**
  87756. * Loads properties from a glTF material into a Babylon material.
  87757. * @param context The context when loading the asset
  87758. * @param material The glTF material property
  87759. * @param babylonMaterial The Babylon material
  87760. * @returns A promise that resolves when the load is complete
  87761. */
  87762. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87763. /**
  87764. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  87765. * @param context The context when loading the asset
  87766. * @param material The glTF material property
  87767. * @param babylonMaterial The Babylon material
  87768. * @returns A promise that resolves when the load is complete
  87769. */
  87770. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  87771. /**
  87772. * Loads the alpha properties from a glTF material into a Babylon material.
  87773. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  87774. * @param context The context when loading the asset
  87775. * @param material The glTF material property
  87776. * @param babylonMaterial The Babylon material
  87777. */
  87778. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  87779. /**
  87780. * Loads a glTF texture info.
  87781. * @param context The context when loading the asset
  87782. * @param textureInfo The glTF texture info property
  87783. * @param assign A function called synchronously after parsing the glTF properties
  87784. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  87785. */
  87786. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87787. /** @hidden */
  87788. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  87789. /** @hidden */
  87790. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void, textureLoaderOptions?: any): Promise<BaseTexture>;
  87791. private _loadSampler;
  87792. /**
  87793. * Loads a glTF image.
  87794. * @param context The context when loading the asset
  87795. * @param image The glTF image property
  87796. * @returns A promise that resolves with the loaded data when the load is complete
  87797. */
  87798. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  87799. /**
  87800. * Loads a glTF uri.
  87801. * @param context The context when loading the asset
  87802. * @param property The glTF property associated with the uri
  87803. * @param uri The base64 or relative uri
  87804. * @returns A promise that resolves with the loaded data when the load is complete
  87805. */
  87806. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  87807. /**
  87808. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  87809. * @param babylonObject the Babylon object with metadata
  87810. * @param pointer the JSON pointer
  87811. */
  87812. static AddPointerMetadata(babylonObject: {
  87813. metadata: any;
  87814. }, pointer: string): void;
  87815. private static _GetTextureWrapMode;
  87816. private static _GetTextureSamplingMode;
  87817. private static _GetTypedArrayConstructor;
  87818. private static _GetTypedArray;
  87819. private static _GetNumComponents;
  87820. private static _ValidateUri;
  87821. /** @hidden */
  87822. static _GetDrawMode(context: string, mode: number | undefined): number;
  87823. private _compileMaterialsAsync;
  87824. private _compileShadowGeneratorsAsync;
  87825. private _forEachExtensions;
  87826. private _applyExtensions;
  87827. private _extensionsOnLoading;
  87828. private _extensionsOnReady;
  87829. private _extensionsLoadSceneAsync;
  87830. private _extensionsLoadNodeAsync;
  87831. private _extensionsLoadCameraAsync;
  87832. private _extensionsLoadVertexDataAsync;
  87833. private _extensionsLoadMeshPrimitiveAsync;
  87834. private _extensionsLoadMaterialAsync;
  87835. private _extensionsCreateMaterial;
  87836. private _extensionsLoadMaterialPropertiesAsync;
  87837. private _extensionsLoadTextureInfoAsync;
  87838. private _extensionsLoadTextureAsync;
  87839. private _extensionsLoadAnimationAsync;
  87840. private _extensionsLoadSkinAsync;
  87841. private _extensionsLoadUriAsync;
  87842. private _extensionsLoadBufferViewAsync;
  87843. private _extensionsLoadBufferAsync;
  87844. /**
  87845. * Helper method called by a loader extension to load an glTF extension.
  87846. * @param context The context when loading the asset
  87847. * @param property The glTF property to load the extension from
  87848. * @param extensionName The name of the extension to load
  87849. * @param actionAsync The action to run
  87850. * @returns The promise returned by actionAsync or null if the extension does not exist
  87851. */
  87852. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87853. /**
  87854. * Helper method called by a loader extension to load a glTF extra.
  87855. * @param context The context when loading the asset
  87856. * @param property The glTF property to load the extra from
  87857. * @param extensionName The name of the extension to load
  87858. * @param actionAsync The action to run
  87859. * @returns The promise returned by actionAsync or null if the extra does not exist
  87860. */
  87861. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  87862. /**
  87863. * Checks for presence of an extension.
  87864. * @param name The name of the extension to check
  87865. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  87866. */
  87867. isExtensionUsed(name: string): boolean;
  87868. /**
  87869. * Increments the indentation level and logs a message.
  87870. * @param message The message to log
  87871. */
  87872. logOpen(message: string): void;
  87873. /**
  87874. * Decrements the indentation level.
  87875. */
  87876. logClose(): void;
  87877. /**
  87878. * Logs a message
  87879. * @param message The message to log
  87880. */
  87881. log(message: string): void;
  87882. /**
  87883. * Starts a performance counter.
  87884. * @param counterName The name of the performance counter
  87885. */
  87886. startPerformanceCounter(counterName: string): void;
  87887. /**
  87888. * Ends a performance counter.
  87889. * @param counterName The name of the performance counter
  87890. */
  87891. endPerformanceCounter(counterName: string): void;
  87892. }
  87893. }
  87894. declare module BABYLON.GLTF2.Loader.Extensions {
  87895. /** @hidden */
  87896. interface IEXTLightsImageBased_LightImageBased {
  87897. _babylonTexture?: BaseTexture;
  87898. _loaded?: Promise<void>;
  87899. }
  87900. /**
  87901. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  87902. */
  87903. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  87904. /**
  87905. * The name of this extension.
  87906. */
  87907. readonly name: string;
  87908. /**
  87909. * Defines whether this extension is enabled.
  87910. */
  87911. enabled: boolean;
  87912. private _loader;
  87913. private _lights?;
  87914. /** @hidden */
  87915. constructor(loader: GLTFLoader);
  87916. /** @hidden */
  87917. dispose(): void;
  87918. /** @hidden */
  87919. onLoading(): void;
  87920. /** @hidden */
  87921. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  87922. private _loadLightAsync;
  87923. }
  87924. }
  87925. declare module BABYLON.GLTF2.Loader.Extensions {
  87926. /**
  87927. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  87928. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  87929. * !!! Experimental Extension Subject to Changes !!!
  87930. */
  87931. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  87932. /**
  87933. * The name of this extension.
  87934. */
  87935. readonly name: string;
  87936. /**
  87937. * Defines whether this extension is enabled.
  87938. */
  87939. enabled: boolean;
  87940. private _loader;
  87941. /** @hidden */
  87942. constructor(loader: GLTFLoader);
  87943. /** @hidden */
  87944. dispose(): void;
  87945. /** @hidden */
  87946. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  87947. }
  87948. }
  87949. declare module BABYLON.GLTF2.Loader.Extensions {
  87950. /**
  87951. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/EXT_meshopt_compression)
  87952. *
  87953. * This extension uses a WebAssembly decoder module from https://github.com/zeux/meshoptimizer/tree/master/js
  87954. */
  87955. export class EXT_meshopt_compression implements IGLTFLoaderExtension {
  87956. /**
  87957. * The name of this extension.
  87958. */
  87959. readonly name: string;
  87960. /**
  87961. * Defines whether this extension is enabled.
  87962. */
  87963. enabled: boolean;
  87964. /**
  87965. * Path to decoder module; defaults to https://preview.babylonjs.com/meshopt_decoder.js
  87966. */
  87967. static DecoderPath: string;
  87968. private _loader;
  87969. private _decoderPromise?;
  87970. /** @hidden */
  87971. constructor(loader: GLTFLoader);
  87972. /** @hidden */
  87973. dispose(): void;
  87974. /** @hidden */
  87975. loadBufferViewAsync(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  87976. }
  87977. }
  87978. declare module BABYLON.GLTF2.Loader.Extensions {
  87979. /**
  87980. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  87981. */
  87982. export class EXT_texture_webp implements IGLTFLoaderExtension {
  87983. /** The name of this extension. */
  87984. readonly name: string;
  87985. /** Defines whether this extension is enabled. */
  87986. enabled: boolean;
  87987. private _loader;
  87988. /** @hidden */
  87989. constructor(loader: GLTFLoader);
  87990. /** @hidden */
  87991. dispose(): void;
  87992. /** @hidden */
  87993. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  87994. }
  87995. }
  87996. declare module BABYLON.GLTF2.Loader.Extensions {
  87997. /**
  87998. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  87999. */
  88000. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  88001. /**
  88002. * The name of this extension.
  88003. */
  88004. readonly name: string;
  88005. /**
  88006. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  88007. */
  88008. dracoCompression?: DracoCompression;
  88009. /**
  88010. * Defines whether this extension is enabled.
  88011. */
  88012. enabled: boolean;
  88013. private _loader;
  88014. /** @hidden */
  88015. constructor(loader: GLTFLoader);
  88016. /** @hidden */
  88017. dispose(): void;
  88018. /** @hidden */
  88019. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  88020. }
  88021. }
  88022. declare module BABYLON.GLTF2.Loader.Extensions {
  88023. /**
  88024. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  88025. */
  88026. export class KHR_lights implements IGLTFLoaderExtension {
  88027. /**
  88028. * The name of this extension.
  88029. */
  88030. readonly name: string;
  88031. /**
  88032. * Defines whether this extension is enabled.
  88033. */
  88034. enabled: boolean;
  88035. private _loader;
  88036. private _lights?;
  88037. /** @hidden */
  88038. constructor(loader: GLTFLoader);
  88039. /** @hidden */
  88040. dispose(): void;
  88041. /** @hidden */
  88042. onLoading(): void;
  88043. /** @hidden */
  88044. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88045. }
  88046. }
  88047. declare module BABYLON.GLTF2.Loader.Extensions {
  88048. /**
  88049. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  88050. */
  88051. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  88052. /**
  88053. * The name of this extension.
  88054. */
  88055. readonly name: string;
  88056. /**
  88057. * Defines whether this extension is enabled.
  88058. */
  88059. enabled: boolean;
  88060. /**
  88061. * Defines a number that determines the order the extensions are applied.
  88062. */
  88063. order: number;
  88064. private _loader;
  88065. /** @hidden */
  88066. constructor(loader: GLTFLoader);
  88067. /** @hidden */
  88068. dispose(): void;
  88069. /** @hidden */
  88070. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88071. private _loadSpecularGlossinessPropertiesAsync;
  88072. }
  88073. }
  88074. declare module BABYLON.GLTF2.Loader.Extensions {
  88075. /**
  88076. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  88077. */
  88078. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  88079. /**
  88080. * The name of this extension.
  88081. */
  88082. readonly name: string;
  88083. /**
  88084. * Defines whether this extension is enabled.
  88085. */
  88086. enabled: boolean;
  88087. /**
  88088. * Defines a number that determines the order the extensions are applied.
  88089. */
  88090. order: number;
  88091. private _loader;
  88092. /** @hidden */
  88093. constructor(loader: GLTFLoader);
  88094. /** @hidden */
  88095. dispose(): void;
  88096. /** @hidden */
  88097. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88098. private _loadUnlitPropertiesAsync;
  88099. }
  88100. }
  88101. declare module BABYLON.GLTF2.Loader.Extensions {
  88102. /**
  88103. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_clearcoat/README.md)
  88104. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  88105. */
  88106. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  88107. /**
  88108. * The name of this extension.
  88109. */
  88110. readonly name: string;
  88111. /**
  88112. * Defines whether this extension is enabled.
  88113. */
  88114. enabled: boolean;
  88115. /**
  88116. * Defines a number that determines the order the extensions are applied.
  88117. */
  88118. order: number;
  88119. private _loader;
  88120. /** @hidden */
  88121. constructor(loader: GLTFLoader);
  88122. /** @hidden */
  88123. dispose(): void;
  88124. /** @hidden */
  88125. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88126. private _loadClearCoatPropertiesAsync;
  88127. }
  88128. }
  88129. declare module BABYLON.GLTF2.Loader.Extensions {
  88130. /**
  88131. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_sheen/README.md)
  88132. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  88133. * !!! Experimental Extension Subject to Changes !!!
  88134. */
  88135. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  88136. /**
  88137. * The name of this extension.
  88138. */
  88139. readonly name: string;
  88140. /**
  88141. * Defines whether this extension is enabled.
  88142. */
  88143. enabled: boolean;
  88144. /**
  88145. * Defines a number that determines the order the extensions are applied.
  88146. */
  88147. order: number;
  88148. private _loader;
  88149. /** @hidden */
  88150. constructor(loader: GLTFLoader);
  88151. /** @hidden */
  88152. dispose(): void;
  88153. /** @hidden */
  88154. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88155. private _loadSheenPropertiesAsync;
  88156. }
  88157. }
  88158. declare module BABYLON.GLTF2.Loader.Extensions {
  88159. /**
  88160. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  88161. * !!! Experimental Extension Subject to Changes !!!
  88162. */
  88163. export class KHR_materials_specular implements IGLTFLoaderExtension {
  88164. /**
  88165. * The name of this extension.
  88166. */
  88167. readonly name: string;
  88168. /**
  88169. * Defines whether this extension is enabled.
  88170. */
  88171. enabled: boolean;
  88172. /**
  88173. * Defines a number that determines the order the extensions are applied.
  88174. */
  88175. order: number;
  88176. private _loader;
  88177. /** @hidden */
  88178. constructor(loader: GLTFLoader);
  88179. /** @hidden */
  88180. dispose(): void;
  88181. /** @hidden */
  88182. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88183. private _loadSpecularPropertiesAsync;
  88184. }
  88185. }
  88186. declare module BABYLON.GLTF2.Loader.Extensions {
  88187. /**
  88188. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  88189. * !!! Experimental Extension Subject to Changes !!!
  88190. */
  88191. export class KHR_materials_ior implements IGLTFLoaderExtension {
  88192. /**
  88193. * Default ior Value from the spec.
  88194. */
  88195. private static readonly _DEFAULT_IOR;
  88196. /**
  88197. * The name of this extension.
  88198. */
  88199. readonly name: string;
  88200. /**
  88201. * Defines whether this extension is enabled.
  88202. */
  88203. enabled: boolean;
  88204. /**
  88205. * Defines a number that determines the order the extensions are applied.
  88206. */
  88207. order: number;
  88208. private _loader;
  88209. /** @hidden */
  88210. constructor(loader: GLTFLoader);
  88211. /** @hidden */
  88212. dispose(): void;
  88213. /** @hidden */
  88214. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88215. private _loadIorPropertiesAsync;
  88216. }
  88217. }
  88218. declare module BABYLON.GLTF2.Loader.Extensions {
  88219. /**
  88220. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_variants/README.md)
  88221. */
  88222. export class KHR_materials_variants implements IGLTFLoaderExtension {
  88223. /**
  88224. * The name of this extension.
  88225. */
  88226. readonly name: string;
  88227. /**
  88228. * Defines whether this extension is enabled.
  88229. */
  88230. enabled: boolean;
  88231. private _loader;
  88232. private _variants?;
  88233. /** @hidden */
  88234. constructor(loader: GLTFLoader);
  88235. /** @hidden */
  88236. dispose(): void;
  88237. /**
  88238. * Gets the list of available variant names for this asset.
  88239. * @param rootMesh The glTF root mesh
  88240. * @returns the list of all the variant names for this model
  88241. */
  88242. static GetAvailableVariants(rootMesh: Mesh): string[];
  88243. /**
  88244. * Gets the list of available variant names for this asset.
  88245. * @param rootMesh The glTF root mesh
  88246. * @returns the list of all the variant names for this model
  88247. */
  88248. getAvailableVariants(rootMesh: Mesh): string[];
  88249. /**
  88250. * Select a variant given a variant name or a list of variant names.
  88251. * @param rootMesh The glTF root mesh
  88252. * @param variantName The variant name(s) to select.
  88253. */
  88254. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88255. /**
  88256. * Select a variant given a variant name or a list of variant names.
  88257. * @param rootMesh The glTF root mesh
  88258. * @param variantName The variant name(s) to select.
  88259. */
  88260. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  88261. /**
  88262. * Reset back to the original before selecting a variant.
  88263. * @param rootMesh The glTF root mesh
  88264. */
  88265. static Reset(rootMesh: Mesh): void;
  88266. /**
  88267. * Reset back to the original before selecting a variant.
  88268. * @param rootMesh The glTF root mesh
  88269. */
  88270. reset(rootMesh: Mesh): void;
  88271. /**
  88272. * Gets the last selected variant name(s) or null if original.
  88273. * @param rootMesh The glTF root mesh
  88274. * @returns The selected variant name(s).
  88275. */
  88276. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88277. /**
  88278. * Gets the last selected variant name(s) or null if original.
  88279. * @param rootMesh The glTF root mesh
  88280. * @returns The selected variant name(s).
  88281. */
  88282. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  88283. private static _GetExtensionMetadata;
  88284. /** @hidden */
  88285. onLoading(): void;
  88286. /** @hidden */
  88287. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  88288. }
  88289. }
  88290. declare module BABYLON.GLTF2.Loader.Extensions {
  88291. /**
  88292. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_transmission/README.md)
  88293. */
  88294. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  88295. /**
  88296. * The name of this extension.
  88297. */
  88298. readonly name: string;
  88299. /**
  88300. * Defines whether this extension is enabled.
  88301. */
  88302. enabled: boolean;
  88303. /**
  88304. * Defines a number that determines the order the extensions are applied.
  88305. */
  88306. order: number;
  88307. private _loader;
  88308. /** @hidden */
  88309. constructor(loader: GLTFLoader);
  88310. /** @hidden */
  88311. dispose(): void;
  88312. /** @hidden */
  88313. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88314. private _loadTransparentPropertiesAsync;
  88315. }
  88316. }
  88317. declare module BABYLON.GLTF2.Loader.Extensions {
  88318. /**
  88319. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1825)
  88320. * !!! Experimental Extension Subject to Changes !!!
  88321. */
  88322. export class KHR_materials_translucency implements IGLTFLoaderExtension {
  88323. /**
  88324. * The name of this extension.
  88325. */
  88326. readonly name: string;
  88327. /**
  88328. * Defines whether this extension is enabled.
  88329. */
  88330. enabled: boolean;
  88331. /**
  88332. * Defines a number that determines the order the extensions are applied.
  88333. */
  88334. order: number;
  88335. private _loader;
  88336. /** @hidden */
  88337. constructor(loader: GLTFLoader);
  88338. /** @hidden */
  88339. dispose(): void;
  88340. /** @hidden */
  88341. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88342. private _loadTranslucentPropertiesAsync;
  88343. }
  88344. }
  88345. declare module BABYLON.GLTF2.Loader.Extensions {
  88346. /**
  88347. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  88348. */
  88349. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  88350. /**
  88351. * The name of this extension.
  88352. */
  88353. readonly name: string;
  88354. /**
  88355. * Defines whether this extension is enabled.
  88356. */
  88357. enabled: boolean;
  88358. /** @hidden */
  88359. constructor(loader: GLTFLoader);
  88360. /** @hidden */
  88361. dispose(): void;
  88362. }
  88363. }
  88364. declare module BABYLON.GLTF2.Loader.Extensions {
  88365. /**
  88366. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  88367. * !!! Experimental Extension Subject to Changes !!!
  88368. */
  88369. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  88370. /** The name of this extension. */
  88371. readonly name: string;
  88372. /** Defines whether this extension is enabled. */
  88373. enabled: boolean;
  88374. private _loader;
  88375. /** @hidden */
  88376. constructor(loader: GLTFLoader);
  88377. /** @hidden */
  88378. dispose(): void;
  88379. /** @hidden */
  88380. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88381. }
  88382. }
  88383. declare module BABYLON.GLTF2.Loader.Extensions {
  88384. /**
  88385. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  88386. */
  88387. export class KHR_texture_transform implements IGLTFLoaderExtension {
  88388. /**
  88389. * The name of this extension.
  88390. */
  88391. readonly name: string;
  88392. /**
  88393. * Defines whether this extension is enabled.
  88394. */
  88395. enabled: boolean;
  88396. private _loader;
  88397. /** @hidden */
  88398. constructor(loader: GLTFLoader);
  88399. /** @hidden */
  88400. dispose(): void;
  88401. /** @hidden */
  88402. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  88403. }
  88404. }
  88405. declare module BABYLON.GLTF2.Loader.Extensions {
  88406. /**
  88407. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  88408. */
  88409. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  88410. /**
  88411. * The name of this extension.
  88412. */
  88413. readonly name: string;
  88414. /**
  88415. * Defines whether this extension is enabled.
  88416. */
  88417. enabled: boolean;
  88418. private _loader;
  88419. private _clips;
  88420. private _emitters;
  88421. /** @hidden */
  88422. constructor(loader: GLTFLoader);
  88423. /** @hidden */
  88424. dispose(): void;
  88425. /** @hidden */
  88426. onLoading(): void;
  88427. /** @hidden */
  88428. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88429. /** @hidden */
  88430. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88431. /** @hidden */
  88432. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  88433. private _loadClipAsync;
  88434. private _loadEmitterAsync;
  88435. private _getEventAction;
  88436. private _loadAnimationEventAsync;
  88437. }
  88438. }
  88439. declare module BABYLON.GLTF2.Loader.Extensions {
  88440. /**
  88441. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  88442. */
  88443. export class MSFT_lod implements IGLTFLoaderExtension {
  88444. /**
  88445. * The name of this extension.
  88446. */
  88447. readonly name: string;
  88448. /**
  88449. * Defines whether this extension is enabled.
  88450. */
  88451. enabled: boolean;
  88452. /**
  88453. * Defines a number that determines the order the extensions are applied.
  88454. */
  88455. order: number;
  88456. /**
  88457. * Maximum number of LODs to load, starting from the lowest LOD.
  88458. */
  88459. maxLODsToLoad: number;
  88460. /**
  88461. * Observable raised when all node LODs of one level are loaded.
  88462. * The event data is the index of the loaded LOD starting from zero.
  88463. * Dispose the loader to cancel the loading of the next level of LODs.
  88464. */
  88465. onNodeLODsLoadedObservable: Observable<number>;
  88466. /**
  88467. * Observable raised when all material LODs of one level are loaded.
  88468. * The event data is the index of the loaded LOD starting from zero.
  88469. * Dispose the loader to cancel the loading of the next level of LODs.
  88470. */
  88471. onMaterialLODsLoadedObservable: Observable<number>;
  88472. private _loader;
  88473. private _bufferLODs;
  88474. private _nodeIndexLOD;
  88475. private _nodeSignalLODs;
  88476. private _nodePromiseLODs;
  88477. private _nodeBufferLODs;
  88478. private _materialIndexLOD;
  88479. private _materialSignalLODs;
  88480. private _materialPromiseLODs;
  88481. private _materialBufferLODs;
  88482. /** @hidden */
  88483. constructor(loader: GLTFLoader);
  88484. /** @hidden */
  88485. dispose(): void;
  88486. /** @hidden */
  88487. onReady(): void;
  88488. /** @hidden */
  88489. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  88490. /** @hidden */
  88491. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88492. /** @hidden */
  88493. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  88494. /** @hidden */
  88495. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  88496. /** @hidden */
  88497. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  88498. private _loadBufferLOD;
  88499. /**
  88500. * Gets an array of LOD properties from lowest to highest.
  88501. */
  88502. private _getLODs;
  88503. private _disposeTransformNode;
  88504. private _disposeMaterials;
  88505. }
  88506. }
  88507. declare module BABYLON.GLTF2.Loader.Extensions {
  88508. /** @hidden */
  88509. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  88510. readonly name: string;
  88511. enabled: boolean;
  88512. private _loader;
  88513. constructor(loader: GLTFLoader);
  88514. dispose(): void;
  88515. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88516. }
  88517. }
  88518. declare module BABYLON.GLTF2.Loader.Extensions {
  88519. /** @hidden */
  88520. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  88521. readonly name: string;
  88522. enabled: boolean;
  88523. private _loader;
  88524. constructor(loader: GLTFLoader);
  88525. dispose(): void;
  88526. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  88527. }
  88528. }
  88529. declare module BABYLON.GLTF2.Loader.Extensions {
  88530. /**
  88531. * Store glTF extras (if present) in BJS objects' metadata
  88532. */
  88533. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  88534. /**
  88535. * The name of this extension.
  88536. */
  88537. readonly name: string;
  88538. /**
  88539. * Defines whether this extension is enabled.
  88540. */
  88541. enabled: boolean;
  88542. private _loader;
  88543. private _assignExtras;
  88544. /** @hidden */
  88545. constructor(loader: GLTFLoader);
  88546. /** @hidden */
  88547. dispose(): void;
  88548. /** @hidden */
  88549. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  88550. /** @hidden */
  88551. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  88552. /** @hidden */
  88553. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  88554. }
  88555. }
  88556. declare module BABYLON {
  88557. /**
  88558. * Class reading and parsing the MTL file bundled with the obj file.
  88559. */
  88560. export class MTLFileLoader {
  88561. /**
  88562. * Invert Y-Axis of referenced textures on load
  88563. */
  88564. static INVERT_TEXTURE_Y: boolean;
  88565. /**
  88566. * All material loaded from the mtl will be set here
  88567. */
  88568. materials: StandardMaterial[];
  88569. /**
  88570. * This function will read the mtl file and create each material described inside
  88571. * This function could be improve by adding :
  88572. * -some component missing (Ni, Tf...)
  88573. * -including the specific options available
  88574. *
  88575. * @param scene defines the scene the material will be created in
  88576. * @param data defines the mtl data to parse
  88577. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  88578. * @param forAssetContainer defines if the material should be registered in the scene
  88579. */
  88580. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  88581. /**
  88582. * Gets the texture for the material.
  88583. *
  88584. * If the material is imported from input file,
  88585. * We sanitize the url to ensure it takes the textre from aside the material.
  88586. *
  88587. * @param rootUrl The root url to load from
  88588. * @param value The value stored in the mtl
  88589. * @return The Texture
  88590. */
  88591. private static _getTexture;
  88592. }
  88593. }
  88594. declare module BABYLON {
  88595. /**
  88596. * Options for loading OBJ/MTL files
  88597. */
  88598. type MeshLoadOptions = {
  88599. /**
  88600. * Defines if UVs are optimized by default during load.
  88601. */
  88602. OptimizeWithUV: boolean;
  88603. /**
  88604. * Defines custom scaling of UV coordinates of loaded meshes.
  88605. */
  88606. UVScaling: Vector2;
  88607. /**
  88608. * Invert model on y-axis (does a model scaling inversion)
  88609. */
  88610. InvertY: boolean;
  88611. /**
  88612. * Invert Y-Axis of referenced textures on load
  88613. */
  88614. InvertTextureY: boolean;
  88615. /**
  88616. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88617. */
  88618. ImportVertexColors: boolean;
  88619. /**
  88620. * Compute the normals for the model, even if normals are present in the file.
  88621. */
  88622. ComputeNormals: boolean;
  88623. /**
  88624. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88625. */
  88626. SkipMaterials: boolean;
  88627. /**
  88628. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88629. */
  88630. MaterialLoadingFailsSilently: boolean;
  88631. };
  88632. /**
  88633. * OBJ file type loader.
  88634. * This is a babylon scene loader plugin.
  88635. */
  88636. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  88637. /**
  88638. * Defines if UVs are optimized by default during load.
  88639. */
  88640. static OPTIMIZE_WITH_UV: boolean;
  88641. /**
  88642. * Invert model on y-axis (does a model scaling inversion)
  88643. */
  88644. static INVERT_Y: boolean;
  88645. /**
  88646. * Invert Y-Axis of referenced textures on load
  88647. */
  88648. static get INVERT_TEXTURE_Y(): boolean;
  88649. static set INVERT_TEXTURE_Y(value: boolean);
  88650. /**
  88651. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  88652. */
  88653. static IMPORT_VERTEX_COLORS: boolean;
  88654. /**
  88655. * Compute the normals for the model, even if normals are present in the file.
  88656. */
  88657. static COMPUTE_NORMALS: boolean;
  88658. /**
  88659. * Defines custom scaling of UV coordinates of loaded meshes.
  88660. */
  88661. static UV_SCALING: Vector2;
  88662. /**
  88663. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  88664. */
  88665. static SKIP_MATERIALS: boolean;
  88666. /**
  88667. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  88668. *
  88669. * Defaults to true for backwards compatibility.
  88670. */
  88671. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  88672. /**
  88673. * Defines the name of the plugin.
  88674. */
  88675. name: string;
  88676. /**
  88677. * Defines the extension the plugin is able to load.
  88678. */
  88679. extensions: string;
  88680. /** @hidden */
  88681. obj: RegExp;
  88682. /** @hidden */
  88683. group: RegExp;
  88684. /** @hidden */
  88685. mtllib: RegExp;
  88686. /** @hidden */
  88687. usemtl: RegExp;
  88688. /** @hidden */
  88689. smooth: RegExp;
  88690. /** @hidden */
  88691. vertexPattern: RegExp;
  88692. /** @hidden */
  88693. normalPattern: RegExp;
  88694. /** @hidden */
  88695. uvPattern: RegExp;
  88696. /** @hidden */
  88697. facePattern1: RegExp;
  88698. /** @hidden */
  88699. facePattern2: RegExp;
  88700. /** @hidden */
  88701. facePattern3: RegExp;
  88702. /** @hidden */
  88703. facePattern4: RegExp;
  88704. /** @hidden */
  88705. facePattern5: RegExp;
  88706. private _forAssetContainer;
  88707. private _meshLoadOptions;
  88708. /**
  88709. * Creates loader for .OBJ files
  88710. *
  88711. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  88712. */
  88713. constructor(meshLoadOptions?: MeshLoadOptions);
  88714. private static get currentMeshLoadOptions();
  88715. /**
  88716. * Calls synchronously the MTL file attached to this obj.
  88717. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  88718. * Without this function materials are not displayed in the first frame (but displayed after).
  88719. * In consequence it is impossible to get material information in your HTML file
  88720. *
  88721. * @param url The URL of the MTL file
  88722. * @param rootUrl
  88723. * @param onSuccess Callback function to be called when the MTL file is loaded
  88724. * @private
  88725. */
  88726. private _loadMTL;
  88727. /**
  88728. * Instantiates a OBJ file loader plugin.
  88729. * @returns the created plugin
  88730. */
  88731. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  88732. /**
  88733. * If the data string can be loaded directly.
  88734. *
  88735. * @param data string containing the file data
  88736. * @returns if the data can be loaded directly
  88737. */
  88738. canDirectLoad(data: string): boolean;
  88739. /**
  88740. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  88741. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  88742. * @param scene the scene the meshes should be added to
  88743. * @param data the OBJ data to load
  88744. * @param rootUrl root url to load from
  88745. * @param onProgress event that fires when loading progress has occured
  88746. * @param fileName Defines the name of the file to load
  88747. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  88748. */
  88749. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<ISceneLoaderAsyncResult>;
  88750. /**
  88751. * Imports all objects from the loaded OBJ data and adds them to the scene
  88752. * @param scene the scene the objects should be added to
  88753. * @param data the OBJ data to load
  88754. * @param rootUrl root url to load from
  88755. * @param onProgress event that fires when loading progress has occured
  88756. * @param fileName Defines the name of the file to load
  88757. * @returns a promise which completes when objects have been loaded to the scene
  88758. */
  88759. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  88760. /**
  88761. * Load into an asset container.
  88762. * @param scene The scene to load into
  88763. * @param data The data to import
  88764. * @param rootUrl The root url for scene and resources
  88765. * @param onProgress The callback when the load progresses
  88766. * @param fileName Defines the name of the file to load
  88767. * @returns The loaded asset container
  88768. */
  88769. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  88770. /**
  88771. * Read the OBJ file and create an Array of meshes.
  88772. * Each mesh contains all information given by the OBJ and the MTL file.
  88773. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  88774. *
  88775. * @param meshesNames
  88776. * @param scene Scene The scene where are displayed the data
  88777. * @param data String The content of the obj file
  88778. * @param rootUrl String The path to the folder
  88779. * @returns Array<AbstractMesh>
  88780. * @private
  88781. */
  88782. private _parseSolid;
  88783. }
  88784. }
  88785. declare module BABYLON {
  88786. /**
  88787. * STL file type loader.
  88788. * This is a babylon scene loader plugin.
  88789. */
  88790. export class STLFileLoader implements ISceneLoaderPlugin {
  88791. /** @hidden */
  88792. solidPattern: RegExp;
  88793. /** @hidden */
  88794. facetsPattern: RegExp;
  88795. /** @hidden */
  88796. normalPattern: RegExp;
  88797. /** @hidden */
  88798. vertexPattern: RegExp;
  88799. /**
  88800. * Defines the name of the plugin.
  88801. */
  88802. name: string;
  88803. /**
  88804. * Defines the extensions the stl loader is able to load.
  88805. * force data to come in as an ArrayBuffer
  88806. * we'll convert to string if it looks like it's an ASCII .stl
  88807. */
  88808. extensions: ISceneLoaderPluginExtensions;
  88809. /**
  88810. * Import meshes into a scene.
  88811. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  88812. * @param scene The scene to import into
  88813. * @param data The data to import
  88814. * @param rootUrl The root url for scene and resources
  88815. * @param meshes The meshes array to import into
  88816. * @param particleSystems The particle systems array to import into
  88817. * @param skeletons The skeletons array to import into
  88818. * @param onError The callback when import fails
  88819. * @returns True if successful or false otherwise
  88820. */
  88821. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  88822. /**
  88823. * Load into a scene.
  88824. * @param scene The scene to load into
  88825. * @param data The data to import
  88826. * @param rootUrl The root url for scene and resources
  88827. * @param onError The callback when import fails
  88828. * @returns true if successful or false otherwise
  88829. */
  88830. load(scene: Scene, data: any, rootUrl: string): boolean;
  88831. /**
  88832. * Load into an asset container.
  88833. * @param scene The scene to load into
  88834. * @param data The data to import
  88835. * @param rootUrl The root url for scene and resources
  88836. * @param onError The callback when import fails
  88837. * @returns The loaded asset container
  88838. */
  88839. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  88840. private _isBinary;
  88841. private _parseBinary;
  88842. private _parseASCII;
  88843. }
  88844. }
  88845. declare module BABYLON {
  88846. /**
  88847. * Class for generating OBJ data from a Babylon scene.
  88848. */
  88849. export class OBJExport {
  88850. /**
  88851. * Exports the geometry of a Mesh array in .OBJ file format (text)
  88852. * @param mesh defines the list of meshes to serialize
  88853. * @param materials defines if materials should be exported
  88854. * @param matlibname defines the name of the associated mtl file
  88855. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  88856. * @returns the OBJ content
  88857. */
  88858. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  88859. /**
  88860. * Exports the material(s) of a mesh in .MTL file format (text)
  88861. * @param mesh defines the mesh to extract the material from
  88862. * @returns the mtl content
  88863. */
  88864. static MTL(mesh: Mesh): string;
  88865. }
  88866. }
  88867. declare module BABYLON {
  88868. /** @hidden */
  88869. export var __IGLTFExporterExtension: number;
  88870. /**
  88871. * Interface for extending the exporter
  88872. * @hidden
  88873. */
  88874. export interface IGLTFExporterExtension {
  88875. /**
  88876. * The name of this extension
  88877. */
  88878. readonly name: string;
  88879. /**
  88880. * Defines whether this extension is enabled
  88881. */
  88882. enabled: boolean;
  88883. /**
  88884. * Defines whether this extension is required
  88885. */
  88886. required: boolean;
  88887. }
  88888. }
  88889. declare module BABYLON.GLTF2.Exporter {
  88890. /** @hidden */
  88891. export var __IGLTFExporterExtensionV2: number;
  88892. /**
  88893. * Interface for a glTF exporter extension
  88894. * @hidden
  88895. */
  88896. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  88897. /**
  88898. * Define this method to modify the default behavior before exporting a texture
  88899. * @param context The context when loading the asset
  88900. * @param babylonTexture The Babylon.js texture
  88901. * @param mimeType The mime-type of the generated image
  88902. * @returns A promise that resolves with the exported texture
  88903. */
  88904. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  88905. /**
  88906. * Define this method to get notified when a texture info is created
  88907. * @param context The context when loading the asset
  88908. * @param textureInfo The glTF texture info
  88909. * @param babylonTexture The Babylon.js texture
  88910. */
  88911. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  88912. /**
  88913. * Define this method to modify the default behavior when exporting texture info
  88914. * @param context The context when loading the asset
  88915. * @param meshPrimitive glTF mesh primitive
  88916. * @param babylonSubMesh Babylon submesh
  88917. * @param binaryWriter glTF serializer binary writer instance
  88918. * @returns nullable IMeshPrimitive promise
  88919. */
  88920. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  88921. /**
  88922. * Define this method to modify the default behavior when exporting a node
  88923. * @param context The context when exporting the node
  88924. * @param node glTF node
  88925. * @param babylonNode BabylonJS node
  88926. * @returns nullable INode promise
  88927. */
  88928. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  88929. [key: number]: number;
  88930. }): Promise<Nullable<INode>>;
  88931. /**
  88932. * Define this method to modify the default behavior when exporting a material
  88933. * @param material glTF material
  88934. * @param babylonMaterial BabylonJS material
  88935. * @returns nullable IMaterial promise
  88936. */
  88937. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  88938. /**
  88939. * Define this method to return additional textures to export from a material
  88940. * @param material glTF material
  88941. * @param babylonMaterial BabylonJS material
  88942. * @returns List of textures
  88943. */
  88944. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  88945. /** Gets a boolean indicating that this extension was used */
  88946. wasUsed: boolean;
  88947. /** Gets a boolean indicating that this extension is required for the file to work */
  88948. required: boolean;
  88949. /**
  88950. * Called after the exporter state changes to EXPORTING
  88951. */
  88952. onExporting?(): void;
  88953. }
  88954. }
  88955. declare module BABYLON.GLTF2.Exporter {
  88956. /**
  88957. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  88958. * @hidden
  88959. */
  88960. export class _GLTFMaterialExporter {
  88961. /**
  88962. * Represents the dielectric specular values for R, G and B
  88963. */
  88964. private static readonly _DielectricSpecular;
  88965. /**
  88966. * Allows the maximum specular power to be defined for material calculations
  88967. */
  88968. private static readonly _MaxSpecularPower;
  88969. /**
  88970. * Mapping to store textures
  88971. */
  88972. private _textureMap;
  88973. /**
  88974. * Numeric tolerance value
  88975. */
  88976. private static readonly _Epsilon;
  88977. /**
  88978. * Reference to the glTF Exporter
  88979. */
  88980. private _exporter;
  88981. constructor(exporter: _Exporter);
  88982. /**
  88983. * Specifies if two colors are approximately equal in value
  88984. * @param color1 first color to compare to
  88985. * @param color2 second color to compare to
  88986. * @param epsilon threshold value
  88987. */
  88988. private static FuzzyEquals;
  88989. /**
  88990. * Gets the materials from a Babylon scene and converts them to glTF materials
  88991. * @param scene babylonjs scene
  88992. * @param mimeType texture mime type
  88993. * @param images array of images
  88994. * @param textures array of textures
  88995. * @param materials array of materials
  88996. * @param imageData mapping of texture names to base64 textures
  88997. * @param hasTextureCoords specifies if texture coordinates are present on the material
  88998. */
  88999. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  89000. /**
  89001. * Makes a copy of the glTF material without the texture parameters
  89002. * @param originalMaterial original glTF material
  89003. * @returns glTF material without texture parameters
  89004. */
  89005. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  89006. /**
  89007. * Specifies if the material has any texture parameters present
  89008. * @param material glTF Material
  89009. * @returns boolean specifying if texture parameters are present
  89010. */
  89011. _hasTexturesPresent(material: IMaterial): boolean;
  89012. /**
  89013. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  89014. * @param babylonStandardMaterial
  89015. * @returns glTF Metallic Roughness Material representation
  89016. */
  89017. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  89018. /**
  89019. * Computes the metallic factor
  89020. * @param diffuse diffused value
  89021. * @param specular specular value
  89022. * @param oneMinusSpecularStrength one minus the specular strength
  89023. * @returns metallic value
  89024. */
  89025. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  89026. /**
  89027. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  89028. * @param glTFMaterial glTF material
  89029. * @param babylonMaterial Babylon material
  89030. */
  89031. private static _SetAlphaMode;
  89032. /**
  89033. * Converts a Babylon Standard Material to a glTF Material
  89034. * @param babylonStandardMaterial BJS Standard Material
  89035. * @param mimeType mime type to use for the textures
  89036. * @param images array of glTF image interfaces
  89037. * @param textures array of glTF texture interfaces
  89038. * @param materials array of glTF material interfaces
  89039. * @param imageData map of image file name to data
  89040. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89041. */
  89042. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89043. private _finishMaterial;
  89044. /**
  89045. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  89046. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  89047. * @param mimeType mime type to use for the textures
  89048. * @param images array of glTF image interfaces
  89049. * @param textures array of glTF texture interfaces
  89050. * @param materials array of glTF material interfaces
  89051. * @param imageData map of image file name to data
  89052. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89053. */
  89054. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89055. /**
  89056. * Converts an image typed array buffer to a base64 image
  89057. * @param buffer typed array buffer
  89058. * @param width width of the image
  89059. * @param height height of the image
  89060. * @param mimeType mimetype of the image
  89061. * @returns base64 image string
  89062. */
  89063. private _createBase64FromCanvasAsync;
  89064. /**
  89065. * Generates a white texture based on the specified width and height
  89066. * @param width width of the texture in pixels
  89067. * @param height height of the texture in pixels
  89068. * @param scene babylonjs scene
  89069. * @returns white texture
  89070. */
  89071. private _createWhiteTexture;
  89072. /**
  89073. * 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
  89074. * @param texture1 first texture to resize
  89075. * @param texture2 second texture to resize
  89076. * @param scene babylonjs scene
  89077. * @returns resized textures or null
  89078. */
  89079. private _resizeTexturesToSameDimensions;
  89080. /**
  89081. * Converts an array of pixels to a Float32Array
  89082. * Throws an error if the pixel format is not supported
  89083. * @param pixels - array buffer containing pixel values
  89084. * @returns Float32 of pixels
  89085. */
  89086. private _convertPixelArrayToFloat32;
  89087. /**
  89088. * Convert Specular Glossiness Textures to Metallic Roughness
  89089. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  89090. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  89091. * @param diffuseTexture texture used to store diffuse information
  89092. * @param specularGlossinessTexture texture used to store specular and glossiness information
  89093. * @param factors specular glossiness material factors
  89094. * @param mimeType the mime type to use for the texture
  89095. * @returns pbr metallic roughness interface or null
  89096. */
  89097. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  89098. /**
  89099. * Converts specular glossiness material properties to metallic roughness
  89100. * @param specularGlossiness interface with specular glossiness material properties
  89101. * @returns interface with metallic roughness material properties
  89102. */
  89103. private _convertSpecularGlossinessToMetallicRoughness;
  89104. /**
  89105. * Calculates the surface reflectance, independent of lighting conditions
  89106. * @param color Color source to calculate brightness from
  89107. * @returns number representing the perceived brightness, or zero if color is undefined
  89108. */
  89109. private _getPerceivedBrightness;
  89110. /**
  89111. * Returns the maximum color component value
  89112. * @param color
  89113. * @returns maximum color component value, or zero if color is null or undefined
  89114. */
  89115. private _getMaxComponent;
  89116. /**
  89117. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  89118. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89119. * @param mimeType mime type to use for the textures
  89120. * @param images array of glTF image interfaces
  89121. * @param textures array of glTF texture interfaces
  89122. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89123. * @param imageData map of image file name to data
  89124. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89125. * @returns glTF PBR Metallic Roughness factors
  89126. */
  89127. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  89128. private _getGLTFTextureSampler;
  89129. private _getGLTFTextureWrapMode;
  89130. private _getGLTFTextureWrapModesSampler;
  89131. /**
  89132. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  89133. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  89134. * @param mimeType mime type to use for the textures
  89135. * @param images array of glTF image interfaces
  89136. * @param textures array of glTF texture interfaces
  89137. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  89138. * @param imageData map of image file name to data
  89139. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89140. * @returns glTF PBR Metallic Roughness factors
  89141. */
  89142. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  89143. /**
  89144. * Converts a Babylon PBR Base Material to a glTF Material
  89145. * @param babylonPBRMaterial BJS PBR Base Material
  89146. * @param mimeType mime type to use for the textures
  89147. * @param images array of glTF image interfaces
  89148. * @param textures array of glTF texture interfaces
  89149. * @param materials array of glTF material interfaces
  89150. * @param imageData map of image file name to data
  89151. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  89152. */
  89153. _convertPBRMaterialAsync(babylonPBRMaterial: PBRBaseMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  89154. private setMetallicRoughnessPbrMaterial;
  89155. private getPixelsFromTexture;
  89156. /**
  89157. * Extracts a texture from a Babylon texture into file data and glTF data
  89158. * @param babylonTexture Babylon texture to extract
  89159. * @param mimeType Mime Type of the babylonTexture
  89160. * @return glTF texture info, or null if the texture format is not supported
  89161. */
  89162. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89163. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  89164. /**
  89165. * Builds a texture from base64 string
  89166. * @param base64Texture base64 texture string
  89167. * @param baseTextureName Name to use for the texture
  89168. * @param mimeType image mime type for the texture
  89169. * @param images array of images
  89170. * @param textures array of textures
  89171. * @param imageData map of image data
  89172. * @returns glTF texture info, or null if the texture format is not supported
  89173. */
  89174. private _getTextureInfoFromBase64;
  89175. }
  89176. }
  89177. declare module BABYLON {
  89178. /**
  89179. * Class for holding and downloading glTF file data
  89180. */
  89181. export class GLTFData {
  89182. /**
  89183. * Object which contains the file name as the key and its data as the value
  89184. */
  89185. glTFFiles: {
  89186. [fileName: string]: string | Blob;
  89187. };
  89188. /**
  89189. * Initializes the glTF file object
  89190. */
  89191. constructor();
  89192. /**
  89193. * Downloads the glTF data as files based on their names and data
  89194. */
  89195. downloadFiles(): void;
  89196. }
  89197. }
  89198. declare module BABYLON {
  89199. /**
  89200. * Holds a collection of exporter options and parameters
  89201. */
  89202. export interface IExportOptions {
  89203. /**
  89204. * Function which indicates whether a babylon node should be exported or not
  89205. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  89206. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  89207. */
  89208. shouldExportNode?(node: Node): boolean;
  89209. /**
  89210. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  89211. * @param metadata source metadata to read from
  89212. * @returns the data to store to glTF node extras
  89213. */
  89214. metadataSelector?(metadata: any): any;
  89215. /**
  89216. * The sample rate to bake animation curves
  89217. */
  89218. animationSampleRate?: number;
  89219. /**
  89220. * Begin serialization without waiting for the scene to be ready
  89221. */
  89222. exportWithoutWaitingForScene?: boolean;
  89223. /**
  89224. * Indicates if coordinate system swapping root nodes should be included in export
  89225. */
  89226. includeCoordinateSystemConversionNodes?: boolean;
  89227. }
  89228. /**
  89229. * Class for generating glTF data from a Babylon scene.
  89230. */
  89231. export class GLTF2Export {
  89232. /**
  89233. * Exports the geometry of the scene to .gltf file format asynchronously
  89234. * @param scene Babylon scene with scene hierarchy information
  89235. * @param filePrefix File prefix to use when generating the glTF file
  89236. * @param options Exporter options
  89237. * @returns Returns an object with a .gltf file and associates texture names
  89238. * as keys and their data and paths as values
  89239. */
  89240. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89241. private static _PreExportAsync;
  89242. private static _PostExportAsync;
  89243. /**
  89244. * Exports the geometry of the scene to .glb file format asychronously
  89245. * @param scene Babylon scene with scene hierarchy information
  89246. * @param filePrefix File prefix to use when generating glb file
  89247. * @param options Exporter options
  89248. * @returns Returns an object with a .glb filename as key and data as value
  89249. */
  89250. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  89251. }
  89252. }
  89253. declare module BABYLON.GLTF2.Exporter {
  89254. /**
  89255. * @hidden
  89256. */
  89257. export class _GLTFUtilities {
  89258. /**
  89259. * Creates a buffer view based on the supplied arguments
  89260. * @param bufferIndex index value of the specified buffer
  89261. * @param byteOffset byte offset value
  89262. * @param byteLength byte length of the bufferView
  89263. * @param byteStride byte distance between conequential elements
  89264. * @param name name of the buffer view
  89265. * @returns bufferView for glTF
  89266. */
  89267. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  89268. /**
  89269. * Creates an accessor based on the supplied arguments
  89270. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  89271. * @param name The name of the accessor
  89272. * @param type The type of the accessor
  89273. * @param componentType The datatype of components in the attribute
  89274. * @param count The number of attributes referenced by this accessor
  89275. * @param byteOffset The offset relative to the start of the bufferView in bytes
  89276. * @param min Minimum value of each component in this attribute
  89277. * @param max Maximum value of each component in this attribute
  89278. * @returns accessor for glTF
  89279. */
  89280. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  89281. /**
  89282. * Calculates the minimum and maximum values of an array of position floats
  89283. * @param positions Positions array of a mesh
  89284. * @param vertexStart Starting vertex offset to calculate min and max values
  89285. * @param vertexCount Number of vertices to check for min and max values
  89286. * @returns min number array and max number array
  89287. */
  89288. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  89289. min: number[];
  89290. max: number[];
  89291. };
  89292. /**
  89293. * Converts a new right-handed Vector3
  89294. * @param vector vector3 array
  89295. * @returns right-handed Vector3
  89296. */
  89297. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  89298. /**
  89299. * Converts a Vector3 to right-handed
  89300. * @param vector Vector3 to convert to right-handed
  89301. */
  89302. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  89303. /**
  89304. * Converts a three element number array to right-handed
  89305. * @param vector number array to convert to right-handed
  89306. */
  89307. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  89308. /**
  89309. * Converts a new right-handed Vector3
  89310. * @param vector vector3 array
  89311. * @returns right-handed Vector3
  89312. */
  89313. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  89314. /**
  89315. * Converts a Vector3 to right-handed
  89316. * @param vector Vector3 to convert to right-handed
  89317. */
  89318. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  89319. /**
  89320. * Converts a three element number array to right-handed
  89321. * @param vector number array to convert to right-handed
  89322. */
  89323. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  89324. /**
  89325. * Converts a Vector4 to right-handed
  89326. * @param vector Vector4 to convert to right-handed
  89327. */
  89328. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  89329. /**
  89330. * Converts a Vector4 to right-handed
  89331. * @param vector Vector4 to convert to right-handed
  89332. */
  89333. static _GetRightHandedArray4FromRef(vector: number[]): void;
  89334. /**
  89335. * Converts a Quaternion to right-handed
  89336. * @param quaternion Source quaternion to convert to right-handed
  89337. */
  89338. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  89339. /**
  89340. * Converts a Quaternion to right-handed
  89341. * @param quaternion Source quaternion to convert to right-handed
  89342. */
  89343. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  89344. static _NormalizeTangentFromRef(tangent: Vector4): void;
  89345. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  89346. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  89347. }
  89348. }
  89349. declare module BABYLON.GLTF2.Exporter {
  89350. /**
  89351. * Converts Babylon Scene into glTF 2.0.
  89352. * @hidden
  89353. */
  89354. export class _Exporter {
  89355. /**
  89356. * Stores the glTF to export
  89357. */
  89358. _glTF: IGLTF;
  89359. /**
  89360. * Stores all generated buffer views, which represents views into the main glTF buffer data
  89361. */
  89362. _bufferViews: IBufferView[];
  89363. /**
  89364. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  89365. */
  89366. _accessors: IAccessor[];
  89367. /**
  89368. * Stores all the generated nodes, which contains transform and/or mesh information per node
  89369. */
  89370. _nodes: INode[];
  89371. /**
  89372. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  89373. */
  89374. private _scenes;
  89375. /**
  89376. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  89377. */
  89378. private _meshes;
  89379. /**
  89380. * Stores all the generated material information, which represents the appearance of each primitive
  89381. */
  89382. _materials: IMaterial[];
  89383. _materialMap: {
  89384. [materialID: number]: number;
  89385. };
  89386. /**
  89387. * Stores all the generated texture information, which is referenced by glTF materials
  89388. */
  89389. _textures: ITexture[];
  89390. /**
  89391. * Stores all the generated image information, which is referenced by glTF textures
  89392. */
  89393. _images: IImage[];
  89394. /**
  89395. * Stores all the texture samplers
  89396. */
  89397. _samplers: ISampler[];
  89398. /**
  89399. * Stores all the generated glTF skins
  89400. */
  89401. _skins: ISkin[];
  89402. /**
  89403. * Stores all the generated animation samplers, which is referenced by glTF animations
  89404. */
  89405. /**
  89406. * Stores the animations for glTF models
  89407. */
  89408. private _animations;
  89409. /**
  89410. * Stores the total amount of bytes stored in the glTF buffer
  89411. */
  89412. private _totalByteLength;
  89413. /**
  89414. * Stores a reference to the Babylon scene containing the source geometry and material information
  89415. */
  89416. _babylonScene: Scene;
  89417. /**
  89418. * Stores a map of the image data, where the key is the file name and the value
  89419. * is the image data
  89420. */
  89421. _imageData: {
  89422. [fileName: string]: {
  89423. data: Uint8Array;
  89424. mimeType: ImageMimeType;
  89425. };
  89426. };
  89427. protected _orderedImageData: Array<{
  89428. data: Uint8Array;
  89429. mimeType: ImageMimeType;
  89430. }>;
  89431. /**
  89432. * Stores a map of the unique id of a node to its index in the node array
  89433. */
  89434. _nodeMap: {
  89435. [key: number]: number;
  89436. };
  89437. /**
  89438. * Specifies if the source Babylon scene was left handed, and needed conversion.
  89439. */
  89440. _convertToRightHandedSystem: boolean;
  89441. /**
  89442. * Specifies if a Babylon node should be converted to right-handed on export
  89443. */
  89444. _convertToRightHandedSystemMap: {
  89445. [nodeId: number]: boolean;
  89446. };
  89447. _includeCoordinateSystemConversionNodes: boolean;
  89448. /**
  89449. * Baked animation sample rate
  89450. */
  89451. private _animationSampleRate;
  89452. private _options;
  89453. private _localEngine;
  89454. _glTFMaterialExporter: _GLTFMaterialExporter;
  89455. private _extensions;
  89456. private static _ExtensionNames;
  89457. private static _ExtensionFactories;
  89458. private _applyExtension;
  89459. private _applyExtensions;
  89460. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  89461. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  89462. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  89463. [key: number]: number;
  89464. }): Promise<Nullable<INode>>;
  89465. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  89466. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  89467. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  89468. private _forEachExtensions;
  89469. private _extensionsOnExporting;
  89470. /**
  89471. * Load glTF serializer extensions
  89472. */
  89473. private _loadExtensions;
  89474. /**
  89475. * Creates a glTF Exporter instance, which can accept optional exporter options
  89476. * @param babylonScene Babylon scene object
  89477. * @param options Options to modify the behavior of the exporter
  89478. */
  89479. constructor(babylonScene: Scene, options?: IExportOptions);
  89480. dispose(): void;
  89481. /**
  89482. * Registers a glTF exporter extension
  89483. * @param name Name of the extension to export
  89484. * @param factory The factory function that creates the exporter extension
  89485. */
  89486. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  89487. /**
  89488. * Un-registers an exporter extension
  89489. * @param name The name fo the exporter extension
  89490. * @returns A boolean indicating whether the extension has been un-registered
  89491. */
  89492. static UnregisterExtension(name: string): boolean;
  89493. private reorderIndicesBasedOnPrimitiveMode;
  89494. /**
  89495. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  89496. * clock-wise during export to glTF
  89497. * @param submesh BabylonJS submesh
  89498. * @param primitiveMode Primitive mode of the mesh
  89499. * @param sideOrientation the winding order of the submesh
  89500. * @param vertexBufferKind The type of vertex attribute
  89501. * @param meshAttributeArray The vertex attribute data
  89502. * @param byteOffset The offset to the binary data
  89503. * @param binaryWriter The binary data for the glTF file
  89504. * @param convertToRightHandedSystem Converts the values to right-handed
  89505. */
  89506. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  89507. /**
  89508. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  89509. * clock-wise during export to glTF
  89510. * @param submesh BabylonJS submesh
  89511. * @param primitiveMode Primitive mode of the mesh
  89512. * @param sideOrientation the winding order of the submesh
  89513. * @param vertexBufferKind The type of vertex attribute
  89514. * @param meshAttributeArray The vertex attribute data
  89515. * @param byteOffset The offset to the binary data
  89516. * @param binaryWriter The binary data for the glTF file
  89517. * @param convertToRightHandedSystem Converts the values to right-handed
  89518. */
  89519. private reorderTriangleFillMode;
  89520. /**
  89521. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  89522. * clock-wise during export to glTF
  89523. * @param submesh BabylonJS submesh
  89524. * @param primitiveMode Primitive mode of the mesh
  89525. * @param sideOrientation the winding order of the submesh
  89526. * @param vertexBufferKind The type of vertex attribute
  89527. * @param meshAttributeArray The vertex attribute data
  89528. * @param byteOffset The offset to the binary data
  89529. * @param binaryWriter The binary data for the glTF file
  89530. * @param convertToRightHandedSystem Converts the values to right-handed
  89531. */
  89532. private reorderTriangleStripDrawMode;
  89533. /**
  89534. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  89535. * clock-wise during export to glTF
  89536. * @param submesh BabylonJS submesh
  89537. * @param primitiveMode Primitive mode of the mesh
  89538. * @param sideOrientation the winding order of the submesh
  89539. * @param vertexBufferKind The type of vertex attribute
  89540. * @param meshAttributeArray The vertex attribute data
  89541. * @param byteOffset The offset to the binary data
  89542. * @param binaryWriter The binary data for the glTF file
  89543. * @param convertToRightHandedSystem Converts the values to right-handed
  89544. */
  89545. private reorderTriangleFanMode;
  89546. /**
  89547. * Writes the vertex attribute data to binary
  89548. * @param vertices The vertices to write to the binary writer
  89549. * @param byteOffset The offset into the binary writer to overwrite binary data
  89550. * @param vertexAttributeKind The vertex attribute type
  89551. * @param meshAttributeArray The vertex attribute data
  89552. * @param binaryWriter The writer containing the binary data
  89553. * @param convertToRightHandedSystem Converts the values to right-handed
  89554. */
  89555. private writeVertexAttributeData;
  89556. /**
  89557. * Writes mesh attribute data to a data buffer
  89558. * Returns the bytelength of the data
  89559. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89560. * @param meshAttributeArray Array containing the attribute data
  89561. * @param byteStride Specifies the space between data
  89562. * @param binaryWriter The buffer to write the binary data to
  89563. * @param convertToRightHandedSystem Converts the values to right-handed
  89564. */
  89565. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  89566. /**
  89567. * Writes mesh attribute data to a data buffer
  89568. * Returns the bytelength of the data
  89569. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  89570. * @param meshAttributeArray Array containing the attribute data
  89571. * @param byteStride Specifies the space between data
  89572. * @param binaryWriter The buffer to write the binary data to
  89573. * @param convertToRightHandedSystem Converts the values to right-handed
  89574. */
  89575. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  89576. /**
  89577. * Generates glTF json data
  89578. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  89579. * @param glTFPrefix Text to use when prefixing a glTF file
  89580. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  89581. * @returns json data as string
  89582. */
  89583. private generateJSON;
  89584. /**
  89585. * Generates data for .gltf and .bin files based on the glTF prefix string
  89586. * @param glTFPrefix Text to use when prefixing a glTF file
  89587. * @param dispose Dispose the exporter
  89588. * @returns GLTFData with glTF file data
  89589. */
  89590. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89591. /**
  89592. * Creates a binary buffer for glTF
  89593. * @returns array buffer for binary data
  89594. */
  89595. private _generateBinaryAsync;
  89596. /**
  89597. * Pads the number to a multiple of 4
  89598. * @param num number to pad
  89599. * @returns padded number
  89600. */
  89601. private _getPadding;
  89602. /**
  89603. * @hidden
  89604. */
  89605. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  89606. /**
  89607. * Sets the TRS for each node
  89608. * @param node glTF Node for storing the transformation data
  89609. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  89610. * @param convertToRightHandedSystem Converts the values to right-handed
  89611. */
  89612. private setNodeTransformation;
  89613. private getVertexBufferFromMesh;
  89614. /**
  89615. * Creates a bufferview based on the vertices type for the Babylon mesh
  89616. * @param kind Indicates the type of vertices data
  89617. * @param componentType Indicates the numerical type used to store the data
  89618. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  89619. * @param binaryWriter The buffer to write the bufferview data to
  89620. * @param convertToRightHandedSystem Converts the values to right-handed
  89621. */
  89622. private createBufferViewKind;
  89623. /**
  89624. * Creates a bufferview based on the vertices type for the Babylon mesh
  89625. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  89626. * @param babylonMorphTarget the morph target to be exported
  89627. * @param binaryWriter The buffer to write the bufferview data to
  89628. * @param convertToRightHandedSystem Converts the values to right-handed
  89629. */
  89630. private setMorphTargetAttributes;
  89631. /**
  89632. * The primitive mode of the Babylon mesh
  89633. * @param babylonMesh The BabylonJS mesh
  89634. */
  89635. private getMeshPrimitiveMode;
  89636. /**
  89637. * Sets the primitive mode of the glTF mesh primitive
  89638. * @param meshPrimitive glTF mesh primitive
  89639. * @param primitiveMode The primitive mode
  89640. */
  89641. private setPrimitiveMode;
  89642. /**
  89643. * Sets the vertex attribute accessor based of the glTF mesh primitive
  89644. * @param meshPrimitive glTF mesh primitive
  89645. * @param attributeKind vertex attribute
  89646. * @returns boolean specifying if uv coordinates are present
  89647. */
  89648. private setAttributeKind;
  89649. /**
  89650. * Sets data for the primitive attributes of each submesh
  89651. * @param mesh glTF Mesh object to store the primitive attribute information
  89652. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  89653. * @param binaryWriter Buffer to write the attribute data to
  89654. * @param convertToRightHandedSystem Converts the values to right-handed
  89655. */
  89656. private setPrimitiveAttributesAsync;
  89657. /**
  89658. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  89659. * @param node The node to check
  89660. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  89661. */
  89662. private isBabylonCoordinateSystemConvertingNode;
  89663. /**
  89664. * Creates a glTF scene based on the array of meshes
  89665. * Returns the the total byte offset
  89666. * @param babylonScene Babylon scene to get the mesh data from
  89667. * @param binaryWriter Buffer to write binary data to
  89668. */
  89669. private createSceneAsync;
  89670. /**
  89671. * Creates a mapping of Node unique id to node index and handles animations
  89672. * @param babylonScene Babylon Scene
  89673. * @param nodes Babylon transform nodes
  89674. * @param binaryWriter Buffer to write binary data to
  89675. * @returns Node mapping of unique id to index
  89676. */
  89677. private createNodeMapAndAnimationsAsync;
  89678. /**
  89679. * Creates a glTF node from a Babylon mesh
  89680. * @param babylonMesh Source Babylon mesh
  89681. * @param binaryWriter Buffer for storing geometry data
  89682. * @param convertToRightHandedSystem Converts the values to right-handed
  89683. * @param nodeMap Node mapping of unique id to glTF node index
  89684. * @returns glTF node
  89685. */
  89686. private createNodeAsync;
  89687. /**
  89688. * Creates a glTF skin from a Babylon skeleton
  89689. * @param babylonScene Babylon Scene
  89690. * @param nodes Babylon transform nodes
  89691. * @param binaryWriter Buffer to write binary data to
  89692. * @returns Node mapping of unique id to index
  89693. */
  89694. private createSkinsAsync;
  89695. }
  89696. /**
  89697. * @hidden
  89698. *
  89699. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  89700. */
  89701. export class _BinaryWriter {
  89702. /**
  89703. * Array buffer which stores all binary data
  89704. */
  89705. private _arrayBuffer;
  89706. /**
  89707. * View of the array buffer
  89708. */
  89709. private _dataView;
  89710. /**
  89711. * byte offset of data in array buffer
  89712. */
  89713. private _byteOffset;
  89714. /**
  89715. * Initialize binary writer with an initial byte length
  89716. * @param byteLength Initial byte length of the array buffer
  89717. */
  89718. constructor(byteLength: number);
  89719. /**
  89720. * Resize the array buffer to the specified byte length
  89721. * @param byteLength
  89722. */
  89723. private resizeBuffer;
  89724. /**
  89725. * Get an array buffer with the length of the byte offset
  89726. * @returns ArrayBuffer resized to the byte offset
  89727. */
  89728. getArrayBuffer(): ArrayBuffer;
  89729. /**
  89730. * Get the byte offset of the array buffer
  89731. * @returns byte offset
  89732. */
  89733. getByteOffset(): number;
  89734. /**
  89735. * Stores an UInt8 in the array buffer
  89736. * @param entry
  89737. * @param byteOffset If defined, specifies where to set the value as an offset.
  89738. */
  89739. setUInt8(entry: number, byteOffset?: number): void;
  89740. /**
  89741. * Stores an UInt16 in the array buffer
  89742. * @param entry
  89743. * @param byteOffset If defined, specifies where to set the value as an offset.
  89744. */
  89745. setUInt16(entry: number, byteOffset?: number): void;
  89746. /**
  89747. * Gets an UInt32 in the array buffer
  89748. * @param entry
  89749. * @param byteOffset If defined, specifies where to set the value as an offset.
  89750. */
  89751. getUInt32(byteOffset: number): number;
  89752. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89753. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  89754. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89755. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  89756. /**
  89757. * Stores a Float32 in the array buffer
  89758. * @param entry
  89759. */
  89760. setFloat32(entry: number, byteOffset?: number): void;
  89761. /**
  89762. * Stores an UInt32 in the array buffer
  89763. * @param entry
  89764. * @param byteOffset If defined, specifies where to set the value as an offset.
  89765. */
  89766. setUInt32(entry: number, byteOffset?: number): void;
  89767. }
  89768. }
  89769. declare module BABYLON.GLTF2.Exporter {
  89770. /**
  89771. * @hidden
  89772. * Interface to store animation data.
  89773. */
  89774. export interface _IAnimationData {
  89775. /**
  89776. * Keyframe data.
  89777. */
  89778. inputs: number[];
  89779. /**
  89780. * Value data.
  89781. */
  89782. outputs: number[][];
  89783. /**
  89784. * Animation interpolation data.
  89785. */
  89786. samplerInterpolation: AnimationSamplerInterpolation;
  89787. /**
  89788. * Minimum keyframe value.
  89789. */
  89790. inputsMin: number;
  89791. /**
  89792. * Maximum keyframe value.
  89793. */
  89794. inputsMax: number;
  89795. }
  89796. /**
  89797. * @hidden
  89798. */
  89799. export interface _IAnimationInfo {
  89800. /**
  89801. * The target channel for the animation
  89802. */
  89803. animationChannelTargetPath: AnimationChannelTargetPath;
  89804. /**
  89805. * The glTF accessor type for the data.
  89806. */
  89807. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  89808. /**
  89809. * Specifies if quaternions should be used.
  89810. */
  89811. useQuaternion: boolean;
  89812. }
  89813. /**
  89814. * @hidden
  89815. * Utility class for generating glTF animation data from BabylonJS.
  89816. */
  89817. export class _GLTFAnimation {
  89818. /**
  89819. * @ignore
  89820. *
  89821. * Creates glTF channel animation from BabylonJS animation.
  89822. * @param babylonTransformNode - BabylonJS mesh.
  89823. * @param animation - animation.
  89824. * @param animationChannelTargetPath - The target animation channel.
  89825. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  89826. * @param useQuaternion - Specifies if quaternions are used.
  89827. * @returns nullable IAnimationData
  89828. */
  89829. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  89830. private static _DeduceAnimationInfo;
  89831. /**
  89832. * @ignore
  89833. * Create node animations from the transform node animations
  89834. * @param babylonNode
  89835. * @param runtimeGLTFAnimation
  89836. * @param idleGLTFAnimations
  89837. * @param nodeMap
  89838. * @param nodes
  89839. * @param binaryWriter
  89840. * @param bufferViews
  89841. * @param accessors
  89842. * @param convertToRightHandedSystem
  89843. * @param animationSampleRate
  89844. */
  89845. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89846. [key: number]: number;
  89847. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89848. /**
  89849. * @ignore
  89850. * Create individual morph animations from the mesh's morph target animation tracks
  89851. * @param babylonNode
  89852. * @param runtimeGLTFAnimation
  89853. * @param idleGLTFAnimations
  89854. * @param nodeMap
  89855. * @param nodes
  89856. * @param binaryWriter
  89857. * @param bufferViews
  89858. * @param accessors
  89859. * @param convertToRightHandedSystem
  89860. * @param animationSampleRate
  89861. */
  89862. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  89863. [key: number]: number;
  89864. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  89865. /**
  89866. * @ignore
  89867. * Create node and morph animations from the animation groups
  89868. * @param babylonScene
  89869. * @param glTFAnimations
  89870. * @param nodeMap
  89871. * @param nodes
  89872. * @param binaryWriter
  89873. * @param bufferViews
  89874. * @param accessors
  89875. * @param convertToRightHandedSystemMap
  89876. * @param animationSampleRate
  89877. */
  89878. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  89879. [key: number]: number;
  89880. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  89881. [nodeId: number]: boolean;
  89882. }, animationSampleRate: number): void;
  89883. private static AddAnimation;
  89884. /**
  89885. * Create a baked animation
  89886. * @param babylonTransformNode BabylonJS mesh
  89887. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  89888. * @param animationChannelTargetPath animation target channel
  89889. * @param minFrame minimum animation frame
  89890. * @param maxFrame maximum animation frame
  89891. * @param fps frames per second of the animation
  89892. * @param inputs input key frames of the animation
  89893. * @param outputs output key frame data of the animation
  89894. * @param convertToRightHandedSystem converts the values to right-handed
  89895. * @param useQuaternion specifies if quaternions should be used
  89896. */
  89897. private static _CreateBakedAnimation;
  89898. private static _ConvertFactorToVector3OrQuaternion;
  89899. private static _SetInterpolatedValue;
  89900. /**
  89901. * Creates linear animation from the animation key frames
  89902. * @param babylonTransformNode BabylonJS mesh
  89903. * @param animation BabylonJS animation
  89904. * @param animationChannelTargetPath The target animation channel
  89905. * @param frameDelta The difference between the last and first frame of the animation
  89906. * @param inputs Array to store the key frame times
  89907. * @param outputs Array to store the key frame data
  89908. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89909. * @param useQuaternion Specifies if quaternions are used in the animation
  89910. */
  89911. private static _CreateLinearOrStepAnimation;
  89912. /**
  89913. * Creates cubic spline animation from the animation key frames
  89914. * @param babylonTransformNode BabylonJS mesh
  89915. * @param animation BabylonJS animation
  89916. * @param animationChannelTargetPath The target animation channel
  89917. * @param frameDelta The difference between the last and first frame of the animation
  89918. * @param inputs Array to store the key frame times
  89919. * @param outputs Array to store the key frame data
  89920. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  89921. * @param useQuaternion Specifies if quaternions are used in the animation
  89922. */
  89923. private static _CreateCubicSplineAnimation;
  89924. private static _GetBasePositionRotationOrScale;
  89925. /**
  89926. * Adds a key frame value
  89927. * @param keyFrame
  89928. * @param animation
  89929. * @param outputs
  89930. * @param animationChannelTargetPath
  89931. * @param basePositionRotationOrScale
  89932. * @param convertToRightHandedSystem
  89933. * @param useQuaternion
  89934. */
  89935. private static _AddKeyframeValue;
  89936. /**
  89937. * Determine the interpolation based on the key frames
  89938. * @param keyFrames
  89939. * @param animationChannelTargetPath
  89940. * @param useQuaternion
  89941. */
  89942. private static _DeduceInterpolation;
  89943. /**
  89944. * Adds an input tangent or output tangent to the output data
  89945. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  89946. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  89947. * @param outputs The animation data by keyframe
  89948. * @param animationChannelTargetPath The target animation channel
  89949. * @param interpolation The interpolation type
  89950. * @param keyFrame The key frame with the animation data
  89951. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  89952. * @param useQuaternion Specifies if quaternions are used
  89953. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  89954. */
  89955. private static AddSplineTangent;
  89956. /**
  89957. * Get the minimum and maximum key frames' frame values
  89958. * @param keyFrames animation key frames
  89959. * @returns the minimum and maximum key frame value
  89960. */
  89961. private static calculateMinMaxKeyFrames;
  89962. }
  89963. }
  89964. declare module BABYLON.GLTF2.Exporter {
  89965. /** @hidden */
  89966. export var textureTransformPixelShader: {
  89967. name: string;
  89968. shader: string;
  89969. };
  89970. }
  89971. declare module BABYLON.GLTF2.Exporter.Extensions {
  89972. /**
  89973. * @hidden
  89974. */
  89975. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  89976. private _recordedTextures;
  89977. /** Name of this extension */
  89978. readonly name: string;
  89979. /** Defines whether this extension is enabled */
  89980. enabled: boolean;
  89981. /** Defines whether this extension is required */
  89982. required: boolean;
  89983. /** Reference to the glTF exporter */
  89984. private _wasUsed;
  89985. constructor(exporter: _Exporter);
  89986. dispose(): void;
  89987. /** @hidden */
  89988. get wasUsed(): boolean;
  89989. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  89990. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  89991. /**
  89992. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  89993. * @param babylonTexture
  89994. * @param offset
  89995. * @param rotation
  89996. * @param scale
  89997. * @param scene
  89998. */
  89999. private _textureTransformTextureAsync;
  90000. }
  90001. }
  90002. declare module BABYLON.GLTF2.Exporter.Extensions {
  90003. /**
  90004. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  90005. */
  90006. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  90007. /** The name of this extension. */
  90008. readonly name: string;
  90009. /** Defines whether this extension is enabled. */
  90010. enabled: boolean;
  90011. /** Defines whether this extension is required */
  90012. required: boolean;
  90013. /** Reference to the glTF exporter */
  90014. private _exporter;
  90015. private _lights;
  90016. /** @hidden */
  90017. constructor(exporter: _Exporter);
  90018. /** @hidden */
  90019. dispose(): void;
  90020. /** @hidden */
  90021. get wasUsed(): boolean;
  90022. /** @hidden */
  90023. onExporting(): void;
  90024. /**
  90025. * Define this method to modify the default behavior when exporting a node
  90026. * @param context The context when exporting the node
  90027. * @param node glTF node
  90028. * @param babylonNode BabylonJS node
  90029. * @param nodeMap Node mapping of unique id to glTF node index
  90030. * @returns nullable INode promise
  90031. */
  90032. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  90033. [key: number]: number;
  90034. }): Promise<Nullable<INode>>;
  90035. }
  90036. }
  90037. declare module BABYLON.GLTF2.Exporter.Extensions {
  90038. /**
  90039. * @hidden
  90040. */
  90041. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  90042. /** Name of this extension */
  90043. readonly name: string;
  90044. /** Defines whether this extension is enabled */
  90045. enabled: boolean;
  90046. /** Defines whether this extension is required */
  90047. required: boolean;
  90048. /** Reference to the glTF exporter */
  90049. private _textureInfos;
  90050. private _exportedTextures;
  90051. private _wasUsed;
  90052. constructor(exporter: _Exporter);
  90053. dispose(): void;
  90054. /** @hidden */
  90055. get wasUsed(): boolean;
  90056. private _getTextureIndex;
  90057. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  90058. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  90059. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90060. }
  90061. }
  90062. declare module BABYLON.GLTF2.Exporter.Extensions {
  90063. /**
  90064. * @hidden
  90065. */
  90066. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  90067. /** Name of this extension */
  90068. readonly name: string;
  90069. /** Defines whether this extension is enabled */
  90070. enabled: boolean;
  90071. /** Defines whether this extension is required */
  90072. required: boolean;
  90073. private _wasUsed;
  90074. constructor(exporter: _Exporter);
  90075. /** @hidden */
  90076. get wasUsed(): boolean;
  90077. dispose(): void;
  90078. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  90079. }
  90080. }
  90081. declare module BABYLON {
  90082. /**
  90083. * Class for generating STL data from a Babylon scene.
  90084. */
  90085. export class STLExport {
  90086. /**
  90087. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  90088. * @param meshes list defines the mesh to serialize
  90089. * @param download triggers the automatic download of the file.
  90090. * @param fileName changes the downloads fileName.
  90091. * @param binary changes the STL to a binary type.
  90092. * @param isLittleEndian toggle for binary type exporter.
  90093. * @param doNotBakeTransform toggle if meshes transforms should be baked or not.
  90094. * @returns the STL as UTF8 string
  90095. */
  90096. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean, doNotBakeTransform?: boolean): any;
  90097. }
  90098. }
  90099. declare module "babylonjs-gltf2interface" {
  90100. export = BABYLON.GLTF2;
  90101. }
  90102. /**
  90103. * Module for glTF 2.0 Interface
  90104. */
  90105. declare module BABYLON.GLTF2 {
  90106. /**
  90107. * The datatype of the components in the attribute
  90108. */
  90109. const enum AccessorComponentType {
  90110. /**
  90111. * Byte
  90112. */
  90113. BYTE = 5120,
  90114. /**
  90115. * Unsigned Byte
  90116. */
  90117. UNSIGNED_BYTE = 5121,
  90118. /**
  90119. * Short
  90120. */
  90121. SHORT = 5122,
  90122. /**
  90123. * Unsigned Short
  90124. */
  90125. UNSIGNED_SHORT = 5123,
  90126. /**
  90127. * Unsigned Int
  90128. */
  90129. UNSIGNED_INT = 5125,
  90130. /**
  90131. * Float
  90132. */
  90133. FLOAT = 5126,
  90134. }
  90135. /**
  90136. * Specifies if the attirbute is a scalar, vector, or matrix
  90137. */
  90138. const enum AccessorType {
  90139. /**
  90140. * Scalar
  90141. */
  90142. SCALAR = "SCALAR",
  90143. /**
  90144. * Vector2
  90145. */
  90146. VEC2 = "VEC2",
  90147. /**
  90148. * Vector3
  90149. */
  90150. VEC3 = "VEC3",
  90151. /**
  90152. * Vector4
  90153. */
  90154. VEC4 = "VEC4",
  90155. /**
  90156. * Matrix2x2
  90157. */
  90158. MAT2 = "MAT2",
  90159. /**
  90160. * Matrix3x3
  90161. */
  90162. MAT3 = "MAT3",
  90163. /**
  90164. * Matrix4x4
  90165. */
  90166. MAT4 = "MAT4",
  90167. }
  90168. /**
  90169. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90170. */
  90171. const enum AnimationChannelTargetPath {
  90172. /**
  90173. * Translation
  90174. */
  90175. TRANSLATION = "translation",
  90176. /**
  90177. * Rotation
  90178. */
  90179. ROTATION = "rotation",
  90180. /**
  90181. * Scale
  90182. */
  90183. SCALE = "scale",
  90184. /**
  90185. * Weights
  90186. */
  90187. WEIGHTS = "weights",
  90188. }
  90189. /**
  90190. * Interpolation algorithm
  90191. */
  90192. const enum AnimationSamplerInterpolation {
  90193. /**
  90194. * The animated values are linearly interpolated between keyframes
  90195. */
  90196. LINEAR = "LINEAR",
  90197. /**
  90198. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  90199. */
  90200. STEP = "STEP",
  90201. /**
  90202. * The animation's interpolation is computed using a cubic spline with specified tangents
  90203. */
  90204. CUBICSPLINE = "CUBICSPLINE",
  90205. }
  90206. /**
  90207. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90208. */
  90209. const enum CameraType {
  90210. /**
  90211. * A perspective camera containing properties to create a perspective projection matrix
  90212. */
  90213. PERSPECTIVE = "perspective",
  90214. /**
  90215. * An orthographic camera containing properties to create an orthographic projection matrix
  90216. */
  90217. ORTHOGRAPHIC = "orthographic",
  90218. }
  90219. /**
  90220. * The mime-type of the image
  90221. */
  90222. const enum ImageMimeType {
  90223. /**
  90224. * JPEG Mime-type
  90225. */
  90226. JPEG = "image/jpeg",
  90227. /**
  90228. * PNG Mime-type
  90229. */
  90230. PNG = "image/png",
  90231. }
  90232. /**
  90233. * The alpha rendering mode of the material
  90234. */
  90235. const enum MaterialAlphaMode {
  90236. /**
  90237. * The alpha value is ignored and the rendered output is fully opaque
  90238. */
  90239. OPAQUE = "OPAQUE",
  90240. /**
  90241. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  90242. */
  90243. MASK = "MASK",
  90244. /**
  90245. * 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)
  90246. */
  90247. BLEND = "BLEND",
  90248. }
  90249. /**
  90250. * The type of the primitives to render
  90251. */
  90252. const enum MeshPrimitiveMode {
  90253. /**
  90254. * Points
  90255. */
  90256. POINTS = 0,
  90257. /**
  90258. * Lines
  90259. */
  90260. LINES = 1,
  90261. /**
  90262. * Line Loop
  90263. */
  90264. LINE_LOOP = 2,
  90265. /**
  90266. * Line Strip
  90267. */
  90268. LINE_STRIP = 3,
  90269. /**
  90270. * Triangles
  90271. */
  90272. TRIANGLES = 4,
  90273. /**
  90274. * Triangle Strip
  90275. */
  90276. TRIANGLE_STRIP = 5,
  90277. /**
  90278. * Triangle Fan
  90279. */
  90280. TRIANGLE_FAN = 6,
  90281. }
  90282. /**
  90283. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90284. */
  90285. const enum TextureMagFilter {
  90286. /**
  90287. * Nearest
  90288. */
  90289. NEAREST = 9728,
  90290. /**
  90291. * Linear
  90292. */
  90293. LINEAR = 9729,
  90294. }
  90295. /**
  90296. * Minification filter. All valid values correspond to WebGL enums
  90297. */
  90298. const enum TextureMinFilter {
  90299. /**
  90300. * Nearest
  90301. */
  90302. NEAREST = 9728,
  90303. /**
  90304. * Linear
  90305. */
  90306. LINEAR = 9729,
  90307. /**
  90308. * Nearest Mip-Map Nearest
  90309. */
  90310. NEAREST_MIPMAP_NEAREST = 9984,
  90311. /**
  90312. * Linear Mipmap Nearest
  90313. */
  90314. LINEAR_MIPMAP_NEAREST = 9985,
  90315. /**
  90316. * Nearest Mipmap Linear
  90317. */
  90318. NEAREST_MIPMAP_LINEAR = 9986,
  90319. /**
  90320. * Linear Mipmap Linear
  90321. */
  90322. LINEAR_MIPMAP_LINEAR = 9987,
  90323. }
  90324. /**
  90325. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90326. */
  90327. const enum TextureWrapMode {
  90328. /**
  90329. * Clamp to Edge
  90330. */
  90331. CLAMP_TO_EDGE = 33071,
  90332. /**
  90333. * Mirrored Repeat
  90334. */
  90335. MIRRORED_REPEAT = 33648,
  90336. /**
  90337. * Repeat
  90338. */
  90339. REPEAT = 10497,
  90340. }
  90341. /**
  90342. * glTF Property
  90343. */
  90344. interface IProperty {
  90345. /**
  90346. * Dictionary object with extension-specific objects
  90347. */
  90348. extensions?: {
  90349. [key: string]: any;
  90350. };
  90351. /**
  90352. * Application-Specific data
  90353. */
  90354. extras?: any;
  90355. }
  90356. /**
  90357. * glTF Child of Root Property
  90358. */
  90359. interface IChildRootProperty extends IProperty {
  90360. /**
  90361. * The user-defined name of this object
  90362. */
  90363. name?: string;
  90364. }
  90365. /**
  90366. * Indices of those attributes that deviate from their initialization value
  90367. */
  90368. interface IAccessorSparseIndices extends IProperty {
  90369. /**
  90370. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90371. */
  90372. bufferView: number;
  90373. /**
  90374. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90375. */
  90376. byteOffset?: number;
  90377. /**
  90378. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  90379. */
  90380. componentType: AccessorComponentType;
  90381. }
  90382. /**
  90383. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  90384. */
  90385. interface IAccessorSparseValues extends IProperty {
  90386. /**
  90387. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  90388. */
  90389. bufferView: number;
  90390. /**
  90391. * The offset relative to the start of the bufferView in bytes. Must be aligned
  90392. */
  90393. byteOffset?: number;
  90394. }
  90395. /**
  90396. * Sparse storage of attributes that deviate from their initialization value
  90397. */
  90398. interface IAccessorSparse extends IProperty {
  90399. /**
  90400. * The number of attributes encoded in this sparse accessor
  90401. */
  90402. count: number;
  90403. /**
  90404. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  90405. */
  90406. indices: IAccessorSparseIndices;
  90407. /**
  90408. * 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
  90409. */
  90410. values: IAccessorSparseValues;
  90411. }
  90412. /**
  90413. * 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
  90414. */
  90415. interface IAccessor extends IChildRootProperty {
  90416. /**
  90417. * The index of the bufferview
  90418. */
  90419. bufferView?: number;
  90420. /**
  90421. * The offset relative to the start of the bufferView in bytes
  90422. */
  90423. byteOffset?: number;
  90424. /**
  90425. * The datatype of components in the attribute
  90426. */
  90427. componentType: AccessorComponentType;
  90428. /**
  90429. * Specifies whether integer data values should be normalized
  90430. */
  90431. normalized?: boolean;
  90432. /**
  90433. * The number of attributes referenced by this accessor
  90434. */
  90435. count: number;
  90436. /**
  90437. * Specifies if the attribute is a scalar, vector, or matrix
  90438. */
  90439. type: AccessorType;
  90440. /**
  90441. * Maximum value of each component in this attribute
  90442. */
  90443. max?: number[];
  90444. /**
  90445. * Minimum value of each component in this attribute
  90446. */
  90447. min?: number[];
  90448. /**
  90449. * Sparse storage of attributes that deviate from their initialization value
  90450. */
  90451. sparse?: IAccessorSparse;
  90452. }
  90453. /**
  90454. * Targets an animation's sampler at a node's property
  90455. */
  90456. interface IAnimationChannel extends IProperty {
  90457. /**
  90458. * The index of a sampler in this animation used to compute the value for the target
  90459. */
  90460. sampler: number;
  90461. /**
  90462. * The index of the node and TRS property to target
  90463. */
  90464. target: IAnimationChannelTarget;
  90465. }
  90466. /**
  90467. * The index of the node and TRS property that an animation channel targets
  90468. */
  90469. interface IAnimationChannelTarget extends IProperty {
  90470. /**
  90471. * The index of the node to target
  90472. */
  90473. node: number;
  90474. /**
  90475. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  90476. */
  90477. path: AnimationChannelTargetPath;
  90478. }
  90479. /**
  90480. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90481. */
  90482. interface IAnimationSampler extends IProperty {
  90483. /**
  90484. * The index of an accessor containing keyframe input values, e.g., time
  90485. */
  90486. input: number;
  90487. /**
  90488. * Interpolation algorithm
  90489. */
  90490. interpolation?: AnimationSamplerInterpolation;
  90491. /**
  90492. * The index of an accessor, containing keyframe output values
  90493. */
  90494. output: number;
  90495. }
  90496. /**
  90497. * A keyframe animation
  90498. */
  90499. interface IAnimation extends IChildRootProperty {
  90500. /**
  90501. * An array of channels, each of which targets an animation's sampler at a node's property
  90502. */
  90503. channels: IAnimationChannel[];
  90504. /**
  90505. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  90506. */
  90507. samplers: IAnimationSampler[];
  90508. }
  90509. /**
  90510. * Metadata about the glTF asset
  90511. */
  90512. interface IAsset extends IChildRootProperty {
  90513. /**
  90514. * A copyright message suitable for display to credit the content creator
  90515. */
  90516. copyright?: string;
  90517. /**
  90518. * Tool that generated this glTF model. Useful for debugging
  90519. */
  90520. generator?: string;
  90521. /**
  90522. * The glTF version that this asset targets
  90523. */
  90524. version: string;
  90525. /**
  90526. * The minimum glTF version that this asset targets
  90527. */
  90528. minVersion?: string;
  90529. }
  90530. /**
  90531. * A buffer points to binary geometry, animation, or skins
  90532. */
  90533. interface IBuffer extends IChildRootProperty {
  90534. /**
  90535. * 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
  90536. */
  90537. uri?: string;
  90538. /**
  90539. * The length of the buffer in bytes
  90540. */
  90541. byteLength: number;
  90542. }
  90543. /**
  90544. * A view into a buffer generally representing a subset of the buffer
  90545. */
  90546. interface IBufferView extends IChildRootProperty {
  90547. /**
  90548. * The index of the buffer
  90549. */
  90550. buffer: number;
  90551. /**
  90552. * The offset into the buffer in bytes
  90553. */
  90554. byteOffset?: number;
  90555. /**
  90556. * The lenth of the bufferView in bytes
  90557. */
  90558. byteLength: number;
  90559. /**
  90560. * The stride, in bytes
  90561. */
  90562. byteStride?: number;
  90563. }
  90564. /**
  90565. * An orthographic camera containing properties to create an orthographic projection matrix
  90566. */
  90567. interface ICameraOrthographic extends IProperty {
  90568. /**
  90569. * The floating-point horizontal magnification of the view. Must not be zero
  90570. */
  90571. xmag: number;
  90572. /**
  90573. * The floating-point vertical magnification of the view. Must not be zero
  90574. */
  90575. ymag: number;
  90576. /**
  90577. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  90578. */
  90579. zfar: number;
  90580. /**
  90581. * The floating-point distance to the near clipping plane
  90582. */
  90583. znear: number;
  90584. }
  90585. /**
  90586. * A perspective camera containing properties to create a perspective projection matrix
  90587. */
  90588. interface ICameraPerspective extends IProperty {
  90589. /**
  90590. * The floating-point aspect ratio of the field of view
  90591. */
  90592. aspectRatio?: number;
  90593. /**
  90594. * The floating-point vertical field of view in radians
  90595. */
  90596. yfov: number;
  90597. /**
  90598. * The floating-point distance to the far clipping plane
  90599. */
  90600. zfar?: number;
  90601. /**
  90602. * The floating-point distance to the near clipping plane
  90603. */
  90604. znear: number;
  90605. }
  90606. /**
  90607. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  90608. */
  90609. interface ICamera extends IChildRootProperty {
  90610. /**
  90611. * An orthographic camera containing properties to create an orthographic projection matrix
  90612. */
  90613. orthographic?: ICameraOrthographic;
  90614. /**
  90615. * A perspective camera containing properties to create a perspective projection matrix
  90616. */
  90617. perspective?: ICameraPerspective;
  90618. /**
  90619. * Specifies if the camera uses a perspective or orthographic projection
  90620. */
  90621. type: CameraType;
  90622. }
  90623. /**
  90624. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  90625. */
  90626. interface IImage extends IChildRootProperty {
  90627. /**
  90628. * 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
  90629. */
  90630. uri?: string;
  90631. /**
  90632. * The image's MIME type
  90633. */
  90634. mimeType?: ImageMimeType;
  90635. /**
  90636. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  90637. */
  90638. bufferView?: number;
  90639. }
  90640. /**
  90641. * Material Normal Texture Info
  90642. */
  90643. interface IMaterialNormalTextureInfo extends ITextureInfo {
  90644. /**
  90645. * The scalar multiplier applied to each normal vector of the normal texture
  90646. */
  90647. scale?: number;
  90648. }
  90649. /**
  90650. * Material Occlusion Texture Info
  90651. */
  90652. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  90653. /**
  90654. * A scalar multiplier controlling the amount of occlusion applied
  90655. */
  90656. strength?: number;
  90657. }
  90658. /**
  90659. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  90660. */
  90661. interface IMaterialPbrMetallicRoughness {
  90662. /**
  90663. * The material's base color factor
  90664. */
  90665. baseColorFactor?: number[];
  90666. /**
  90667. * The base color texture
  90668. */
  90669. baseColorTexture?: ITextureInfo;
  90670. /**
  90671. * The metalness of the material
  90672. */
  90673. metallicFactor?: number;
  90674. /**
  90675. * The roughness of the material
  90676. */
  90677. roughnessFactor?: number;
  90678. /**
  90679. * The metallic-roughness texture
  90680. */
  90681. metallicRoughnessTexture?: ITextureInfo;
  90682. }
  90683. /**
  90684. * The material appearance of a primitive
  90685. */
  90686. interface IMaterial extends IChildRootProperty {
  90687. /**
  90688. * 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
  90689. */
  90690. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  90691. /**
  90692. * The normal map texture
  90693. */
  90694. normalTexture?: IMaterialNormalTextureInfo;
  90695. /**
  90696. * The occlusion map texture
  90697. */
  90698. occlusionTexture?: IMaterialOcclusionTextureInfo;
  90699. /**
  90700. * The emissive map texture
  90701. */
  90702. emissiveTexture?: ITextureInfo;
  90703. /**
  90704. * 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
  90705. */
  90706. emissiveFactor?: number[];
  90707. /**
  90708. * The alpha rendering mode of the material
  90709. */
  90710. alphaMode?: MaterialAlphaMode;
  90711. /**
  90712. * The alpha cutoff value of the material
  90713. */
  90714. alphaCutoff?: number;
  90715. /**
  90716. * Specifies whether the material is double sided
  90717. */
  90718. doubleSided?: boolean;
  90719. }
  90720. /**
  90721. * Geometry to be rendered with the given material
  90722. */
  90723. interface IMeshPrimitive extends IProperty {
  90724. /**
  90725. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  90726. */
  90727. attributes: {
  90728. [name: string]: number;
  90729. };
  90730. /**
  90731. * The index of the accessor that contains the indices
  90732. */
  90733. indices?: number;
  90734. /**
  90735. * The index of the material to apply to this primitive when rendering
  90736. */
  90737. material?: number;
  90738. /**
  90739. * The type of primitives to render. All valid values correspond to WebGL enums
  90740. */
  90741. mode?: MeshPrimitiveMode;
  90742. /**
  90743. * 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
  90744. */
  90745. targets?: {
  90746. [name: string]: number;
  90747. }[];
  90748. }
  90749. /**
  90750. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  90751. */
  90752. interface IMesh extends IChildRootProperty {
  90753. /**
  90754. * An array of primitives, each defining geometry to be rendered with a material
  90755. */
  90756. primitives: IMeshPrimitive[];
  90757. /**
  90758. * Array of weights to be applied to the Morph Targets
  90759. */
  90760. weights?: number[];
  90761. }
  90762. /**
  90763. * A node in the node hierarchy
  90764. */
  90765. interface INode extends IChildRootProperty {
  90766. /**
  90767. * The index of the camera referenced by this node
  90768. */
  90769. camera?: number;
  90770. /**
  90771. * The indices of this node's children
  90772. */
  90773. children?: number[];
  90774. /**
  90775. * The index of the skin referenced by this node
  90776. */
  90777. skin?: number;
  90778. /**
  90779. * A floating-point 4x4 transformation matrix stored in column-major order
  90780. */
  90781. matrix?: number[];
  90782. /**
  90783. * The index of the mesh in this node
  90784. */
  90785. mesh?: number;
  90786. /**
  90787. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  90788. */
  90789. rotation?: number[];
  90790. /**
  90791. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  90792. */
  90793. scale?: number[];
  90794. /**
  90795. * The node's translation along the x, y, and z axes
  90796. */
  90797. translation?: number[];
  90798. /**
  90799. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  90800. */
  90801. weights?: number[];
  90802. }
  90803. /**
  90804. * Texture sampler properties for filtering and wrapping modes
  90805. */
  90806. interface ISampler extends IChildRootProperty {
  90807. /**
  90808. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  90809. */
  90810. magFilter?: TextureMagFilter;
  90811. /**
  90812. * Minification filter. All valid values correspond to WebGL enums
  90813. */
  90814. minFilter?: TextureMinFilter;
  90815. /**
  90816. * S (U) wrapping mode. All valid values correspond to WebGL enums
  90817. */
  90818. wrapS?: TextureWrapMode;
  90819. /**
  90820. * T (V) wrapping mode. All valid values correspond to WebGL enums
  90821. */
  90822. wrapT?: TextureWrapMode;
  90823. }
  90824. /**
  90825. * The root nodes of a scene
  90826. */
  90827. interface IScene extends IChildRootProperty {
  90828. /**
  90829. * The indices of each root node
  90830. */
  90831. nodes: number[];
  90832. }
  90833. /**
  90834. * Joints and matrices defining a skin
  90835. */
  90836. interface ISkin extends IChildRootProperty {
  90837. /**
  90838. * 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
  90839. */
  90840. inverseBindMatrices?: number;
  90841. /**
  90842. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  90843. */
  90844. skeleton?: number;
  90845. /**
  90846. * 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)
  90847. */
  90848. joints: number[];
  90849. }
  90850. /**
  90851. * A texture and its sampler
  90852. */
  90853. interface ITexture extends IChildRootProperty {
  90854. /**
  90855. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  90856. */
  90857. sampler?: number;
  90858. /**
  90859. * The index of the image used by this texture
  90860. */
  90861. source: number;
  90862. }
  90863. /**
  90864. * Reference to a texture
  90865. */
  90866. interface ITextureInfo extends IProperty {
  90867. /**
  90868. * The index of the texture
  90869. */
  90870. index: number;
  90871. /**
  90872. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  90873. */
  90874. texCoord?: number;
  90875. }
  90876. /**
  90877. * The root object for a glTF asset
  90878. */
  90879. interface IGLTF extends IProperty {
  90880. /**
  90881. * An array of accessors. An accessor is a typed view into a bufferView
  90882. */
  90883. accessors?: IAccessor[];
  90884. /**
  90885. * An array of keyframe animations
  90886. */
  90887. animations?: IAnimation[];
  90888. /**
  90889. * Metadata about the glTF asset
  90890. */
  90891. asset: IAsset;
  90892. /**
  90893. * An array of buffers. A buffer points to binary geometry, animation, or skins
  90894. */
  90895. buffers?: IBuffer[];
  90896. /**
  90897. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  90898. */
  90899. bufferViews?: IBufferView[];
  90900. /**
  90901. * An array of cameras
  90902. */
  90903. cameras?: ICamera[];
  90904. /**
  90905. * Names of glTF extensions used somewhere in this asset
  90906. */
  90907. extensionsUsed?: string[];
  90908. /**
  90909. * Names of glTF extensions required to properly load this asset
  90910. */
  90911. extensionsRequired?: string[];
  90912. /**
  90913. * An array of images. An image defines data used to create a texture
  90914. */
  90915. images?: IImage[];
  90916. /**
  90917. * An array of materials. A material defines the appearance of a primitive
  90918. */
  90919. materials?: IMaterial[];
  90920. /**
  90921. * An array of meshes. A mesh is a set of primitives to be rendered
  90922. */
  90923. meshes?: IMesh[];
  90924. /**
  90925. * An array of nodes
  90926. */
  90927. nodes?: INode[];
  90928. /**
  90929. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  90930. */
  90931. samplers?: ISampler[];
  90932. /**
  90933. * The index of the default scene
  90934. */
  90935. scene?: number;
  90936. /**
  90937. * An array of scenes
  90938. */
  90939. scenes?: IScene[];
  90940. /**
  90941. * An array of skins. A skin is defined by joints and matrices
  90942. */
  90943. skins?: ISkin[];
  90944. /**
  90945. * An array of textures
  90946. */
  90947. textures?: ITexture[];
  90948. }
  90949. /**
  90950. * The glTF validation results
  90951. * @ignore
  90952. */
  90953. interface IGLTFValidationResults {
  90954. info: {
  90955. generator: string;
  90956. hasAnimations: boolean;
  90957. hasDefaultScene: boolean;
  90958. hasMaterials: boolean;
  90959. hasMorphTargets: boolean;
  90960. hasSkins: boolean;
  90961. hasTextures: boolean;
  90962. maxAttributesUsed: number;
  90963. primitivesCount: number
  90964. };
  90965. issues: {
  90966. messages: Array<string>;
  90967. numErrors: number;
  90968. numHints: number;
  90969. numInfos: number;
  90970. numWarnings: number;
  90971. truncated: boolean
  90972. };
  90973. mimeType: string;
  90974. uri: string;
  90975. validatedAt: string;
  90976. validatorVersion: string;
  90977. }
  90978. /**
  90979. * The glTF validation options
  90980. */
  90981. interface IGLTFValidationOptions {
  90982. /** Uri to use */
  90983. uri?: string;
  90984. /** Function used to load external resources */
  90985. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  90986. /** Boolean indicating that we need to validate accessor data */
  90987. validateAccessorData?: boolean;
  90988. /** max number of issues allowed */
  90989. maxIssues?: number;
  90990. /** Ignored issues */
  90991. ignoredIssues?: Array<string>;
  90992. /** Value to override severy settings */
  90993. severityOverrides?: Object;
  90994. }
  90995. /**
  90996. * The glTF validator object
  90997. * @ignore
  90998. */
  90999. interface IGLTFValidator {
  91000. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91001. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  91002. }
  91003. /**
  91004. * Interfaces from the EXT_lights_image_based extension
  91005. */
  91006. /** @hidden */
  91007. interface IEXTLightsImageBased_LightReferenceImageBased {
  91008. light: number;
  91009. }
  91010. /** @hidden */
  91011. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  91012. intensity: number;
  91013. rotation: number[];
  91014. specularImageSize: number;
  91015. specularImages: number[][];
  91016. irradianceCoefficients: number[][];
  91017. }
  91018. /** @hidden */
  91019. interface IEXTLightsImageBased {
  91020. lights: IEXTLightsImageBased_LightImageBased[];
  91021. }
  91022. /**
  91023. * Interfaces from the EXT_mesh_gpu_instancing extension
  91024. * !!! Experimental Extension Subject to Changes !!!
  91025. */
  91026. /** @hidden */
  91027. interface IEXTMeshGpuInstancing {
  91028. mesh?: number;
  91029. attributes: { [name: string]: number };
  91030. }
  91031. /**
  91032. * Interfaces from the KHR_draco_mesh_compression extension
  91033. */
  91034. /** @hidden */
  91035. interface IKHRDracoMeshCompression {
  91036. bufferView: number;
  91037. attributes: { [name: string]: number };
  91038. }
  91039. /**
  91040. * Interfaces from the KHR_lights_punctual extension
  91041. */
  91042. /** @hidden */
  91043. const enum IKHRLightsPunctual_LightType {
  91044. DIRECTIONAL = "directional",
  91045. POINT = "point",
  91046. SPOT = "spot"
  91047. }
  91048. /** @hidden */
  91049. interface IKHRLightsPunctual_LightReference {
  91050. light: number;
  91051. }
  91052. /** @hidden */
  91053. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  91054. type: IKHRLightsPunctual_LightType;
  91055. color?: number[];
  91056. intensity?: number;
  91057. range?: number;
  91058. spot?: {
  91059. innerConeAngle?: number;
  91060. outerConeAngle?: number;
  91061. };
  91062. }
  91063. /** @hidden */
  91064. interface IKHRLightsPunctual {
  91065. lights: IKHRLightsPunctual_Light[];
  91066. }
  91067. /**
  91068. * Interfaces from the KHR_materials_clearcoat extension
  91069. * !!! Experimental Extension Subject to Changes !!!
  91070. */
  91071. /** @hidden */
  91072. interface IKHRMaterialsClearcoat {
  91073. clearcoatFactor: number;
  91074. clearcoatTexture: ITextureInfo;
  91075. clearcoatRoughnessFactor: number;
  91076. clearcoatRoughnessTexture: ITextureInfo;
  91077. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  91078. }
  91079. /**
  91080. * Interfaces from the KHR_materials_ior extension
  91081. * !!! Experimental Extension Subject to Changes !!!
  91082. */
  91083. /** @hidden */
  91084. interface IKHRMaterialsIor {
  91085. ior: number;
  91086. }
  91087. /**
  91088. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  91089. */
  91090. /** @hidden */
  91091. interface IKHRMaterialsPbrSpecularGlossiness {
  91092. diffuseFactor: number[];
  91093. diffuseTexture: ITextureInfo;
  91094. specularFactor: number[];
  91095. glossinessFactor: number;
  91096. specularGlossinessTexture: ITextureInfo;
  91097. }
  91098. /**
  91099. * Interfaces from the KHR_materials_sheen extension
  91100. * !!! Experimental Extension Subject to Changes !!!
  91101. */
  91102. /** @hidden */
  91103. interface IKHRMaterialsSheen {
  91104. sheenColorFactor?: number[];
  91105. sheenColorTexture?: ITextureInfo;
  91106. sheenRoughnessFactor?: number;
  91107. sheenRoughnessTexture?: ITextureInfo;
  91108. }
  91109. /**
  91110. * Interfaces from the KHR_materials_specular extension
  91111. * !!! Experimental Extension Subject to Changes !!!
  91112. */
  91113. /** @hidden */
  91114. interface IKHRMaterialsSpecular {
  91115. specularFactor: number;
  91116. specularColorFactor: number[];
  91117. specularTexture: ITextureInfo;
  91118. }
  91119. /**
  91120. * Interfaces from the KHR_materials_transmission extension
  91121. * !!! Experimental Extension Subject to Changes !!!
  91122. */
  91123. /** @hidden */
  91124. interface IKHRMaterialsTransmission {
  91125. transmissionFactor?: number;
  91126. transmissionTexture?: ITextureInfo;
  91127. }
  91128. /**
  91129. * Interfaces from the KHR_materials_translucency extension
  91130. * !!! Experimental Extension Subject to Changes !!!
  91131. */
  91132. /** @hidden */
  91133. interface IKHRMaterialsTranslucency {
  91134. translucencyFactor?: number;
  91135. translucencyTexture?: ITextureInfo;
  91136. }
  91137. /**
  91138. * Interfaces from the KHR_materials_variants extension
  91139. * !!! Experimental Extension Subject to Changes !!!
  91140. */
  91141. /** @hidden */
  91142. interface IKHRMaterialVariants_Mapping extends IProperty {
  91143. mappings: Array<{
  91144. variants: number[];
  91145. material: number;
  91146. }>;
  91147. }
  91148. /** @hidden */
  91149. interface IKHRMaterialVariants_Variant extends IProperty {
  91150. name: string;
  91151. }
  91152. /** @hidden */
  91153. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  91154. variants: Array<IKHRMaterialVariants_Variant>;
  91155. }
  91156. /**
  91157. * Interfaces from the KHR_texture_basisu extension
  91158. * !!! Experimental Extension Subject to Changes !!!
  91159. */
  91160. /** @hidden */
  91161. interface IKHRTextureBasisU {
  91162. source: number;
  91163. }
  91164. /**
  91165. * Interfaces from the EXT_texture_webp extension
  91166. */
  91167. /** @hidden */
  91168. interface IEXTTextureWebP {
  91169. source: number;
  91170. }
  91171. /**
  91172. * Interfaces from the KHR_texture_transform extension
  91173. */
  91174. /** @hidden */
  91175. interface IKHRTextureTransform {
  91176. offset?: number[];
  91177. rotation?: number;
  91178. scale?: number[];
  91179. texCoord?: number;
  91180. }
  91181. /**
  91182. * Interfaces from the KHR_xmp extension
  91183. * !!! Experimental Extension Subject to Changes !!!
  91184. */
  91185. /** @hidden */
  91186. interface IKHRXmp_Data {
  91187. [key: string]: unknown;
  91188. }
  91189. /** @hidden */
  91190. interface IKHRXmp_Gltf {
  91191. packets: IKHRXmp_Data[];
  91192. }
  91193. /** @hidden */
  91194. interface IKHRXmp_Node {
  91195. packet: number;
  91196. }
  91197. /**
  91198. * Interfaces from the MSFT_audio_emitter extension
  91199. */
  91200. /** @hidden */
  91201. interface IMSFTAudioEmitter_ClipReference {
  91202. clip: number;
  91203. weight?: number;
  91204. }
  91205. /** @hidden */
  91206. interface IMSFTAudioEmitter_EmittersReference {
  91207. emitters: number[];
  91208. }
  91209. /** @hidden */
  91210. const enum IMSFTAudioEmitter_DistanceModel {
  91211. linear = "linear",
  91212. inverse = "inverse",
  91213. exponential = "exponential",
  91214. }
  91215. /** @hidden */
  91216. interface IMSFTAudioEmitter_Emitter {
  91217. name?: string;
  91218. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  91219. refDistance?: number;
  91220. maxDistance?: number;
  91221. rolloffFactor?: number;
  91222. innerAngle?: number;
  91223. outerAngle?: number;
  91224. loop?: boolean;
  91225. volume?: number;
  91226. clips: IMSFTAudioEmitter_ClipReference[];
  91227. }
  91228. /** @hidden */
  91229. const enum IMSFTAudioEmitter_AudioMimeType {
  91230. WAV = "audio/wav",
  91231. }
  91232. /** @hidden */
  91233. interface IMSFTAudioEmitter_Clip extends IProperty {
  91234. uri?: string;
  91235. bufferView?: number;
  91236. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  91237. }
  91238. /** @hidden */
  91239. const enum IMSFTAudioEmitter_AnimationEventAction {
  91240. play = "play",
  91241. pause = "pause",
  91242. stop = "stop",
  91243. }
  91244. /** @hidden */
  91245. interface IMSFTAudioEmitter_AnimationEvent {
  91246. action: IMSFTAudioEmitter_AnimationEventAction;
  91247. emitter: number;
  91248. time: number;
  91249. startOffset?: number;
  91250. }
  91251. /**
  91252. * Interfaces from the MSFT_lod extension
  91253. */
  91254. /** @hidden */
  91255. interface IMSFTLOD {
  91256. ids: number[];
  91257. }
  91258. /**
  91259. * Interfaces from the EXT_meshopt_compression extension
  91260. */
  91261. /** @hidden */
  91262. interface IEXTMeshoptCompression {
  91263. buffer: number;
  91264. byteOffset?: number;
  91265. byteLength: number;
  91266. byteStride: number;
  91267. count: number;
  91268. mode: "ATTRIBUTES" | "TRIANGLES" | "INDICES";
  91269. filter?: "NONE" | "OCTAHEDRAL" | "QUATERNION" | "EXPONENTIAL";
  91270. }
  91271. }
  91272. declare module BABYLON {
  91273. /** @hidden */
  91274. export var cellPixelShader: {
  91275. name: string;
  91276. shader: string;
  91277. };
  91278. }
  91279. declare module BABYLON {
  91280. /** @hidden */
  91281. export var cellVertexShader: {
  91282. name: string;
  91283. shader: string;
  91284. };
  91285. }
  91286. declare module BABYLON {
  91287. export class CellMaterial extends BABYLON.PushMaterial {
  91288. private _diffuseTexture;
  91289. diffuseTexture: BABYLON.BaseTexture;
  91290. diffuseColor: BABYLON.Color3;
  91291. _computeHighLevel: boolean;
  91292. computeHighLevel: boolean;
  91293. private _disableLighting;
  91294. disableLighting: boolean;
  91295. private _maxSimultaneousLights;
  91296. maxSimultaneousLights: number;
  91297. constructor(name: string, scene: BABYLON.Scene);
  91298. needAlphaBlending(): boolean;
  91299. needAlphaTesting(): boolean;
  91300. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91301. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91302. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91303. getAnimatables(): BABYLON.IAnimatable[];
  91304. getActiveTextures(): BABYLON.BaseTexture[];
  91305. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91306. dispose(forceDisposeEffect?: boolean): void;
  91307. getClassName(): string;
  91308. clone(name: string): CellMaterial;
  91309. serialize(): any;
  91310. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  91311. }
  91312. }
  91313. declare module BABYLON {
  91314. export class CustomShaderStructure {
  91315. FragmentStore: string;
  91316. VertexStore: string;
  91317. constructor();
  91318. }
  91319. export class ShaderSpecialParts {
  91320. constructor();
  91321. Fragment_Begin: string;
  91322. Fragment_Definitions: string;
  91323. Fragment_MainBegin: string;
  91324. Fragment_Custom_Diffuse: string;
  91325. Fragment_Before_Lights: string;
  91326. Fragment_Before_Fog: string;
  91327. Fragment_Custom_Alpha: string;
  91328. Fragment_Before_FragColor: string;
  91329. Vertex_Begin: string;
  91330. Vertex_Definitions: string;
  91331. Vertex_MainBegin: string;
  91332. Vertex_Before_PositionUpdated: string;
  91333. Vertex_Before_NormalUpdated: string;
  91334. Vertex_After_WorldPosComputed: string;
  91335. Vertex_MainEnd: string;
  91336. }
  91337. export class CustomMaterial extends BABYLON.StandardMaterial {
  91338. static ShaderIndexer: number;
  91339. CustomParts: ShaderSpecialParts;
  91340. _isCreatedShader: boolean;
  91341. _createdShaderName: string;
  91342. _customUniform: string[];
  91343. _newUniforms: string[];
  91344. _newUniformInstances: {
  91345. [name: string]: any;
  91346. };
  91347. _newSamplerInstances: {
  91348. [name: string]: BABYLON.Texture;
  91349. };
  91350. _customAttributes: string[];
  91351. FragmentShader: string;
  91352. VertexShader: string;
  91353. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91354. ReviewUniform(name: string, arr: string[]): string[];
  91355. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91356. constructor(name: string, scene: BABYLON.Scene);
  91357. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  91358. AddAttribute(name: string): CustomMaterial;
  91359. Fragment_Begin(shaderPart: string): CustomMaterial;
  91360. Fragment_Definitions(shaderPart: string): CustomMaterial;
  91361. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  91362. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  91363. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  91364. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  91365. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  91366. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  91367. Vertex_Begin(shaderPart: string): CustomMaterial;
  91368. Vertex_Definitions(shaderPart: string): CustomMaterial;
  91369. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  91370. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  91371. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  91372. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  91373. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  91374. }
  91375. }
  91376. declare module BABYLON {
  91377. export class ShaderAlebdoParts {
  91378. constructor();
  91379. Fragment_Begin: string;
  91380. Fragment_Definitions: string;
  91381. Fragment_MainBegin: string;
  91382. Fragment_Custom_Albedo: string;
  91383. Fragment_Before_Lights: string;
  91384. Fragment_Custom_MetallicRoughness: string;
  91385. Fragment_Custom_MicroSurface: string;
  91386. Fragment_Before_Fog: string;
  91387. Fragment_Custom_Alpha: string;
  91388. Fragment_Before_FragColor: string;
  91389. Vertex_Begin: string;
  91390. Vertex_Definitions: string;
  91391. Vertex_MainBegin: string;
  91392. Vertex_Before_PositionUpdated: string;
  91393. Vertex_Before_NormalUpdated: string;
  91394. Vertex_After_WorldPosComputed: string;
  91395. Vertex_MainEnd: string;
  91396. }
  91397. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  91398. static ShaderIndexer: number;
  91399. CustomParts: ShaderAlebdoParts;
  91400. _isCreatedShader: boolean;
  91401. _createdShaderName: string;
  91402. _customUniform: string[];
  91403. _newUniforms: string[];
  91404. _newUniformInstances: {
  91405. [name: string]: any;
  91406. };
  91407. _newSamplerInstances: {
  91408. [name: string]: BABYLON.Texture;
  91409. };
  91410. _customAttributes: string[];
  91411. FragmentShader: string;
  91412. VertexShader: string;
  91413. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  91414. ReviewUniform(name: string, arr: string[]): string[];
  91415. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  91416. constructor(name: string, scene: BABYLON.Scene);
  91417. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  91418. AddAttribute(name: string): PBRCustomMaterial;
  91419. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  91420. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  91421. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  91422. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  91423. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  91424. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  91425. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  91426. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  91427. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  91428. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  91429. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  91430. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  91431. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  91432. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  91433. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  91434. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  91435. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  91436. }
  91437. }
  91438. declare module BABYLON {
  91439. /** @hidden */
  91440. export var firePixelShader: {
  91441. name: string;
  91442. shader: string;
  91443. };
  91444. }
  91445. declare module BABYLON {
  91446. /** @hidden */
  91447. export var fireVertexShader: {
  91448. name: string;
  91449. shader: string;
  91450. };
  91451. }
  91452. declare module BABYLON {
  91453. export class FireMaterial extends BABYLON.PushMaterial {
  91454. private _diffuseTexture;
  91455. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91456. private _distortionTexture;
  91457. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91458. private _opacityTexture;
  91459. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  91460. diffuseColor: BABYLON.Color3;
  91461. speed: number;
  91462. private _scaledDiffuse;
  91463. private _lastTime;
  91464. constructor(name: string, scene: BABYLON.Scene);
  91465. needAlphaBlending(): boolean;
  91466. needAlphaTesting(): boolean;
  91467. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91468. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91469. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91470. getAnimatables(): BABYLON.IAnimatable[];
  91471. getActiveTextures(): BABYLON.BaseTexture[];
  91472. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91473. getClassName(): string;
  91474. dispose(forceDisposeEffect?: boolean): void;
  91475. clone(name: string): FireMaterial;
  91476. serialize(): any;
  91477. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  91478. }
  91479. }
  91480. declare module BABYLON {
  91481. /** @hidden */
  91482. export var furPixelShader: {
  91483. name: string;
  91484. shader: string;
  91485. };
  91486. }
  91487. declare module BABYLON {
  91488. /** @hidden */
  91489. export var furVertexShader: {
  91490. name: string;
  91491. shader: string;
  91492. };
  91493. }
  91494. declare module BABYLON {
  91495. export class FurMaterial extends BABYLON.PushMaterial {
  91496. private _diffuseTexture;
  91497. diffuseTexture: BABYLON.BaseTexture;
  91498. private _heightTexture;
  91499. heightTexture: BABYLON.BaseTexture;
  91500. diffuseColor: BABYLON.Color3;
  91501. furLength: number;
  91502. furAngle: number;
  91503. furColor: BABYLON.Color3;
  91504. furOffset: number;
  91505. furSpacing: number;
  91506. furGravity: BABYLON.Vector3;
  91507. furSpeed: number;
  91508. furDensity: number;
  91509. furOcclusion: number;
  91510. furTexture: BABYLON.DynamicTexture;
  91511. private _disableLighting;
  91512. disableLighting: boolean;
  91513. private _maxSimultaneousLights;
  91514. maxSimultaneousLights: number;
  91515. highLevelFur: boolean;
  91516. _meshes: BABYLON.AbstractMesh[];
  91517. private _furTime;
  91518. constructor(name: string, scene: BABYLON.Scene);
  91519. get furTime(): number;
  91520. set furTime(furTime: number);
  91521. needAlphaBlending(): boolean;
  91522. needAlphaTesting(): boolean;
  91523. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91524. updateFur(): void;
  91525. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91526. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91527. getAnimatables(): BABYLON.IAnimatable[];
  91528. getActiveTextures(): BABYLON.BaseTexture[];
  91529. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91530. dispose(forceDisposeEffect?: boolean): void;
  91531. clone(name: string): FurMaterial;
  91532. serialize(): any;
  91533. getClassName(): string;
  91534. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  91535. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  91536. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  91537. }
  91538. }
  91539. declare module BABYLON {
  91540. /** @hidden */
  91541. export var gradientPixelShader: {
  91542. name: string;
  91543. shader: string;
  91544. };
  91545. }
  91546. declare module BABYLON {
  91547. /** @hidden */
  91548. export var gradientVertexShader: {
  91549. name: string;
  91550. shader: string;
  91551. };
  91552. }
  91553. declare module BABYLON {
  91554. export class GradientMaterial extends BABYLON.PushMaterial {
  91555. private _maxSimultaneousLights;
  91556. maxSimultaneousLights: number;
  91557. topColor: BABYLON.Color3;
  91558. topColorAlpha: number;
  91559. bottomColor: BABYLON.Color3;
  91560. bottomColorAlpha: number;
  91561. offset: number;
  91562. scale: number;
  91563. smoothness: number;
  91564. private _disableLighting;
  91565. disableLighting: boolean;
  91566. constructor(name: string, scene: BABYLON.Scene);
  91567. needAlphaBlending(): boolean;
  91568. needAlphaTesting(): boolean;
  91569. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91570. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91571. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91572. getAnimatables(): BABYLON.IAnimatable[];
  91573. dispose(forceDisposeEffect?: boolean): void;
  91574. clone(name: string): GradientMaterial;
  91575. serialize(): any;
  91576. getClassName(): string;
  91577. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  91578. }
  91579. }
  91580. declare module BABYLON {
  91581. /** @hidden */
  91582. export var gridPixelShader: {
  91583. name: string;
  91584. shader: string;
  91585. };
  91586. }
  91587. declare module BABYLON {
  91588. /** @hidden */
  91589. export var gridVertexShader: {
  91590. name: string;
  91591. shader: string;
  91592. };
  91593. }
  91594. declare module BABYLON {
  91595. /**
  91596. * The grid materials allows you to wrap any shape with a grid.
  91597. * Colors are customizable.
  91598. */
  91599. export class GridMaterial extends BABYLON.PushMaterial {
  91600. /**
  91601. * Main color of the grid (e.g. between lines)
  91602. */
  91603. mainColor: BABYLON.Color3;
  91604. /**
  91605. * Color of the grid lines.
  91606. */
  91607. lineColor: BABYLON.Color3;
  91608. /**
  91609. * The scale of the grid compared to unit.
  91610. */
  91611. gridRatio: number;
  91612. /**
  91613. * Allows setting an offset for the grid lines.
  91614. */
  91615. gridOffset: BABYLON.Vector3;
  91616. /**
  91617. * The frequency of thicker lines.
  91618. */
  91619. majorUnitFrequency: number;
  91620. /**
  91621. * The visibility of minor units in the grid.
  91622. */
  91623. minorUnitVisibility: number;
  91624. /**
  91625. * The grid opacity outside of the lines.
  91626. */
  91627. opacity: number;
  91628. /**
  91629. * Determine RBG output is premultiplied by alpha value.
  91630. */
  91631. preMultiplyAlpha: boolean;
  91632. private _opacityTexture;
  91633. opacityTexture: BABYLON.BaseTexture;
  91634. private _gridControl;
  91635. /**
  91636. * constructor
  91637. * @param name The name given to the material in order to identify it afterwards.
  91638. * @param scene The scene the material is used in.
  91639. */
  91640. constructor(name: string, scene: BABYLON.Scene);
  91641. /**
  91642. * Returns wehter or not the grid requires alpha blending.
  91643. */
  91644. needAlphaBlending(): boolean;
  91645. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91646. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91647. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91648. /**
  91649. * Dispose the material and its associated resources.
  91650. * @param forceDisposeEffect will also dispose the used effect when true
  91651. */
  91652. dispose(forceDisposeEffect?: boolean): void;
  91653. clone(name: string): GridMaterial;
  91654. serialize(): any;
  91655. getClassName(): string;
  91656. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  91657. }
  91658. }
  91659. declare module BABYLON {
  91660. /** @hidden */
  91661. export var lavaPixelShader: {
  91662. name: string;
  91663. shader: string;
  91664. };
  91665. }
  91666. declare module BABYLON {
  91667. /** @hidden */
  91668. export var lavaVertexShader: {
  91669. name: string;
  91670. shader: string;
  91671. };
  91672. }
  91673. declare module BABYLON {
  91674. export class LavaMaterial extends BABYLON.PushMaterial {
  91675. private _diffuseTexture;
  91676. diffuseTexture: BABYLON.BaseTexture;
  91677. noiseTexture: BABYLON.BaseTexture;
  91678. fogColor: BABYLON.Color3;
  91679. speed: number;
  91680. movingSpeed: number;
  91681. lowFrequencySpeed: number;
  91682. fogDensity: number;
  91683. private _lastTime;
  91684. diffuseColor: BABYLON.Color3;
  91685. private _disableLighting;
  91686. disableLighting: boolean;
  91687. private _unlit;
  91688. unlit: boolean;
  91689. private _maxSimultaneousLights;
  91690. maxSimultaneousLights: number;
  91691. private _scaledDiffuse;
  91692. constructor(name: string, scene: BABYLON.Scene);
  91693. needAlphaBlending(): boolean;
  91694. needAlphaTesting(): boolean;
  91695. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91696. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91697. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91698. getAnimatables(): BABYLON.IAnimatable[];
  91699. getActiveTextures(): BABYLON.BaseTexture[];
  91700. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91701. dispose(forceDisposeEffect?: boolean): void;
  91702. clone(name: string): LavaMaterial;
  91703. serialize(): any;
  91704. getClassName(): string;
  91705. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  91706. }
  91707. }
  91708. declare module BABYLON {
  91709. /** @hidden */
  91710. export var mixPixelShader: {
  91711. name: string;
  91712. shader: string;
  91713. };
  91714. }
  91715. declare module BABYLON {
  91716. /** @hidden */
  91717. export var mixVertexShader: {
  91718. name: string;
  91719. shader: string;
  91720. };
  91721. }
  91722. declare module BABYLON {
  91723. export class MixMaterial extends BABYLON.PushMaterial {
  91724. /**
  91725. * Mix textures
  91726. */
  91727. private _mixTexture1;
  91728. mixTexture1: BABYLON.BaseTexture;
  91729. private _mixTexture2;
  91730. mixTexture2: BABYLON.BaseTexture;
  91731. /**
  91732. * Diffuse textures
  91733. */
  91734. private _diffuseTexture1;
  91735. diffuseTexture1: BABYLON.Texture;
  91736. private _diffuseTexture2;
  91737. diffuseTexture2: BABYLON.Texture;
  91738. private _diffuseTexture3;
  91739. diffuseTexture3: BABYLON.Texture;
  91740. private _diffuseTexture4;
  91741. diffuseTexture4: BABYLON.Texture;
  91742. private _diffuseTexture5;
  91743. diffuseTexture5: BABYLON.Texture;
  91744. private _diffuseTexture6;
  91745. diffuseTexture6: BABYLON.Texture;
  91746. private _diffuseTexture7;
  91747. diffuseTexture7: BABYLON.Texture;
  91748. private _diffuseTexture8;
  91749. diffuseTexture8: BABYLON.Texture;
  91750. /**
  91751. * Uniforms
  91752. */
  91753. diffuseColor: BABYLON.Color3;
  91754. specularColor: BABYLON.Color3;
  91755. specularPower: number;
  91756. private _disableLighting;
  91757. disableLighting: boolean;
  91758. private _maxSimultaneousLights;
  91759. maxSimultaneousLights: number;
  91760. constructor(name: string, scene: BABYLON.Scene);
  91761. needAlphaBlending(): boolean;
  91762. needAlphaTesting(): boolean;
  91763. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91764. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91765. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91766. getAnimatables(): BABYLON.IAnimatable[];
  91767. getActiveTextures(): BABYLON.BaseTexture[];
  91768. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91769. dispose(forceDisposeEffect?: boolean): void;
  91770. clone(name: string): MixMaterial;
  91771. serialize(): any;
  91772. getClassName(): string;
  91773. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  91774. }
  91775. }
  91776. declare module BABYLON {
  91777. /** @hidden */
  91778. export var normalPixelShader: {
  91779. name: string;
  91780. shader: string;
  91781. };
  91782. }
  91783. declare module BABYLON {
  91784. /** @hidden */
  91785. export var normalVertexShader: {
  91786. name: string;
  91787. shader: string;
  91788. };
  91789. }
  91790. declare module BABYLON {
  91791. export class NormalMaterial extends BABYLON.PushMaterial {
  91792. private _diffuseTexture;
  91793. diffuseTexture: BABYLON.BaseTexture;
  91794. diffuseColor: BABYLON.Color3;
  91795. private _disableLighting;
  91796. disableLighting: boolean;
  91797. private _maxSimultaneousLights;
  91798. maxSimultaneousLights: number;
  91799. constructor(name: string, scene: BABYLON.Scene);
  91800. needAlphaBlending(): boolean;
  91801. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  91802. needAlphaTesting(): boolean;
  91803. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91804. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91805. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91806. getAnimatables(): BABYLON.IAnimatable[];
  91807. getActiveTextures(): BABYLON.BaseTexture[];
  91808. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91809. dispose(forceDisposeEffect?: boolean): void;
  91810. clone(name: string): NormalMaterial;
  91811. serialize(): any;
  91812. getClassName(): string;
  91813. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  91814. }
  91815. }
  91816. declare module BABYLON {
  91817. /** @hidden */
  91818. export var shadowOnlyPixelShader: {
  91819. name: string;
  91820. shader: string;
  91821. };
  91822. }
  91823. declare module BABYLON {
  91824. /** @hidden */
  91825. export var shadowOnlyVertexShader: {
  91826. name: string;
  91827. shader: string;
  91828. };
  91829. }
  91830. declare module BABYLON {
  91831. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  91832. private _activeLight;
  91833. private _needAlphaBlending;
  91834. constructor(name: string, scene: BABYLON.Scene);
  91835. shadowColor: BABYLON.Color3;
  91836. needAlphaBlending(): boolean;
  91837. needAlphaTesting(): boolean;
  91838. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91839. get activeLight(): BABYLON.IShadowLight;
  91840. set activeLight(light: BABYLON.IShadowLight);
  91841. private _getFirstShadowLightForMesh;
  91842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91844. clone(name: string): ShadowOnlyMaterial;
  91845. serialize(): any;
  91846. getClassName(): string;
  91847. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  91848. }
  91849. }
  91850. declare module BABYLON {
  91851. /** @hidden */
  91852. export var simplePixelShader: {
  91853. name: string;
  91854. shader: string;
  91855. };
  91856. }
  91857. declare module BABYLON {
  91858. /** @hidden */
  91859. export var simpleVertexShader: {
  91860. name: string;
  91861. shader: string;
  91862. };
  91863. }
  91864. declare module BABYLON {
  91865. export class SimpleMaterial extends BABYLON.PushMaterial {
  91866. private _diffuseTexture;
  91867. diffuseTexture: BABYLON.BaseTexture;
  91868. diffuseColor: BABYLON.Color3;
  91869. private _disableLighting;
  91870. disableLighting: boolean;
  91871. private _maxSimultaneousLights;
  91872. maxSimultaneousLights: number;
  91873. constructor(name: string, scene: BABYLON.Scene);
  91874. needAlphaBlending(): boolean;
  91875. needAlphaTesting(): boolean;
  91876. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91877. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91878. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91879. getAnimatables(): BABYLON.IAnimatable[];
  91880. getActiveTextures(): BABYLON.BaseTexture[];
  91881. hasTexture(texture: BABYLON.BaseTexture): boolean;
  91882. dispose(forceDisposeEffect?: boolean): void;
  91883. clone(name: string): SimpleMaterial;
  91884. serialize(): any;
  91885. getClassName(): string;
  91886. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  91887. }
  91888. }
  91889. declare module BABYLON {
  91890. /** @hidden */
  91891. export var skyPixelShader: {
  91892. name: string;
  91893. shader: string;
  91894. };
  91895. }
  91896. declare module BABYLON {
  91897. /** @hidden */
  91898. export var skyVertexShader: {
  91899. name: string;
  91900. shader: string;
  91901. };
  91902. }
  91903. declare module BABYLON {
  91904. /**
  91905. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  91906. * @see https://doc.babylonjs.com/extensions/sky
  91907. */
  91908. export class SkyMaterial extends BABYLON.PushMaterial {
  91909. /**
  91910. * Defines the overall luminance of sky in interval ]0, 1[.
  91911. */
  91912. luminance: number;
  91913. /**
  91914. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  91915. */
  91916. turbidity: number;
  91917. /**
  91918. * Defines the sky appearance (light intensity).
  91919. */
  91920. rayleigh: number;
  91921. /**
  91922. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  91923. */
  91924. mieCoefficient: number;
  91925. /**
  91926. * Defines the amount of haze particles following the Mie scattering theory.
  91927. */
  91928. mieDirectionalG: number;
  91929. /**
  91930. * Defines the distance of the sun according to the active scene camera.
  91931. */
  91932. distance: number;
  91933. /**
  91934. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  91935. * "inclined".
  91936. */
  91937. inclination: number;
  91938. /**
  91939. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  91940. * an object direction and a reference direction.
  91941. */
  91942. azimuth: number;
  91943. /**
  91944. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  91945. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  91946. */
  91947. sunPosition: BABYLON.Vector3;
  91948. /**
  91949. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  91950. * .sunPosition property.
  91951. */
  91952. useSunPosition: boolean;
  91953. /**
  91954. * Defines an offset vector used to get a horizon offset.
  91955. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  91956. */
  91957. cameraOffset: BABYLON.Vector3;
  91958. private _cameraPosition;
  91959. /**
  91960. * Instantiates a new sky material.
  91961. * This material allows to create dynamic and texture free
  91962. * effects for skyboxes by taking care of the atmosphere state.
  91963. * @see https://doc.babylonjs.com/extensions/sky
  91964. * @param name Define the name of the material in the scene
  91965. * @param scene Define the scene the material belong to
  91966. */
  91967. constructor(name: string, scene: BABYLON.Scene);
  91968. /**
  91969. * Specifies if the material will require alpha blending
  91970. * @returns a boolean specifying if alpha blending is needed
  91971. */
  91972. needAlphaBlending(): boolean;
  91973. /**
  91974. * Specifies if this material should be rendered in alpha test mode
  91975. * @returns false as the sky material doesn't need alpha testing.
  91976. */
  91977. needAlphaTesting(): boolean;
  91978. /**
  91979. * Get the texture used for alpha test purpose.
  91980. * @returns null as the sky material has no texture.
  91981. */
  91982. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  91983. /**
  91984. * Get if the submesh is ready to be used and all its information available.
  91985. * Child classes can use it to update shaders
  91986. * @param mesh defines the mesh to check
  91987. * @param subMesh defines which submesh to check
  91988. * @param useInstances specifies that instances should be used
  91989. * @returns a boolean indicating that the submesh is ready or not
  91990. */
  91991. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  91992. /**
  91993. * Binds the submesh to this material by preparing the effect and shader to draw
  91994. * @param world defines the world transformation matrix
  91995. * @param mesh defines the mesh containing the submesh
  91996. * @param subMesh defines the submesh to bind the material to
  91997. */
  91998. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  91999. /**
  92000. * Get the list of animatables in the material.
  92001. * @returns the list of animatables object used in the material
  92002. */
  92003. getAnimatables(): BABYLON.IAnimatable[];
  92004. /**
  92005. * Disposes the material
  92006. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  92007. */
  92008. dispose(forceDisposeEffect?: boolean): void;
  92009. /**
  92010. * Makes a duplicate of the material, and gives it a new name
  92011. * @param name defines the new name for the duplicated material
  92012. * @returns the cloned material
  92013. */
  92014. clone(name: string): SkyMaterial;
  92015. /**
  92016. * Serializes this material in a JSON representation
  92017. * @returns the serialized material object
  92018. */
  92019. serialize(): any;
  92020. /**
  92021. * Gets the current class name of the material e.g. "SkyMaterial"
  92022. * Mainly use in serialization.
  92023. * @returns the class name
  92024. */
  92025. getClassName(): string;
  92026. /**
  92027. * Creates a sky material from parsed material data
  92028. * @param source defines the JSON representation of the material
  92029. * @param scene defines the hosting scene
  92030. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92031. * @returns a new sky material
  92032. */
  92033. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  92034. }
  92035. }
  92036. declare module BABYLON {
  92037. /** @hidden */
  92038. export var terrainPixelShader: {
  92039. name: string;
  92040. shader: string;
  92041. };
  92042. }
  92043. declare module BABYLON {
  92044. /** @hidden */
  92045. export var terrainVertexShader: {
  92046. name: string;
  92047. shader: string;
  92048. };
  92049. }
  92050. declare module BABYLON {
  92051. export class TerrainMaterial extends BABYLON.PushMaterial {
  92052. private _mixTexture;
  92053. mixTexture: BABYLON.BaseTexture;
  92054. private _diffuseTexture1;
  92055. diffuseTexture1: BABYLON.Texture;
  92056. private _diffuseTexture2;
  92057. diffuseTexture2: BABYLON.Texture;
  92058. private _diffuseTexture3;
  92059. diffuseTexture3: BABYLON.Texture;
  92060. private _bumpTexture1;
  92061. bumpTexture1: BABYLON.Texture;
  92062. private _bumpTexture2;
  92063. bumpTexture2: BABYLON.Texture;
  92064. private _bumpTexture3;
  92065. bumpTexture3: BABYLON.Texture;
  92066. diffuseColor: BABYLON.Color3;
  92067. specularColor: BABYLON.Color3;
  92068. specularPower: number;
  92069. private _disableLighting;
  92070. disableLighting: boolean;
  92071. private _maxSimultaneousLights;
  92072. maxSimultaneousLights: number;
  92073. constructor(name: string, scene: BABYLON.Scene);
  92074. needAlphaBlending(): boolean;
  92075. needAlphaTesting(): boolean;
  92076. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92077. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92078. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92079. getAnimatables(): BABYLON.IAnimatable[];
  92080. getActiveTextures(): BABYLON.BaseTexture[];
  92081. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92082. dispose(forceDisposeEffect?: boolean): void;
  92083. clone(name: string): TerrainMaterial;
  92084. serialize(): any;
  92085. getClassName(): string;
  92086. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  92087. }
  92088. }
  92089. declare module BABYLON {
  92090. /** @hidden */
  92091. export var triplanarPixelShader: {
  92092. name: string;
  92093. shader: string;
  92094. };
  92095. }
  92096. declare module BABYLON {
  92097. /** @hidden */
  92098. export var triplanarVertexShader: {
  92099. name: string;
  92100. shader: string;
  92101. };
  92102. }
  92103. declare module BABYLON {
  92104. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  92105. mixTexture: BABYLON.BaseTexture;
  92106. private _diffuseTextureX;
  92107. diffuseTextureX: BABYLON.BaseTexture;
  92108. private _diffuseTextureY;
  92109. diffuseTextureY: BABYLON.BaseTexture;
  92110. private _diffuseTextureZ;
  92111. diffuseTextureZ: BABYLON.BaseTexture;
  92112. private _normalTextureX;
  92113. normalTextureX: BABYLON.BaseTexture;
  92114. private _normalTextureY;
  92115. normalTextureY: BABYLON.BaseTexture;
  92116. private _normalTextureZ;
  92117. normalTextureZ: BABYLON.BaseTexture;
  92118. tileSize: number;
  92119. diffuseColor: BABYLON.Color3;
  92120. specularColor: BABYLON.Color3;
  92121. specularPower: number;
  92122. private _disableLighting;
  92123. disableLighting: boolean;
  92124. private _maxSimultaneousLights;
  92125. maxSimultaneousLights: number;
  92126. constructor(name: string, scene: BABYLON.Scene);
  92127. needAlphaBlending(): boolean;
  92128. needAlphaTesting(): boolean;
  92129. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92130. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92131. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92132. getAnimatables(): BABYLON.IAnimatable[];
  92133. getActiveTextures(): BABYLON.BaseTexture[];
  92134. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92135. dispose(forceDisposeEffect?: boolean): void;
  92136. clone(name: string): TriPlanarMaterial;
  92137. serialize(): any;
  92138. getClassName(): string;
  92139. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  92140. }
  92141. }
  92142. declare module BABYLON {
  92143. /** @hidden */
  92144. export var waterPixelShader: {
  92145. name: string;
  92146. shader: string;
  92147. };
  92148. }
  92149. declare module BABYLON {
  92150. /** @hidden */
  92151. export var waterVertexShader: {
  92152. name: string;
  92153. shader: string;
  92154. };
  92155. }
  92156. declare module BABYLON {
  92157. export class WaterMaterial extends BABYLON.PushMaterial {
  92158. renderTargetSize: BABYLON.Vector2;
  92159. private _bumpTexture;
  92160. bumpTexture: BABYLON.BaseTexture;
  92161. diffuseColor: BABYLON.Color3;
  92162. specularColor: BABYLON.Color3;
  92163. specularPower: number;
  92164. private _disableLighting;
  92165. disableLighting: boolean;
  92166. private _maxSimultaneousLights;
  92167. maxSimultaneousLights: number;
  92168. /**
  92169. * Defines the wind force.
  92170. */
  92171. windForce: number;
  92172. /**
  92173. * Defines the direction of the wind in the plane (X, Z).
  92174. */
  92175. windDirection: BABYLON.Vector2;
  92176. /**
  92177. * Defines the height of the waves.
  92178. */
  92179. waveHeight: number;
  92180. /**
  92181. * Defines the bump height related to the bump map.
  92182. */
  92183. bumpHeight: number;
  92184. /**
  92185. * Defines wether or not: to add a smaller moving bump to less steady waves.
  92186. */
  92187. private _bumpSuperimpose;
  92188. bumpSuperimpose: boolean;
  92189. /**
  92190. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  92191. */
  92192. private _fresnelSeparate;
  92193. fresnelSeparate: boolean;
  92194. /**
  92195. * Defines wether or not bump Wwves modify the reflection.
  92196. */
  92197. private _bumpAffectsReflection;
  92198. bumpAffectsReflection: boolean;
  92199. /**
  92200. * Defines the water color blended with the refraction (near).
  92201. */
  92202. waterColor: BABYLON.Color3;
  92203. /**
  92204. * Defines the blend factor related to the water color.
  92205. */
  92206. colorBlendFactor: number;
  92207. /**
  92208. * Defines the water color blended with the reflection (far).
  92209. */
  92210. waterColor2: BABYLON.Color3;
  92211. /**
  92212. * Defines the blend factor related to the water color (reflection, far).
  92213. */
  92214. colorBlendFactor2: number;
  92215. /**
  92216. * Defines the maximum length of a wave.
  92217. */
  92218. waveLength: number;
  92219. /**
  92220. * Defines the waves speed.
  92221. */
  92222. waveSpeed: number;
  92223. /**
  92224. * 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.
  92225. */
  92226. waveCount: number;
  92227. /**
  92228. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  92229. * will avoid calculating useless pixels in the pixel shader of the water material.
  92230. */
  92231. disableClipPlane: boolean;
  92232. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  92233. private _mesh;
  92234. private _refractionRTT;
  92235. private _reflectionRTT;
  92236. private _reflectionTransform;
  92237. private _lastTime;
  92238. private _lastDeltaTime;
  92239. private _useLogarithmicDepth;
  92240. private _waitingRenderList;
  92241. private _imageProcessingConfiguration;
  92242. private _imageProcessingObserver;
  92243. /**
  92244. * Gets a boolean indicating that current material needs to register RTT
  92245. */
  92246. get hasRenderTargetTextures(): boolean;
  92247. /**
  92248. * Constructor
  92249. */
  92250. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  92251. get useLogarithmicDepth(): boolean;
  92252. set useLogarithmicDepth(value: boolean);
  92253. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92254. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  92255. addToRenderList(node: any): void;
  92256. enableRenderTargets(enable: boolean): void;
  92257. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  92258. get renderTargetsEnabled(): boolean;
  92259. needAlphaBlending(): boolean;
  92260. needAlphaTesting(): boolean;
  92261. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  92262. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  92263. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  92264. private _createRenderTargets;
  92265. getAnimatables(): BABYLON.IAnimatable[];
  92266. getActiveTextures(): BABYLON.BaseTexture[];
  92267. hasTexture(texture: BABYLON.BaseTexture): boolean;
  92268. dispose(forceDisposeEffect?: boolean): void;
  92269. clone(name: string): WaterMaterial;
  92270. serialize(): any;
  92271. getClassName(): string;
  92272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  92273. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  92274. }
  92275. }
  92276. declare module BABYLON {
  92277. /** @hidden */
  92278. export var asciiartPixelShader: {
  92279. name: string;
  92280. shader: string;
  92281. };
  92282. }
  92283. declare module BABYLON {
  92284. /**
  92285. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  92286. *
  92287. * It basically takes care rendering the font front the given font size to a texture.
  92288. * This is used later on in the postprocess.
  92289. */
  92290. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  92291. private _font;
  92292. private _text;
  92293. private _charSize;
  92294. /**
  92295. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92296. */
  92297. get charSize(): number;
  92298. /**
  92299. * Create a new instance of the Ascii Art FontTexture class
  92300. * @param name the name of the texture
  92301. * @param font the font to use, use the W3C CSS notation
  92302. * @param text the caracter set to use in the rendering.
  92303. * @param scene the scene that owns the texture
  92304. */
  92305. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92306. /**
  92307. * Gets the max char width of a font.
  92308. * @param font the font to use, use the W3C CSS notation
  92309. * @return the max char width
  92310. */
  92311. private getFontWidth;
  92312. /**
  92313. * Gets the max char height of a font.
  92314. * @param font the font to use, use the W3C CSS notation
  92315. * @return the max char height
  92316. */
  92317. private getFontHeight;
  92318. /**
  92319. * Clones the current AsciiArtTexture.
  92320. * @return the clone of the texture.
  92321. */
  92322. clone(): AsciiArtFontTexture;
  92323. /**
  92324. * Parses a json object representing the texture and returns an instance of it.
  92325. * @param source the source JSON representation
  92326. * @param scene the scene to create the texture for
  92327. * @return the parsed texture
  92328. */
  92329. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  92330. }
  92331. /**
  92332. * Option available in the Ascii Art Post Process.
  92333. */
  92334. export interface IAsciiArtPostProcessOptions {
  92335. /**
  92336. * The font to use following the w3c font definition.
  92337. */
  92338. font?: string;
  92339. /**
  92340. * The character set to use in the postprocess.
  92341. */
  92342. characterSet?: string;
  92343. /**
  92344. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92345. * This number is defined between 0 and 1;
  92346. */
  92347. mixToTile?: number;
  92348. /**
  92349. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92350. * This number is defined between 0 and 1;
  92351. */
  92352. mixToNormal?: number;
  92353. }
  92354. /**
  92355. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  92356. *
  92357. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92358. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  92359. */
  92360. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  92361. /**
  92362. * The font texture used to render the char in the post process.
  92363. */
  92364. private _asciiArtFontTexture;
  92365. /**
  92366. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  92367. * This number is defined between 0 and 1;
  92368. */
  92369. mixToTile: number;
  92370. /**
  92371. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  92372. * This number is defined between 0 and 1;
  92373. */
  92374. mixToNormal: number;
  92375. /**
  92376. * Instantiates a new Ascii Art Post Process.
  92377. * @param name the name to give to the postprocess
  92378. * @camera the camera to apply the post process to.
  92379. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  92380. */
  92381. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  92382. }
  92383. }
  92384. declare module BABYLON {
  92385. /** @hidden */
  92386. export var digitalrainPixelShader: {
  92387. name: string;
  92388. shader: string;
  92389. };
  92390. }
  92391. declare module BABYLON {
  92392. /**
  92393. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  92394. *
  92395. * It basically takes care rendering the font front the given font size to a texture.
  92396. * This is used later on in the postprocess.
  92397. */
  92398. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  92399. private _font;
  92400. private _text;
  92401. private _charSize;
  92402. /**
  92403. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  92404. */
  92405. get charSize(): number;
  92406. /**
  92407. * Create a new instance of the Digital Rain FontTexture class
  92408. * @param name the name of the texture
  92409. * @param font the font to use, use the W3C CSS notation
  92410. * @param text the caracter set to use in the rendering.
  92411. * @param scene the scene that owns the texture
  92412. */
  92413. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  92414. /**
  92415. * Gets the max char width of a font.
  92416. * @param font the font to use, use the W3C CSS notation
  92417. * @return the max char width
  92418. */
  92419. private getFontWidth;
  92420. /**
  92421. * Gets the max char height of a font.
  92422. * @param font the font to use, use the W3C CSS notation
  92423. * @return the max char height
  92424. */
  92425. private getFontHeight;
  92426. /**
  92427. * Clones the current DigitalRainFontTexture.
  92428. * @return the clone of the texture.
  92429. */
  92430. clone(): DigitalRainFontTexture;
  92431. /**
  92432. * Parses a json object representing the texture and returns an instance of it.
  92433. * @param source the source JSON representation
  92434. * @param scene the scene to create the texture for
  92435. * @return the parsed texture
  92436. */
  92437. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  92438. }
  92439. /**
  92440. * Option available in the Digital Rain Post Process.
  92441. */
  92442. export interface IDigitalRainPostProcessOptions {
  92443. /**
  92444. * The font to use following the w3c font definition.
  92445. */
  92446. font?: string;
  92447. /**
  92448. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92449. * This number is defined between 0 and 1;
  92450. */
  92451. mixToTile?: number;
  92452. /**
  92453. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92454. * This number is defined between 0 and 1;
  92455. */
  92456. mixToNormal?: number;
  92457. }
  92458. /**
  92459. * DigitalRainPostProcess helps rendering everithing in digital rain.
  92460. *
  92461. * Simmply add it to your scene and let the nerd that lives in you have fun.
  92462. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  92463. */
  92464. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  92465. /**
  92466. * The font texture used to render the char in the post process.
  92467. */
  92468. private _digitalRainFontTexture;
  92469. /**
  92470. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  92471. * This number is defined between 0 and 1;
  92472. */
  92473. mixToTile: number;
  92474. /**
  92475. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  92476. * This number is defined between 0 and 1;
  92477. */
  92478. mixToNormal: number;
  92479. /**
  92480. * Instantiates a new Digital Rain Post Process.
  92481. * @param name the name to give to the postprocess
  92482. * @camera the camera to apply the post process to.
  92483. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  92484. */
  92485. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  92486. }
  92487. }
  92488. declare module BABYLON {
  92489. /** @hidden */
  92490. export var brickProceduralTexturePixelShader: {
  92491. name: string;
  92492. shader: string;
  92493. };
  92494. }
  92495. declare module BABYLON {
  92496. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  92497. private _numberOfBricksHeight;
  92498. private _numberOfBricksWidth;
  92499. private _jointColor;
  92500. private _brickColor;
  92501. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92502. updateShaderUniforms(): void;
  92503. get numberOfBricksHeight(): number;
  92504. set numberOfBricksHeight(value: number);
  92505. get numberOfBricksWidth(): number;
  92506. set numberOfBricksWidth(value: number);
  92507. get jointColor(): BABYLON.Color3;
  92508. set jointColor(value: BABYLON.Color3);
  92509. get brickColor(): BABYLON.Color3;
  92510. set brickColor(value: BABYLON.Color3);
  92511. /**
  92512. * Serializes this brick procedural texture
  92513. * @returns a serialized brick procedural texture object
  92514. */
  92515. serialize(): any;
  92516. /**
  92517. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  92518. * @param parsedTexture defines parsed texture data
  92519. * @param scene defines the current scene
  92520. * @param rootUrl defines the root URL containing brick procedural texture information
  92521. * @returns a parsed Brick Procedural BABYLON.Texture
  92522. */
  92523. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  92524. }
  92525. }
  92526. declare module BABYLON {
  92527. /** @hidden */
  92528. export var cloudProceduralTexturePixelShader: {
  92529. name: string;
  92530. shader: string;
  92531. };
  92532. }
  92533. declare module BABYLON {
  92534. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  92535. private _skyColor;
  92536. private _cloudColor;
  92537. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92538. updateShaderUniforms(): void;
  92539. get skyColor(): BABYLON.Color4;
  92540. set skyColor(value: BABYLON.Color4);
  92541. get cloudColor(): BABYLON.Color4;
  92542. set cloudColor(value: BABYLON.Color4);
  92543. /**
  92544. * Serializes this cloud procedural texture
  92545. * @returns a serialized cloud procedural texture object
  92546. */
  92547. serialize(): any;
  92548. /**
  92549. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  92550. * @param parsedTexture defines parsed texture data
  92551. * @param scene defines the current scene
  92552. * @param rootUrl defines the root URL containing cloud procedural texture information
  92553. * @returns a parsed Cloud Procedural BABYLON.Texture
  92554. */
  92555. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  92556. }
  92557. }
  92558. declare module BABYLON {
  92559. /** @hidden */
  92560. export var fireProceduralTexturePixelShader: {
  92561. name: string;
  92562. shader: string;
  92563. };
  92564. }
  92565. declare module BABYLON {
  92566. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  92567. private _time;
  92568. private _speed;
  92569. private _autoGenerateTime;
  92570. private _fireColors;
  92571. private _alphaThreshold;
  92572. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92573. updateShaderUniforms(): void;
  92574. render(useCameraPostProcess?: boolean): void;
  92575. static get PurpleFireColors(): BABYLON.Color3[];
  92576. static get GreenFireColors(): BABYLON.Color3[];
  92577. static get RedFireColors(): BABYLON.Color3[];
  92578. static get BlueFireColors(): BABYLON.Color3[];
  92579. get autoGenerateTime(): boolean;
  92580. set autoGenerateTime(value: boolean);
  92581. get fireColors(): BABYLON.Color3[];
  92582. set fireColors(value: BABYLON.Color3[]);
  92583. get time(): number;
  92584. set time(value: number);
  92585. get speed(): BABYLON.Vector2;
  92586. set speed(value: BABYLON.Vector2);
  92587. get alphaThreshold(): number;
  92588. set alphaThreshold(value: number);
  92589. /**
  92590. * Serializes this fire procedural texture
  92591. * @returns a serialized fire procedural texture object
  92592. */
  92593. serialize(): any;
  92594. /**
  92595. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  92596. * @param parsedTexture defines parsed texture data
  92597. * @param scene defines the current scene
  92598. * @param rootUrl defines the root URL containing fire procedural texture information
  92599. * @returns a parsed Fire Procedural BABYLON.Texture
  92600. */
  92601. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  92602. }
  92603. }
  92604. declare module BABYLON {
  92605. /** @hidden */
  92606. export var grassProceduralTexturePixelShader: {
  92607. name: string;
  92608. shader: string;
  92609. };
  92610. }
  92611. declare module BABYLON {
  92612. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  92613. private _grassColors;
  92614. private _groundColor;
  92615. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92616. updateShaderUniforms(): void;
  92617. get grassColors(): BABYLON.Color3[];
  92618. set grassColors(value: BABYLON.Color3[]);
  92619. get groundColor(): BABYLON.Color3;
  92620. set groundColor(value: BABYLON.Color3);
  92621. /**
  92622. * Serializes this grass procedural texture
  92623. * @returns a serialized grass procedural texture object
  92624. */
  92625. serialize(): any;
  92626. /**
  92627. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  92628. * @param parsedTexture defines parsed texture data
  92629. * @param scene defines the current scene
  92630. * @param rootUrl defines the root URL containing grass procedural texture information
  92631. * @returns a parsed Grass Procedural BABYLON.Texture
  92632. */
  92633. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  92634. }
  92635. }
  92636. declare module BABYLON {
  92637. /** @hidden */
  92638. export var marbleProceduralTexturePixelShader: {
  92639. name: string;
  92640. shader: string;
  92641. };
  92642. }
  92643. declare module BABYLON {
  92644. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  92645. private _numberOfTilesHeight;
  92646. private _numberOfTilesWidth;
  92647. private _amplitude;
  92648. private _jointColor;
  92649. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92650. updateShaderUniforms(): void;
  92651. get numberOfTilesHeight(): number;
  92652. set numberOfTilesHeight(value: number);
  92653. get amplitude(): number;
  92654. set amplitude(value: number);
  92655. get numberOfTilesWidth(): number;
  92656. set numberOfTilesWidth(value: number);
  92657. get jointColor(): BABYLON.Color3;
  92658. set jointColor(value: BABYLON.Color3);
  92659. /**
  92660. * Serializes this marble procedural texture
  92661. * @returns a serialized marble procedural texture object
  92662. */
  92663. serialize(): any;
  92664. /**
  92665. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  92666. * @param parsedTexture defines parsed texture data
  92667. * @param scene defines the current scene
  92668. * @param rootUrl defines the root URL containing marble procedural texture information
  92669. * @returns a parsed Marble Procedural BABYLON.Texture
  92670. */
  92671. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  92672. }
  92673. }
  92674. declare module BABYLON {
  92675. /** @hidden */
  92676. export var normalMapProceduralTexturePixelShader: {
  92677. name: string;
  92678. shader: string;
  92679. };
  92680. }
  92681. declare module BABYLON {
  92682. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  92683. private _baseTexture;
  92684. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92685. updateShaderUniforms(): void;
  92686. render(useCameraPostProcess?: boolean): void;
  92687. resize(size: any, generateMipMaps: any): void;
  92688. isReady(): boolean;
  92689. get baseTexture(): BABYLON.Texture;
  92690. set baseTexture(texture: BABYLON.Texture);
  92691. /**
  92692. * Serializes this normal map procedural texture
  92693. * @returns a serialized normal map procedural texture object
  92694. */
  92695. serialize(): any;
  92696. /**
  92697. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  92698. * @param parsedTexture defines parsed texture data
  92699. * @param scene defines the current scene
  92700. * @param rootUrl defines the root URL containing normal map procedural texture information
  92701. * @returns a parsed Normal Map Procedural BABYLON.Texture
  92702. */
  92703. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  92704. }
  92705. }
  92706. declare module BABYLON {
  92707. /** @hidden */
  92708. export var perlinNoiseProceduralTexturePixelShader: {
  92709. name: string;
  92710. shader: string;
  92711. };
  92712. }
  92713. declare module BABYLON {
  92714. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  92715. time: number;
  92716. timeScale: number;
  92717. translationSpeed: number;
  92718. private _currentTranslation;
  92719. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92720. updateShaderUniforms(): void;
  92721. render(useCameraPostProcess?: boolean): void;
  92722. resize(size: any, generateMipMaps: any): void;
  92723. /**
  92724. * Serializes this perlin noise procedural texture
  92725. * @returns a serialized perlin noise procedural texture object
  92726. */
  92727. serialize(): any;
  92728. /**
  92729. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  92730. * @param parsedTexture defines parsed texture data
  92731. * @param scene defines the current scene
  92732. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  92733. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  92734. */
  92735. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  92736. }
  92737. }
  92738. declare module BABYLON {
  92739. /** @hidden */
  92740. export var roadProceduralTexturePixelShader: {
  92741. name: string;
  92742. shader: string;
  92743. };
  92744. }
  92745. declare module BABYLON {
  92746. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  92747. private _roadColor;
  92748. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92749. updateShaderUniforms(): void;
  92750. get roadColor(): BABYLON.Color3;
  92751. set roadColor(value: BABYLON.Color3);
  92752. /**
  92753. * Serializes this road procedural texture
  92754. * @returns a serialized road procedural texture object
  92755. */
  92756. serialize(): any;
  92757. /**
  92758. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  92759. * @param parsedTexture defines parsed texture data
  92760. * @param scene defines the current scene
  92761. * @param rootUrl defines the root URL containing road procedural texture information
  92762. * @returns a parsed Road Procedural BABYLON.Texture
  92763. */
  92764. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  92765. }
  92766. }
  92767. declare module BABYLON {
  92768. /** @hidden */
  92769. export var starfieldProceduralTexturePixelShader: {
  92770. name: string;
  92771. shader: string;
  92772. };
  92773. }
  92774. declare module BABYLON {
  92775. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  92776. private _time;
  92777. private _alpha;
  92778. private _beta;
  92779. private _zoom;
  92780. private _formuparam;
  92781. private _stepsize;
  92782. private _tile;
  92783. private _brightness;
  92784. private _darkmatter;
  92785. private _distfading;
  92786. private _saturation;
  92787. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92788. updateShaderUniforms(): void;
  92789. get time(): number;
  92790. set time(value: number);
  92791. get alpha(): number;
  92792. set alpha(value: number);
  92793. get beta(): number;
  92794. set beta(value: number);
  92795. get formuparam(): number;
  92796. set formuparam(value: number);
  92797. get stepsize(): number;
  92798. set stepsize(value: number);
  92799. get zoom(): number;
  92800. set zoom(value: number);
  92801. get tile(): number;
  92802. set tile(value: number);
  92803. get brightness(): number;
  92804. set brightness(value: number);
  92805. get darkmatter(): number;
  92806. set darkmatter(value: number);
  92807. get distfading(): number;
  92808. set distfading(value: number);
  92809. get saturation(): number;
  92810. set saturation(value: number);
  92811. /**
  92812. * Serializes this starfield procedural texture
  92813. * @returns a serialized starfield procedural texture object
  92814. */
  92815. serialize(): any;
  92816. /**
  92817. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  92818. * @param parsedTexture defines parsed texture data
  92819. * @param scene defines the current scene
  92820. * @param rootUrl defines the root URL containing startfield procedural texture information
  92821. * @returns a parsed Starfield Procedural BABYLON.Texture
  92822. */
  92823. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  92824. }
  92825. }
  92826. declare module BABYLON {
  92827. /** @hidden */
  92828. export var woodProceduralTexturePixelShader: {
  92829. name: string;
  92830. shader: string;
  92831. };
  92832. }
  92833. declare module BABYLON {
  92834. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  92835. private _ampScale;
  92836. private _woodColor;
  92837. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  92838. updateShaderUniforms(): void;
  92839. get ampScale(): number;
  92840. set ampScale(value: number);
  92841. get woodColor(): BABYLON.Color3;
  92842. set woodColor(value: BABYLON.Color3);
  92843. /**
  92844. * Serializes this wood procedural texture
  92845. * @returns a serialized wood procedural texture object
  92846. */
  92847. serialize(): any;
  92848. /**
  92849. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  92850. * @param parsedTexture defines parsed texture data
  92851. * @param scene defines the current scene
  92852. * @param rootUrl defines the root URL containing wood procedural texture information
  92853. * @returns a parsed Wood Procedural BABYLON.Texture
  92854. */
  92855. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  92856. }
  92857. }